CHAPTER 14
Advanced topics — Vincenty, ECEF, and affine transforms
Sub-meter ellipsoidal accuracy with Vincenty, 3D Earth-Centered coordinates, pan/zoom transforms, and rhumb lines.
Haversine vs Vincenty — accuracy comparison
Point A
Point B
Haversine (sphere)
10840.289 km
fast, ~0.5% error
Vincenty (ellipsoid)
10826.694 km
accurate to mm
Difference
13594.8 m
0.126%
Vincenty's formulae (ellipsoidal accuracy)
Haversine assumes a sphere; Vincenty works on the WGS84 ellipsoid and is accurate to ~0.5 mm. It's iterative and slow, but used for surveying, aviation, and any time you need sub-meter accuracy over long distances.
The Earth is not a perfect sphere — it's an oblate spheroid, with a radius at the equator (~6,378 km) that is 21 km larger than at the poles (~6,357 km). This difference is small (~0.3%) but accumulates: over a 10,000 km flight, Haversine and Vincenty can disagree by up to ~70 m. For most web apps this is irrelevant. For geodetic survey or precision GPS work, it's not.
The forward and inverse Vincenty formulas are too long to reproduce here, but every major language has a library. Use it when accuracy matters more than speed.
ECEF coordinates
Earth-Centered, Earth-Fixed is a 3D Cartesian system with origin at Earth's center, X through (0, 0), Y through (0, 90° E), Z through the North Pole.
Where:
- is the height above the ellipsoid
- is the radius of curvature in the prime vertical
- is the squared eccentricity (≈ 0.00669437999 for WGS84)
- is the equatorial radius
ECEF is essential for GPS, sensor fusion, and 3D map engines (Cesium, Google Earth).
The radius of curvature is latitude-dependent — it varies from at the equator (6,378,137 m) to at the poles (~6,399,594 m). This is what distinguishes the ellipsoidal formulas from the spherical ones.
Affine transforms (2D map view)
When you pan and zoom a map, you're applying a 2D affine transform to world pixel coordinates:
For pure pan (no rotation, no scale change): , , = offset. For zoom: , plus translation to keep the zoom anchor stationary.
If your map rotates by angle α: , , , .
Continue reading "Advanced topics — Vincenty, ECEF, and affine transforms"
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 — Vincenty is the ellipsoidal upgrade
- ECEF and 3D coordinate systems — ECEF math in depth
- Coordinate transforms — converting between CRS — affine transforms in practice