Skip to main content

Ellipsoid

Struct Ellipsoid 

Source
pub struct Ellipsoid {
    pub a: f64,
    pub f: f64,
    pub b: f64,
    pub e2: f64,
}
Expand description

A reference ellipsoid defined by its semi-major axis and flattening.

All four fields are stored for fast access, but only two are independent (a and f). The derived fields b and e2 are computed at construction time (in const context) to avoid repeated work in hot paths.

§Field summary

FieldFormulaDescription
a(input)Semi-major axis (equatorial radius), meters
f1 / inv_fFlattening
ba * (1 - f)Semi-minor axis (polar radius), meters
e22f - f^2First eccentricity squared

Fields§

§a: f64

Semi-major axis (equatorial radius) in meters.

§f: f64

Flattening: f = (a - b) / a.

§b: f64

Semi-minor axis (polar radius) in meters: b = a * (1 - f).

§e2: f64

First eccentricity squared: e2 = 2f - f^2.

Implementations§

Source§

impl Ellipsoid

Source

pub const WGS84: Self

WGS-84 ellipsoid (EPSG:4326, NIMA TR8350.2).

The World Geodetic System 1984 is the reference frame used by GPS and the default for all rustial coordinate operations.

  • a = 6 378 137.0 m
  • 1/f = 298.257 223 563
Source

pub const GRS80: Self

GRS-80 ellipsoid (EPSG:7019, IUGG 1980).

The Geodetic Reference System 1980 is used by NAD83 (North America) and ETRS89 (Europe). It is nearly identical to WGS-84 (difference in 1/f is ~0.0001) but is a distinct definition.

  • a = 6 378 137.0 m
  • 1/f = 298.257 222 101
Source

pub const fn from_a_inv_f(a: f64, inv_f: f64) -> Self

Construct an ellipsoid from semi-major axis a (meters) and inverse flattening inv_f (dimensionless).

Inverse flattening is the standard geodetic convention because f itself is a very small number (~0.003 for Earth) and 1/f (~298.257) is easier to read and compare across standards.

§Derived quantities
f  = 1 / inv_f
b  = a * (1 - f)
e2 = 2f - f^2
Source

pub fn second_eccentricity_squared(&self) -> f64

Second eccentricity squared: e'2 = (a^2 - b^2) / b^2.

Used in Vincenty geodesic formulae and some map projections.

Source

pub fn radius_of_curvature_n(&self, lat_rad: f64) -> f64

Radius of curvature in the prime vertical (N) at geodetic latitude lat_rad (radians).

N = a / sqrt(1 - e2 * sin^2(lat))

This is the distance from the surface to the polar axis along the ellipsoid normal. Used in geographic-to-ECEF conversion and UTM projection.

Source

pub fn is_sphere(&self) -> bool

Whether this ellipsoid is effectively a sphere (f == 0).

Can be used to select simplified (spherical) code paths where the ellipsoidal correction is negligible.

Trait Implementations§

Source§

impl Clone for Ellipsoid

Source§

fn clone(&self) -> Ellipsoid

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Ellipsoid

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Ellipsoid

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Ellipsoid

Source§

fn eq(&self, other: &Ellipsoid) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Ellipsoid

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Copy for Ellipsoid

Source§

impl StructuralPartialEq for Ellipsoid

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,