From: <flightgearbugs@go...>  20140425 13:00:27

Status: New Owner:  New issue 1453 by aceofs...@...: Longitude error in SGGeodesy::SGCartToGeod? http://code.google.com/p/flightgearbugs/issues/detail?id=1453 *What steps will reproduce the problem?* *What is the expected output? What do you see instead?* 1. In the line geod.setLongitudeRad(2*atan2(Y, X+sqrtXXpYY)); , 2. if parameter "cart" has the value (6600000.0, 0.0, 0.0) (or any other absolute values for X (in negative), as long as it is bigger than the maximum radius of the earth), 3. the longitude will be zero, instead of Pi or negative Pi. 4. It is unlikely that a plane in flight will hit this value (exactly at (x,0.0,0.0)) (x, being negative), but the function then is not robust ... Fix: (1) ((Moreorless) exactly same output, but higher overhead ... ) geod.setLongitudeRad( X>=0.0? (2*atan2(Y,X+sqrtXXpYY)): (2*atan2(Y,sqrtXXpYYX)+SGMisc<double>::pi())); or ... (2) (Fast, but not preferable ... ) geod.setLongitudeRad(atan2(Y,X)); https://gitorious.org/fg/simgear/source/85b17ae8d4588312a1a82cd767c7150a13a00598:simgear/math/SGGeodesy.cxx Reference (to calculate longitude): http://www.iagaig.org/attach/989c8e501d9c5b5e2736955baf2632f5/V60N2_5FT.pdf Have a nice day!  You received this message because this project is configured to send all issue notifications to this address. You may adjust your notification preferences at: https://code.google.com/hosting/settings 