| Crates.io | geocentric |
| lib.rs | geocentric |
| version | 0.1.3 |
| created_at | 2025-03-08 07:37:15.33041+00 |
| updated_at | 2025-03-10 05:45:24.554297+00 |
| description | Conversion between geodetic and geocentric (cartesian) coordinates |
| homepage | |
| repository | https://github.com/ciscorn/geocentric-rs |
| max_upload_size | |
| id | 1584152 |
| size | 10,632 |
Conversion between geodetic (geographic) coordinates and geocentric (cartesian) coordinates in Rust.
Keywords: EPSG:4326, EPSG:4979, EPSG:4978
// WGS 84 Ellipsoid
let a = 6378137.; // Semi-major axis
let inv_f = 298.257223563; // Inverse flattening
let f = 1. / inv_f; // Flattening
let e_sq = f * (2. - f); // Eccentricity squared
// Convert from geodetic to geocentric
let (x, y, z) = geodetic_to_geocentric(a, e_sq, 140., 37., 50.);
// Convert from geocentric to geodetic
let (lng, lat, height) = geocentric_to_geodetic(a, e_sq, x, y, z);
The geocentric_to_geodetic function implements the algorithm described in:
MIT
Taku Fukada (@ciscorn)