Skip to main content

Spherical

Struct Spherical 

Source
pub struct Spherical<U: AngleUnit>(/* private fields */);
Expand description

Spherical coordinates in unit U.

Mirrors boost::geometry::cs::spherical<DegreeOrRadian> (boost/geometry/core/cs.hpp:115-135).

§Convention: latitude measured from the equator

Boost has two spherical tags (boost/geometry/core/tags.hpp:38-41):

  • spherical_polar_tag — colatitude. The second coordinate is the angle from the pole, ranging [0, π].
  • spherical_equatorial_tag — latitude. The second coordinate is the angle from the equator, ranging [-π/2, π/2].

v1 collapses both into one Spherical<U> family and picks the equatorial convention because that is what the OGC standard and the Boost.Geometry quickstart use (doc/src/examples/quick_start.cpp Amsterdam → Paris example).

In coordinate order:

get::<0>(p)  →  longitude (azimuth, around the polar axis)
get::<1>(p)  →  latitude  (measured from the equator)

In a Spherical<Degree> point, longitude ranges -180.0..=180.0 (east of Greenwich is positive) and latitude ranges -90.0..=90.0 (north of the equator is positive). Amsterdam (≈ 4.90° E, 52.37° N) is (4.90, 52.37) — the “north of the equator” component is the second coordinate.

§If you have colatitude data

Convert to latitude first: latitude = 90° − colatitude (degrees) or π/2 − colatitude (radians). The dedicated SphericalPolar / SphericalEquatorial split is deferred to a future iteration.

§Examples

use geometry_cs::{CoordinateSystem, Degree, Spherical, SphericalFamily};
fn _spherical<C: CoordinateSystem<Family = SphericalFamily>>() {}
_spherical::<Spherical<Degree>>();

Trait Implementations§

Source§

impl<U: Clone + AngleUnit> Clone for Spherical<U>

Source§

fn clone(&self) -> Spherical<U>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<U: AngleUnit> CoordinateSystem for Spherical<U>

Source§

type Family = SphericalFamily

The CS family this concrete system belongs to. Read more
Source§

impl<U: Copy + AngleUnit> Copy for Spherical<U>

Source§

impl<U: Debug + AngleUnit> Debug for Spherical<U>

Source§

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

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

impl<U: Default + AngleUnit> Default for Spherical<U>

Source§

fn default() -> Spherical<U>

Returns the “default value” for a type. Read more
Source§

impl<U: Eq + AngleUnit> Eq for Spherical<U>

Source§

impl<U: PartialEq + AngleUnit> PartialEq for Spherical<U>

Source§

fn eq(&self, other: &Spherical<U>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<U: PartialEq + AngleUnit> StructuralPartialEq for Spherical<U>

Auto Trait Implementations§

§

impl<U> Freeze for Spherical<U>

§

impl<U> RefUnwindSafe for Spherical<U>
where U: RefUnwindSafe,

§

impl<U> Send for Spherical<U>
where U: Send,

§

impl<U> Sync for Spherical<U>
where U: Sync,

§

impl<U> Unpin for Spherical<U>
where U: Unpin,

§

impl<U> UnsafeUnpin for Spherical<U>

§

impl<U> UnwindSafe for Spherical<U>
where U: UnwindSafe,

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.