views:

142

answers:

3

This is similar to this question, but kind of the opposite.

I have two geographic points (latitude, longitude) A and B. Let's say they're 40 nautical miles apart. I'd like to calculate the coordinates of the point 10 nautical miles from point A, on the line between A and B. I'm sure this is very basic math, but it's been YEARS since I've had to do this kind of math (some other kinds I use daily), so I'm stuck. Any pointers would be greatly appreciated. My code for this project is in Python, but math isn't language-specific, so I'm not really concerned about that -- I just want to know the formula.

A: 

So, it's something like:

 x B (x2,y2)
  \
   \
    \
     \
      x C (x3, y3)
       \
        \
         \
          X A (x1,y1)

The way I'd do this is first find the angle of that line:

angle_A_B = arctan((y2-y1)-(x2-x1))

then given the distance between A and C is known (lets call it distance_A_C):

sin(angle_A_B) = delta_x_A_C / distance_A_C
delta_x_A_C = distance_A_C * sin(angle_A_B)

therefore:

x3 = x1+delta_x_A_C

same for the value of y3:

delta_y_A_C = distance_A_C * cos(angle_A_B)

therefore:

y3 = y1+delta_y_A_C

I may have gotten the signs mixed so if it doesn't work change the + to -.

slebetman
This doesn't work on a sphere, which is the question here. It's finding the "straight line", not the great-circle line.
ShreevatsaR
Ah, OK. Didn't realise it is literally for the Earth's surface.
slebetman
+4  A: 

You have two position vectors with (latitude, longitude). From those you can calculate your bearing from point A to point B (if you don't already know it). With a bearing and a distance you can calculate your new latitude and longitude.

All the math you need to know is referenced here: http://www.movable-type.co.uk/scripts/latlong.html. I deal with this stuff so infrequently it's nice to have that link saved somewhere (read: printed).

Anthony
This is a fantastic resource. Exactly what I needed. Thank you!!!
RustyAtMath
A: 

I believe the Haversine Formula could be applied here. If it would help I've implemented it in C#, Java and Javascript?

Matthew Sposato