Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Title says it all, I'm looking for the formula to get the bearing from one point to another on a number plane. I have found examples of this for lat/lon around the earth but that's not exactly what i need. Thanks

share|cite|improve this question

Exactly what is a "bearing" to you? Compass bearings are typically quoted with 0° meaning due north and increasing in the clockwise direction, whereas in mathematics in general the convention is to consider 0° to be due right, and increasing counterclockwise.

For a compass bearing, the conventional answer is $\tan^{-1}\left(\frac{E_2-E_1}{N_2-N_2}\right)$, where $(E_1,N_1)$ and $(E_2,N_2)$ are the (easting,northing) coordinates of your two points. There are various points to keep in mind, though:

  1. Your arctangent function probably gives values in radians, which you'll have to convert to degrees yourself.

  2. If the northings are equal, you'll end up dividing by zero. This needs to be handled as a special case, answering 90° or 270° as appropriate.

  3. The formula also cannot distinguish between a direction and its direct opposite, so you need to add 180° if $N_2<N_1$.

  4. Directions in the northwest quadrants will end up as negative numbers between $-$90° and 0°; you'll want to add 360° to those to make them look like ordinary compass bearings.

If you're looking to create a computer implementation, see if your programming language has an atan2 function -- it will take care of points 2 and 3 for you automatically. Typically it should be called as atan2(e2-e1,n2-n1), but I've heard rumors of languages that need you to give the arguments in the opposite order.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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