CHAPTER 09
Destination points — moving on a sphere
Given a starting point, bearing, and distance, compute the destination on a sphere — used for geofences, range rings, and dead reckoning.
The inverse of distance/bearing: given a starting point, a bearing, and a distance, find the destination on the sphere. This operation is called dead reckoning in navigation — it's how ships historically computed position before GPS. In modern apps it's used for geofence construction, range rings, path simulation, and anywhere you need to place a point at a known offset from another.
Try it live before diving into the derivation.
Destination point calculator
The formula
Angular distance converts a linear distance (metres) into the angle it subtends at Earth's centre. A 1 km arc on a sphere of radius 6,371 km subtends radians. Working in angular distance keeps the sphere math dimensionally consistent — all the trig functions expect angles, not metres.
Let be the angular distance in radians. This normalises the linear distance by Earth's radius to get the central angle subtended by the arc.
The first equation derives the new latitude by rotating the starting point through angle δ in the direction θ. The second computes the longitude offset using arctan2 to handle the full 360° range correctly.
function destination(lat1, lon1, bearingDeg, distanceMeters) {
const R = 6371008.8;
const δ = distanceMeters / R;
const θ = bearingDeg * Math.PI / 180;
const φ1 = lat1 * Math.PI / 180;
const λ1 = lon1 * Math.PI / 180;
const φ2 = Math.asin(
Math.sin(φ1) * Math.cos(δ) +
Math.cos(φ1) * Math.sin(δ) * Math.cos(θ)
);
const λ2 = λ1 + Math.atan2(
Math.sin(θ) * Math.sin(δ) * Math.cos(φ1),
Math.cos(δ) - Math.sin(φ1) * Math.sin(φ2)
);
return {
lat: φ2 * 180 / Math.PI,
lon: ((λ2 * 180 / Math.PI) + 540) % 360 - 180 // normalize to [-180, 180]
};
}
Continue reading "Destination points — moving on a sphere"
You've reached the end of the free preview. Unlock all 22 paid chapters, including distance math, bearings, polygons, spatial indexing, and 3D map rendering — plus a downloadable PDF and the companion code repo.
- All 22 paid chapters with worked examples
- Downloadable PDF for offline reading
- Companion GitHub repo (JavaScript + Python)
- Free updates for life
Multiple payment options including Wise, PayPal, and bank transfer.
Related chapters
- Distance on a sphere — Haversine and friends — the inverse problem (two points → distance)
- Bearings, headings, and azimuths — where the angle in the formula comes from
- Buffering and spatial operations — destination points form a buffer ring