1 // antenna.cxx -- implementation of FGRadioAntenna
2 // Class to represent a virtual radio antenna properties
3 // Written by Adrian Musceac, started December 2011.
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License as
7 // published by the Free Software Foundation; either version 2 of the
8 // License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful, but
11 // WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28 #include <Scenery/scenery.hxx>
29 #include "antenna.hxx"
33 FGRadioAntenna::FGRadioAntenna(string type) {
38 load_antenna_pattern(type);
41 FGRadioAntenna::~FGRadioAntenna() {
45 double FGRadioAntenna::calculate_gain(double azimuth, double elevation) {
51 /*** load external plot file generated by NEC4
53 void FGRadioAntenna::load_antenna_pattern(string type) {
55 SGPath pattern_file(fgGetString("/sim/fg-home"));
56 pattern_file.append("antennas");
57 pattern_file.append(type + ".txt");
58 if (!pattern_file.exists()) {
61 ifstream file_in(pattern_file.c_str());
62 int heading, elevation;
64 while(!file_in.eof()) {
65 file_in >> heading >> elevation >> gain;
66 cerr << "head: " << heading << " elev: " << elevation << " gain: " << gain << endl;
67 AntennaGain datapoint;
68 datapoint.azimuth = heading;
69 datapoint.elevation = elevation;
70 datapoint.gain = gain;
71 _pattern.push_back(datapoint);