Compass Bearing Converter Formula
Understand the math behind the compass bearing converter. Each variable explained with a worked example.
Formulas Used
Cardinal Direction
main_direction = value < 22.5 ? 1 : (value < 67.5 ? 2 : (value < 112.5 ? 3 : (value < 157.5 ? 4 : (value < 202.5 ? 5 : (value < 247.5 ? 6 : (value < 292.5 ? 7 : (value < 337.5 ? 8 : 1)))))))Radians
radians = value * pi / 180NATO Mils
mil_nato = value * 17.7778Variables
| Variable | Description | Default |
|---|---|---|
value | Bearing (degrees from North)(°) | 135 |
How It Works
Compass Bearings
Cardinal Directions and Degrees
| Bearing | Direction | |---|---| | 0° (360°) | North (N) | | 45° | Northeast (NE) | | 90° | East (E) | | 135° | Southeast (SE) | | 180° | South (S) | | 225° | Southwest (SW) | | 270° | West (W) | | 315° | Northwest (NW) |
Bearings are measured clockwise from true North. Output values: 1=N, 2=NE, 3=E, 4=SE, 5=S, 6=SW, 7=W, 8=NW.
Worked Example
Convert 135° bearing.
value = 135
- 01135° falls between 112.5° and 157.5°
- 02Direction: Southeast (SE)
- 03NATO mils = 135 x 17.78 = 2,400 mils
Ready to run the numbers?
Open Compass Bearing Converter