On Sat, Jan 10, 2009 at 5:50 PM, John Denker <j...@av8n.com> wrote:
> On 01/10/2009 09:13 AM, Csaba Halász wrote:
>> #2  0x000000000080188d in FGNavRadio::update (this=0x98df490,
>> dt=0.058333333333333334) at src/Instrumentation/navradio.cxx:613
>> 613                     double angle = asin( y / x ) * 
>> SGD_RADIANS_TO_DEGREES;
>> (gdb) p x
>> $1 = 3.2580450943147174
>> (gdb) p y
>> $2 = 3.258443598627875
>> (gdb) p y / x
>> $3 = 1.0001223139341602
>>
>> No idea what it is calculating and how to fix. (apart from forcibly
>> clamping y/x to [-1, 1] ...)
>
> It's calculating your angle of elevation relative to the
> glideslope antenna.  The code would be correct except for
> roundoff error.  To provoke this bug you need to sit directly
> above the GS transmitter, vertically within a few thousandths
> of a degree, and then get unlucky w.r.t roundoff.

Not that much (un)luck needed, I can reproduce it easily just flying
above rwy 28L at KSFO.

> Clamping it is guaranteed 100% safe and effective.

Something like the attached patch? Not sure what to do about the x == 0 case.

-- 
Csaba/Jester
Index: src/Instrumentation/navradio.cxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/Instrumentation/navradio.cxx,v
retrieving revision 1.31
diff -u -r1.31 navradio.cxx
--- src/Instrumentation/navradio.cxx	25 Dec 2008 23:11:44 -0000	1.31
+++ src/Instrumentation/navradio.cxx	10 Jan 2009 17:17:54 -0000
@@ -610,7 +610,8 @@
                 double y = (fgGetDouble("/position/altitude-ft") - nav_elev)
                     * SG_FEET_TO_METER;
                 // cout << "dist = " << x << " height = " << y << endl;
-                double angle = asin( y / x ) * SGD_RADIANS_TO_DEGREES;
+                double quotient = (x == 0) ? 1 : y / x;
+                double angle = (quotient >= 1) ? 90 : (quotient <= -1 ? -90 : (asin(quotient) * SGD_RADIANS_TO_DEGREES));
                 r = (target_gs - angle) * 5.0;
                 r *= signal_quality_norm;
             }
------------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It is the best place to buy or sell services for
just about anything Open Source.
http://p.sf.net/sfu/Xq1LFB
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to