Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!seismo!hao!cires!nbires!ut-ngp!utastro!bill From: bill@utastro.UUCP Newsgroups: net.math Subject: Re: Obscure spherical trig question (need help, please) Message-ID: <458@utastro.UUCP> Date: Sat, 9-Jul-83 13:30:45 EDT Article-I.D.: utastro.458 Posted: Sat Jul 9 13:30:45 1983 Date-Received: Mon, 11-Jul-83 00:04:30 EDT References: csu-cs.2311 Lines: 63 Here is the best way to solve a spherical triangle. Let the sides and angles be labelled as below: /\ / C\ / \ b / \ a / \ / \ / A B \ ---------------- c Capital letters are the angles and lower case letters the opposite sides. In your case, angle C is at the north pole, so that C = longitude difference between the two points. Sides a and b are the colatitudes of the two points of interest (colatitude = pi/2 - latitude). You want angle A (the bearing from A to B) and side c (the distance from A to B). The following three quantities can be calculated from the known quantities a, b and C: x = sin c cos A = cos a sin b - sin a cos b cos C y = sin c sin A = sin a sin C z = cos c = cos a cos b + cos b cos a cos C You should calculate all three quantities and then do the following: The ratio of the first two quantities is tan A; but don't use the ordinary arctangent function! Instead, use the relation angle A = atan2(y,x), which gives you the angle *resolved for quadrant*. By definition, sin c >= 0, because all sides of the spherical triangle are less than pi, so we don't have to know sin c at this point. Now compute w = sin c = sqrt (x*X + y*y); as remarked above, it is non-negative. Finally, compute side c = atan2 (w, z). For the reasons given below, you should *not* calculate c from the acos of z! This method has several advantages: 1) It automatically resolves the quadrant issue; 2) It is accurate even near A = pi/2 or c = 0; the other approach (using asin and acos) loses accuracy because the sin and cos have extrema near pi/2 and 0, respectively. 3) It works for southern latitudes as well. Keep point C at the north pole; the math will still work out. The same method is the method of choice on a pocket calculator, as well. Most of the scientific calculators have a vector-to-polar key that is the analog of the function atan2 (y, x). Bill Jefferys Astronomy Dept University of Texas Austin TX 78712 (...ucbvax!nbires!ut-ngp!utastro!bill) (...decvax!eagle!ut-ngp!utastro!bill) ( utastro!bill@utexas-11)