From eccd695f91f8c6c2dae63c3a96382e0a00772306 Mon Sep 17 00:00:00 2001 From: curt Date: Mon, 19 Mar 2001 13:56:19 +0000 Subject: [PATCH] Fixed some problems with marker beacon range: a) I was compairing feet vs. meter (making the range 3x too. big) b) I was using the diameter in place of the radius (making the range an additional 2x too big.) c) Updated the equation for calculating range to model the weak transmitter not being picked up at upper altitudes. We still might need some additional tweaking, but I think we are starting to get in the right ball park. --- src/GUI/gui_local.hxx | 6 ++++++ src/Main/main.cxx | 4 ++-- src/Navaids/mkrbeacons.cxx | 25 ++++++++++++++++++------- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/GUI/gui_local.hxx b/src/GUI/gui_local.hxx index 82698d95a..6958f7118 100644 --- a/src/GUI/gui_local.hxx +++ b/src/GUI/gui_local.hxx @@ -1,3 +1,9 @@ +#ifdef HAVE_CONFIG_H +# include +#endif + +#include + #include "trackball.h" #if defined(WIN32) || defined(__CYGWIN32__) diff --git a/src/Main/main.cxx b/src/Main/main.cxx index bab4f7e91..d669b9072 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -30,8 +30,8 @@ #endif #ifdef HAVE_WINDOWS_H -# include -# include +# include +# include #endif #include diff --git a/src/Navaids/mkrbeacons.cxx b/src/Navaids/mkrbeacons.cxx index a3e8d33ed..6c4da70ed 100644 --- a/src/Navaids/mkrbeacons.cxx +++ b/src/Navaids/mkrbeacons.cxx @@ -172,7 +172,7 @@ FGBeacon::fgMkrBeacType FGMarkerBeacons::query( double lon, double lat, // cout << " aircraft = " << aircraft << " station = " << station // << endl; - double d = aircraft.distance3Dsquared( station ); + double d = aircraft.distance3Dsquared( station ); // meters^2 // cout << " distance = " << d << " (" // << FG_ILS_DEFAULT_RANGE * NM_TO_METER // * FG_ILS_DEFAULT_RANGE * NM_TO_METER @@ -187,20 +187,31 @@ FGBeacon::fgMkrBeacType FGMarkerBeacons::query( double lon, double lat, // cout << "elev = " << elev * METER_TO_FEET // << " current->get_elev() = " << current->get_elev() << endl; double delev = elev * METER_TO_FEET - current->get_elev(); - double maxrange = 4200 * delev / 1000; + + // max range is the area under r = 2.4 * alt or r^2 = 4000^2 - alt^2 + // whichever is smaller. The intersection point is 1538 ... + double maxrange2; // feet^2 + if ( delev < 1538.0 ) { + maxrange2 = 2.4 * 2.4 * delev * delev; + } else if ( delev < 4000.0 ) { + maxrange2 = 4000 * 4000 - delev * delev; + } else { + maxrange2 = 0.0; + } + maxrange2 *= FEET_TO_METER * FEET_TO_METER; // convert to meter^2 // cout << "delev = " << delev << " maxrange = " << maxrange << endl; // match up to twice the published range so we can model // reduced signal strength - if ( d < maxrange * maxrange ) { - // cout << "lon = " << lon << " lat = " << lat - // << " closest beacon = " << sqrt( min_dist ) << endl; + if ( d < maxrange2 ) { + cout << "lon = " << lon << " lat = " << lat + << " closest beacon = " << sqrt( min_dist ) << endl; return current->get_type(); } } - // cout << "lon = " << lon << " lat = " << lat - // << " closest beacon = " << sqrt( min_dist ) << endl; + cout << "lon = " << lon << " lat = " << lat + << " closest beacon = " << sqrt( min_dist ) << endl; return FGBeacon::NOBEACON; }