include(FlightGearComponent)
set(SOURCES
+ antenna.cxx
radio.cxx
itm.cpp
)
set(HEADERS
+ antenna.hxx
radio.hxx
)
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <math.h>
+
+#include <stdlib.h>
+
+#include <Scenery/scenery.hxx>
+#include "antenna.hxx"
+
+
+FGRadioAntenna::FGRadioAntenna() {
+
+ _mirror_y = 1;
+ _mirror_z = 1;
+}
+
+FGRadioAntenna::~FGRadioAntenna() {
+
+}
+
+double FGRadioAntenna::calculate_gain(double azimuth, double theta) {
+ return 0;
+}
+
+
+
+
+void FGRadioAntenna::_load_antenna_pattern() {
+
+}
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+#ifndef __cplusplus
+# error This library requires C++
+#endif
+
+#include <simgear/compiler.h>
+#include <simgear/structure/subsystem_mgr.hxx>
+#include <Main/fg_props.hxx>
+
+#include <simgear/math/sg_geodesy.hxx>
+#include <simgear/debug/logstream.hxx>
+
+class FGRadioAntenna
+{
+private:
+ void _load_antenna_pattern();
+ int _mirror_y;
+ int _mirror_z;
+ double _heading;
+ struct AntennaGain {
+ double azimuth;
+ double elevation_angle;
+ double gain;
+ };
+
+ typedef std::vector<AntennaGain> AntennaPattern;
+ AntennaPattern _pattern;
+
+public:
+
+ FGRadioAntenna();
+ ~FGRadioAntenna();
+ double calculate_gain(double azimuth, double theta);
+
+
+};
}
- double max_alt_between=0.0;
- for( deque<double>::size_type i = 0; i < _elevations.size(); i++ ) {
- if (_elevations[i] > max_alt_between) {
- max_alt_between = _elevations[i];
- }
- }
-
double num_points= (double)_elevations.size();
_elevations.push_front(point_distance);
}
+/*** calculate loss due to polarization mismatch
+* this function is only reliable for vertical polarization
+* due to the V-shape of horizontally polarized antennas
+***/
+double FGRadioTransmission::polarization_loss() {
+
+ double theta_deg;
+ double roll = fgGetDouble("/orientation/roll-deg");
+ double pitch = fgGetDouble("/orientation/pitch-deg");
+ double theta = acos( sqrt( cos(roll) * cos(roll) + cos(pitch) * cos(pitch) ));
+ if (_polarization == 1)
+ theta_deg = 90.0 - theta;
+ else
+ theta_deg = theta;
+ if (fabs(theta_deg) > 85.0) // we don't want to converge into infinity
+ theta_deg = 85.0;
+ return 10 * log10(cos(theta_deg) * cos(theta_deg));
+}
+
std::map<string, double[2]> _mat_database;
int _propagation_model; /// 0 none, 1 round Earth, 2 ITM
+ double polarization_loss();
double ITM_calculate_attenuation(SGGeod tx_pos, double freq, int ground_to_air);
double LOS_calculate_attenuation(SGGeod tx_pos, double freq, int ground_to_air);
void clutterLoss(double freq, double distance_m, double itm_elev[], std::deque<string> materials,