pub struct GeocentricUnit { /* private fields */ }Expand description
Unit vector from the Earth’s centre.
x towards 0°N 0°E, y towards 0°N 90°E, z towards the north pole. Direction only, no radius.
Components are private, finite and of unit length. As a bare [f64; 3] a
caller could pass the zero vector, a vector in other axes, or metres, and
the signature would not prevent it.
§Example
use kinavis_kernel::{GeocentricUnit, Latitude, Longitude, Position};
let greenwich = Position::new(Latitude::from_degrees(0.0)?, Longitude::from_degrees(0.0)?);
let unit = greenwich.to_geocentric_unit();
assert!((unit.x() - 1.0).abs() < 1e-12);
// Round trips, and the length is normalised on the way in.
let doubled = GeocentricUnit::new(2.0, 0.0, 0.0)?;
assert_eq!(Position::from_geocentric_unit(doubled), greenwich);
// The zero vector points nowhere and is refused.
assert!(GeocentricUnit::new(0.0, 0.0, 0.0).is_err());Implementations§
Source§impl GeocentricUnit
impl GeocentricUnit
Sourcepub fn new(x: f64, y: f64, z: f64) -> Result<Self>
pub fn new(x: f64, y: f64, z: f64) -> Result<Self>
Normalises an Earth-centred vector; any positive multiple gives the same direction.
§Errors
KernelError::NotFinitefor aNaNor infinite component.KernelError::Indeterminatefor the zero vector or one too small to normalise meaningfully.
Sourcepub const fn components(self) -> [f64; 3]
pub const fn components(self) -> [f64; 3]
Components [x, y, z].
Trait Implementations§
Source§impl Clone for GeocentricUnit
impl Clone for GeocentricUnit
impl Copy for GeocentricUnit
Source§impl Debug for GeocentricUnit
impl Debug for GeocentricUnit
Source§impl PartialEq for GeocentricUnit
impl PartialEq for GeocentricUnit
impl StructuralPartialEq for GeocentricUnit
Auto Trait Implementations§
impl Freeze for GeocentricUnit
impl RefUnwindSafe for GeocentricUnit
impl Send for GeocentricUnit
impl Sync for GeocentricUnit
impl Unpin for GeocentricUnit
impl UnsafeUnpin for GeocentricUnit
impl UnwindSafe for GeocentricUnit
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more