### Walking Around the World

Date: 02/08/97 at 18:02:14 From: Anonymous Subject: Calculating new position and heading after a walk around the world I've been trying to solve the following problem, but as I don't know any spherical geometry (or whatever it is that's needed). I haven't had much luck so far. Given someone's starting point on the earth (in degrees longitude and latitude), and the direction he is initially facing, if he travels in a straight line a certain distance, where will he end up (in degrees/ radians) and in what direction will he now be facing? I really want to get this down to a set of formulae which I can put the 4 given values into (longitude, latitude, direction, distance) and get out the 3 values I'm looking for (new longitude, new latitude, new direction).

Date: 02/13/97 at 12:59:12 From: Doctor Mitteldorf Subject: Re: Calculating new position and heading after a walk around the world Dear Kluj, I've been working periodically on your question about headings, latitude and longitude. I have an answer for you, and I'll describe briefly where it comes from. Let me know if you want more details, or if the derivation either too advanced or too elementary. First, definitions: Start at a point with given longitude, we'll call this long1, and given latitude, we'll call this lat1. Travel in a compass heading, we'll call this hdng1, and go a certain distance, we'll call this dist. The compass heading is measured from due north, which is equal to 0. Define alpha = dist/[earth radius] to be the angular distance covered on the earth's surface. You're looking for coordinates of the point that you reach, which we'll call lat2 and long2. You also want to know your new compass heading, which we'll call hdng2. The answer: First calculate the new latitude: 1) sin(lat2) = cos(hdng1)*cos(lat1)*sin(alpha) + sin(lat1)*cos(alpha) Then calculate the new longitude, using your result for lat2: cos(alpha) - sin(lat1)*sin(lat2) 2) cos(long2-long1) = ---------------------------------- cos(lat1)*cos(lat2) Again, using lat2 you can calculate the new compass heading: sin(lat1) - sin(lat2)*cos(alpha) 3) cos(hdng2) = ---------------------------------- cos(lat2)*sin(alpha) hdng2 is the compass setting from point 2 to point 1; it's just 180 degrees from the compass heading that one has when traveling from point 1 to point 2 and continuing on from there. The derivation: I'm a physicist, and I find it natural to think in terms of vectors. Going back and forth between expressing the vectors in spherical coordinates (r, theta, phi) and in cartesian coordinates (x,y,z) gives you a wealth of identities, which are sufficient to solve the kind of problem you've posed. The first useful result from this is that the scalar product (dot product) between two vectors can be expressed in two different ways: In cartesian coordinates, it's x1*x2 + y1*y2 + z1*z2. In polar coordinates, it's r1*r2*cos(alpha), where alpha is the angle between the two vectors. Now, on the surface of the earth, the angle alpha is just the distance between the points divided by the earth's radius. This gives you a very useful expression for the distance between any two points on the earth's surface. The quantities x1/r1, y1/r1 and z1/r1 are simply related to latitude and longitude of point 1. By definition: z1/r1 = sin(lat1) x1/r1 = cos(lat1)*sin(long1) y1/r1 = cos(lat1)*cos(long1) Identifying the cartesian and polar expressions for the dot product gives: cos(alpha)= sin(lat1)*sin(lat2) + cos(lat1)*cos(lat2)*cos(long1-long2) This is half of your problem right here: it's an expression for the distance between any two points on the globe in terms of their coordinates. The other expression you need involves compass headings. Given that you're at point 2 with coordinates as above, and you want to get to point 1, what direction should you travel? The answer is given in equation (3) at the top of my answer. The derivation for this also comes from vector manipulations in polar coordinates, but it's a little more involved than the one above. Let r2u be a unit vector from the center of the earth's surface to point 2. This unit vector is just a vector that's one unit long, but pointing in the same direction as the vector r2. Let zu be the unit vector in the z direction. Then you can construct a vector that points "due north" along the earth's surface from point 2 as: north pointing vector = zu - (zu.r2u)r2u The period in this expression connotes the scalar product of two vectors. Similarly, a vector pointing along the earth's surface from point 2 toward point 1 (on a great circle) can be written as: heading vector = r1u - (r1u.r2u)r2u The cosine of the heading angle is just the angle between these two vectors. You can get this by taking the scalar product of the two vectors and then dividing by the length of each vector separately. This is exactly what I did to derive equation (3). I'm hoping at least the formulas are useful to you, and if you want to go through the details of the derivation, please write back.Referencehttp://mathforum.org/library/drmath/view/52049.html

Advertisements