While searching the web, I've encountered the following formulas for calculating the destination point P2's location given the source point P1 = (lat1,long1), the distance from it & the bearing:

lat2 = math.asin( math.sin(lat1)*math.cos(d/R) +

lon2 = lon1 + math.atan2(math.sin(brng)*math.sin(d/R)*math.cos(lat1),

Where P2=(lat2,lon2).

I was trying to develop the math behind it but could not really get it right

Can someone please show me how to develop the lat2 & lon2 mathematically?

  • 1
    So you want to know the theory behind the equations? Perhaps see Rapp's Geometric Geodesy Part I and Part II. If that's what you are looking for, let me know so I can turn this into an answer.
    – mkennedy
    Feb 19, 2019 at 23:31
  • Thank you very much mkennedy, for the links, but Gabriel De Luca's answer solved my problem.
    – Jo muller
    Feb 22, 2019 at 6:48

1 Answer 1


What follows is a development of the formulas found in the Aviation Formulary by Ed Williams and in Movable Type Scripts by Chris Veness, from the formulas of spherical trigonometry, to solve the direct problem of geodesy (obtain the coordinates of the destination point, knowing the azimuth of origin and the distance traveled over a great circle) on a spherical surface:

This is not a map of the Earth. This is a map of a spheric world, whose Radius = 1 (dimensionless).


In this map, a spheric triangle was drawn.
The vertices of the triangle are:

N North pole.
1 Start point of a travel.
2 End point of a travel.

The travel was started with initial azimuth alpha_1, and traveled a distance s.

The distance, on the unit sphere, is equivalent to the angle covered by the arc traveled, in radians.
If you want to perform your calculations over a sphere of radius R, and travel a distance d, you need to transform:
s = d / R.

lambdaare longitudes, in radians.
phi are latitudes, in radians.

One side of the triangle measures s, and the other two measure the respective collatitudes of the vertices (PI() / 2 - phi).

lambda_1, phi_1, alpha_1 and s are given.

  • First, calculate phi_2.

From the Spherical Law of Cosines, we know that:

COS(PI()/2-phi_2 ) = COS(PI()/2-phi_1) * COS(s) + SIN(PI()/2-phi_1) * SIN(s) * COS(alpha_1)

But, whether we remember the trigonometric identity for the cosine of a subtraction, or remember that the sine is the same function as the cosine, out of phase PI()/2:

COS(PI()/2-phi_2) = SIN(phi_2) and COS(PI()/2-phi_1) = SIN(phi_1)


SIN(phi_2) = SIN(phi_1) * COS(s) + COS(phi_1) * SIN(s) * COS(alpha_1)

  • Then, calculate lambda_2

The angle at N is lambda_2 - lambda_1, delta_lambda from now.

Write the cosine law for the s side of the triangle.

COS(s) = COS(PI()/2-phi_1) * COS(PI()/2-phi_2) + SIN(PI()/2-phi_1) * SIN(PI()/2-phi_2) * COS(delta_lambda)

Or better:

COS(s) = SIN(phi_1) * SIN(phi_2) + COS(phi_1) * COS(phi_2) * COS(delta_lambda)


COS(delta_lambda) = (COS(s) - SIN(phi_1) * SIN(phi_2)) / (COS(phi_1) * COS(phi2))

Now, write the Spherical Law of Sines that describes the relationship between delta_lambda and s, in terms of the relation between alpha _1 and PI()/2-phi_2:

SIN(delta_lambda) / SIN(s) = SIN(alpha_1) / SIN(PI()/2-phi_2)


SIN(delta_lambda) = SIN(alpha) * SIN(s) / COS(phi_2)

Now, the tangent of delta_lambda:

TAN(delta_lambda) = SIN(delta_lambda) / COS(delta_lambda)

Simplifying on-the-fly:

TAN(delta_lambda) = SIN(alpha_1) * SIN(s) * COS(phi_1) / (COS(s) - SIN(phi_1) * SIN(phi_2))

Finally, write lambda_2 in terms of delta_lambda and lambda_1:

lambda_2 = lambda_1 + delta_lambda


lambda_2 = lambda_1 + ATAN(SIN(alpha_1) * SIN(s) * COS(phi_1) / (COS(s) - SIN(phi_1) * SIN(phi_2)))

Note the ambiguity that the arctangent function returns the same result for opposing arguments, so it must be decided whether to add (or subtract) PI() to its result, based on the quadrant in which the argument is. This ambiguity is solved by the ATAN2 function.

  • Got it, thank you very much Gabriel De Luca for the very elaborated explanation. there is one tiny mistake to fix in your explanation: The last term in the phi_2 calculation should be: SIN(phi_2) = SIN(phi_1) * COS(s) + COS(phi_1) * SIN(s) * COS(alpha_1). again thanks a lot.
    – Jo muller
    Feb 22, 2019 at 6:41
  • Edited. You are welcome! Feb 22, 2019 at 14:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.