NavList:
A Community Devoted to the Preservation and Practice of Celestial Navigation and Other Methods of Traditional Wayfinding
Re: distance with atan2
From: Paul Hirose
Date: 2005 Nov 11, 15:44 -0800
From: Paul Hirose
Date: 2005 Nov 11, 15:44 -0800
One way to calculate distance (separation angle) on a sphere is to use vectors and the atan2 function or rectangular to polar conversion. Set x to the dot product of the two vectors, and y to the magnitude of their cross product. The separation angle is atan2(y, x), or you can get the angle by converting x and y to polar form. For example, Meeus calculates the separation angle between two stars: 14h 15m 39.7s +19°10′57″ 13h 25m 11.6s -11°09′41″ He uses spherical trig. Using the vector method, start by forming the rectanglar coordinates on the celestial sphere: -.783786 -.526988 .328578 -.914079 -.356354 -.193573 dot product = .840633 (x) cross product magnitude = .541606 (y) Converting (x, y) to polar form gives angle 32.7930°, which agrees with Meeus. An advantage of the vector method is its accuracy at all angles. A large portion of Meeus' chapter on separation angle discusses ways to avoid the inaccuracy of the traditional spherical trig formula near 0 or 180 degrees.