# How do you find the difference in degrees between two headings?

This may be more of a math question, but it is specific to aviation so here goes:

Given an origin heading and a destination heading (origin heading is the heading you're already flying at and destination heading is the heading that you want to turn to), what are the formulas for degrees of separation between those two headings for a left or a right turn?

So if you are heading 190 and you want to go to 020:

The left turn formula should output 170 degrees.

The right turn formula should output 190 degrees.

Figured it out.

LH turn: [origin hdg] - [destination hdg] (if less than 0, add 360)

RH turn: [destination hdg] - [origin hdg] (if less than 0, add 360)

Edit: for the acute angle between two headings you would just take the lower number between these two values. There is no different formula. This is alluded to in this SO post.

By the way, this is not really useful for normal pilots because you can just visualize a compass rose and figure out the different angles pretty easily but I am making a program that will make flying holding patterns a lot easier. You input the inbound leg course (not radial), the wind (direction, velocity), your true airspeed, and whether you are making a left or right hand turn. The program calculates what heading you should turn to on the outbound leg and the heading you should then turn to on the inbound leg (assuming standard rate turn). It also gives you the time to fly on the outbound leg after you reach your heading for that leg. It even takes into account turning from/to different crab angles (which would make the turns more or less than 180 degrees).

• How many degrees is it when the controller tells you to turn a specific direction (left/right)? For example when heading 180°, the controller instructs "turn left heading 270°"? Jan 15, 2018 at 13:25
• @RonBeyer By the way, the controller will usually add extra words to that instruction to alleviate confusion, "turn left heading 270 long way around." Jan 15, 2018 at 16:18
• For a left hand turn it would be (180 - 270) and since that is -90, you add 360 so it's a 270 degree turn. So at standard rate it would take 90 seconds. Jan 15, 2018 at 19:14
• BTW, when you have got the angular distance in one direction, the angle in the other direction is just 360° - angle.
– mins
Jan 15, 2018 at 23:50

## Right-hand Turn -

### If (Dest) > (Orig)

(Dest) - (Orig) = Turn Degrees

### If (Dest) <= (Orig)

(Dest) - (Orig) + 360 = Turn Degrees

## Left-hand Turn -

### If (Orig) > (Dest)

(Orig) - (Dest) = Turn Degrees

### If (Orig) <= (Dest)

(Orig) - (Dest) + 360 = Turn Degrees

I'm interested in your final product for the holding pattern. Please do share!

In programmer logic, you'd use the Modulo operator (% in most languages)

Left-Hand Turn:   ((Origin - Destination) + 360) % 360
Right-Hand Turn: ((Destination - Origin) + 360) % 360

Example:

((190 - 20) + 360) % 360 == 170 degree turn to the left.
((20 - 190) + 360) % 360 == 190 degree turn to the right

• Ha - how to confuse a non-programmer. Tell them % means something other than "per hundred"
– Jamiec
Sep 3, 2020 at 14:47
• And in PowerShell, it means "for-each", in Matlab it is a comment, In Perl it is a hash.... Sep 3, 2020 at 14:53