On 01/10/2009 10:22 AM, Csaba Halász wrote:
>> Clamping it is guaranteed 100% safe and effective.
>
> Something like the attached patch? Not sure what to do about the x == 0 case.
How about this version? It assumes dist is not less than zero,
but is otherwise pretty defensive.
diff --git a/src/Instrumentation/navradio.cxx b/src/Instrumentation/navradio.cxx
index 45d0588..cd85902 100644
--- a/src/Instrumentation/navradio.cxx
+++ b/src/Instrumentation/navradio.cxx
@@ -665,7 +665,10 @@ FGNavRadio::update(double dt)
double y = (fgGetDouble("/position/altitude-ft") - gs_elev)
* SG_FEET_TO_METER;
// cout << "dist = " << dist << " height = " << y << endl;
- double angle = asin( y / dist ) * SGD_RADIANS_TO_DEGREES;
+ double angle;
+ if (dist <= y) angle = 90.0; // Need to defend
+ else if (dist <= -y) angle = -90.0; // against roundoff.
+ else angle = asin( y / dist ) * SGD_RADIANS_TO_DEGREES;
// The factor of 1.5 gives a period of 6 degrees.
// There will be zeros at 3, 6r, 9, 12r et cetera
------------------------------------------------------------------------------
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