Bearing Formula
Reference for the bearing formula using atan2 to calculate true compass heading between two lat/lon points.
Covers true vs magnetic bearing.
The Formula
The bearing formula gives the initial compass direction from one point to another on Earth. Bearing is measured clockwise from north: 0° = North, 90° = East, 180° = South, 270° = West.
Variables
| Symbol | Meaning |
|---|---|
| θ | Bearing (degrees, 0-360) |
| φ₁, φ₂ | Latitude of start and end points (radians) |
| Δλ | Difference in longitude (radians) |
| atan2 | Two-argument arctangent function |
Example 1
Bearing from New York (40.71°N, 74.01°W) to London (51.51°N, 0.13°W)
Δλ = 73.88° east
Using the formula with radians:
Bearing ≈ 51.2° (roughly northeast)
Example 2
Bearing from Los Angeles (34.05°N, 118.24°W) to Tokyo (35.68°N, 139.65°E)
Δλ = 360 - (118.24 + 139.65) = 102.11° (going west across the Pacific)
Using the formula:
Bearing ≈ 305° (roughly northwest — across the Pacific)
When to Use It
Use the bearing formula when:
- Navigating between two geographic coordinates
- Building mapping and direction applications
- Planning sailing, flying, or hiking routes
- Determining which compass direction to travel
Key Notes
- This formula gives the initial bearing — along a great circle route the bearing changes continuously; for long journeys, recalculate bearing periodically or use rhumb-line navigation for a constant heading
- atan2 returns a value in radians between −π and π; convert to degrees and add 360° if the result is negative to get a standard 0°–360° compass bearing
- The formula assumes a spherical Earth; for survey-grade accuracy over long distances, use WGS-84 ellipsoidal formulas (Vincenty's or Karney's method)
- The result is a true bearing (relative to geographic north) — to use it with a magnetic compass, apply the local magnetic declination correction
Key Notes
- Initial bearing formula: θ = atan2(sin(Δλ)·cos(φ₂), cos(φ₁)·sin(φ₂) − sin(φ₁)·cos(φ₂)·cos(Δλ)) where φ is latitude and λ is longitude in radians. The result is in radians; convert to 0–360° bearing by normalizing.
- True bearing vs magnetic bearing: True bearing is measured clockwise from geographic (true) north. Magnetic bearing is from magnetic north. To convert: True = Magnetic + East declination (or − West declination). GPS gives true bearings; a compass gives magnetic.
- Back bearing: The reciprocal bearing from destination back to origin = bearing ± 180°. If bearing < 180°, add 180°; if ≥ 180°, subtract 180°. Used to verify navigation fixes and to retrace a path.
- Great-circle bearing changes continuously: Along a great-circle route (shortest path on a sphere), the bearing at the destination differs from the initial bearing — unlike a straight line on a Mercator map where bearing is constant (rhumb line). Long-distance flights use great circles but with waypoint bearing recalculation.
- Applications: Bearing calculations are used in aviation (flight plan waypoint headings), marine navigation (chart plotting), orienteering, artillery (azimuth from observer to target), and GPS/GIS applications (directional search, proximity alerts).