]> git.mxchange.org Git - flightgear.git/commitdiff
Add function to calculate polarization loss
authoradrian <adrian@localhost.com>
Thu, 1 Dec 2011 20:46:46 +0000 (22:46 +0200)
committeradrian <adrian@localhost.com>
Thu, 1 Dec 2011 20:46:46 +0000 (22:46 +0200)
This function is reliable only for vertical polarization

src/Radio/CMakeLists.txt
src/Radio/antenna.cxx
src/Radio/antenna.hxx
src/Radio/radio.cxx
src/Radio/radio.hxx

index aa6d5483bd5198a2d4c9e275dc9101d5705ad701..72b1705f51c488f85913278779d41712ed02fab1 100644 (file)
@@ -1,11 +1,13 @@
 include(FlightGearComponent)
 
 set(SOURCES
+       antenna.cxx
        radio.cxx
        itm.cpp
        )
 
 set(HEADERS
+       antenna.hxx
        radio.hxx
        )
 
index e3909103bd0dd2e958526213e0a7df51dec09f60..22496d81e9b7b5ab589ea403a430e8f8202e8b7c 100644 (file)
 // 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() {
+       
+}
index 9d54c4cace19783e15b645503e90413b8f15e593..ec5d302533d9a000a04029a06f9b095cf3524af4 100644 (file)
 // 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);
+       
+       
+};
index d2d6a159ba0935829012ce4effd3fd4ebfde4b90..d5211615a427fabae29981783dd8d6aa1547d2a5 100644 (file)
@@ -357,13 +357,6 @@ double FGRadioTransmission::ITM_calculate_attenuation(SGGeod pos, double freq, i
        }
        
        
-       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);
@@ -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));
+}
+
 
index ac6dc9e3d357449f4bffd82fa40f53bf3c08673a..cafa2b3866b73997bbe46795429f49e0860166f5 100644 (file)
@@ -53,6 +53,7 @@ private:
        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,