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
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
Frequently Asked Questions
What is a compass bearing?
A bearing is an angle measured clockwise from true north. 0° is due north, 90° is due east, 180° is due south, 270° is due west.
What is the difference between true and magnetic north?
True north points to the geographic North Pole. Magnetic north is where a compass needle points and varies by location (magnetic declination). The difference can be significant for precise navigation.
Ready to run the numbers?
Open Compass Bearing Converter