diff --git a/src/Radio/CMakeLists.txt b/src/Radio/CMakeLists.txt index aa6d5483b..72b1705f5 100644 --- a/src/Radio/CMakeLists.txt +++ b/src/Radio/CMakeLists.txt @@ -1,11 +1,13 @@ include(FlightGearComponent) set(SOURCES + antenna.cxx radio.cxx itm.cpp ) set(HEADERS + antenna.hxx radio.hxx ) diff --git a/src/Radio/antenna.cxx b/src/Radio/antenna.cxx index e3909103b..22496d81e 100644 --- a/src/Radio/antenna.cxx +++ b/src/Radio/antenna.cxx @@ -15,3 +15,37 @@ // 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 +#endif + +#include + +#include + +#include +#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() { + +} diff --git a/src/Radio/antenna.hxx b/src/Radio/antenna.hxx index 9d54c4cac..ec5d30253 100644 --- a/src/Radio/antenna.hxx +++ b/src/Radio/antenna.hxx @@ -15,3 +15,39 @@ // 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 +#include +#include
+ +#include +#include + +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 AntennaPattern; + AntennaPattern _pattern; + +public: + + FGRadioAntenna(); + ~FGRadioAntenna(); + double calculate_gain(double azimuth, double theta); + + +}; diff --git a/src/Radio/radio.cxx b/src/Radio/radio.cxx index d2d6a159b..d5211615a 100644 --- a/src/Radio/radio.cxx +++ b/src/Radio/radio.cxx @@ -357,13 +357,6 @@ double FGRadioTransmission::ITM_calculate_attenuation(SGGeod pos, double freq, i } - double max_alt_between=0.0; - for( deque::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); @@ -875,4 +868,23 @@ double FGRadioTransmission::LOS_calculate_attenuation(SGGeod pos, double freq, i } +/*** 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)); +} + diff --git a/src/Radio/radio.hxx b/src/Radio/radio.hxx index ac6dc9e3d..cafa2b386 100644 --- a/src/Radio/radio.hxx +++ b/src/Radio/radio.hxx @@ -53,6 +53,7 @@ private: std::map _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 materials,