Skip to main content

Position

Struct Position 

Source
pub struct Position {
    pub x: Real,
    pub y: Real,
    pub z: Real,
}
Expand description

A 3-dimensional position vector expressed in Cartesian coordinates (x, y, z) with units of meters (SI).

This type is designed for high-precision relativistic calculations in space navigation, deep-space tracking, and interplanetary timing. Positions are typically expressed in a heliocentric (Sun-centered) reference frame because the dominant gravitational light-time correction—the Shapiro delay—is calculated with respect to the Sun.

Fields§

§x: Real§y: Real§z: Real

Implementations§

Source§

impl Position

Source

pub const ZERO: Self

The zero vector, representing the origin of the coordinate system (commonly the center of the Sun).

Source

pub const fn new(x: Real, y: Real, z: Real) -> Self

Creates a new Position directly from its Cartesian components in meters.

Source

pub const fn from_au(x: Real, y: Real, z: Real) -> Self

Creates a Position from coordinates expressed in Astronomical Units (AU), converting them to meters using the IAU 2012 definition (1 AU = 149 597 870 700 m).

Especially convenient when working with planetary ephemerides or solar-system models that are natively given in AU.

Source

pub const fn norm(self) -> Real

Returns the Euclidean norm (straight-line distance) of this position from the origin.

When the position is Sun-centered, this is the radial distance from the Sun required for Shapiro-delay calculations.

Source

pub const fn distance_to(self, other: Self) -> Real

Computes the straight-line (Euclidean) distance between this position and another Position.

Together with the two radial distances from the Sun, this value supplies the three geometric inputs needed to evaluate the Shapiro delay.

Source

pub const fn lerp(self, other: Self, t: Real) -> Self

Returns a new position that lies a fraction t of the way along the straight line between self and other.

This is known as linear interpolation (lerp). It is most commonly used when you need to generate evenly spaced sample points along a path — for example, when building the samples slice for [ObserverState::one_way_relativistic_delay_integrated].

§Parameters
  • other – the ending position
  • t – interpolation parameter (0.0 = start point, 1.0 = end point). Values outside [0, 1] are allowed and will extrapolate.
§Examples
use deep_time::Position;

let a = Position::new(0.0, 0.0, 0.0);
let b = Position::new(10.0, 20.0, 30.0);

let midpoint = a.lerp(b, 0.5);           // (5.0, 10.0, 15.0)
let quarter   = a.lerp(b, 0.25);         // (2.5, 5.0, 7.5)
let beyond    = a.lerp(b, 1.5);          // (15.0, 30.0, 45.0)

Trait Implementations§

Source§

impl Clone for Position

Source§

fn clone(&self) -> Position

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 Debug for Position

Source§

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

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

impl<'de> Deserialize<'de> for Position

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 Position

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 Position

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 Tsify for Position

Source§

const DECL: &'static str = "/**\n * A 3-dimensional position vector expressed in Cartesian coordinates (x, y, z)\n * with units of meters (SI).\n *\n * This type is designed for high-precision relativistic calculations in space\n * navigation, deep-space tracking, and interplanetary timing. Positions are\n * typically expressed in a heliocentric (Sun-centered) reference frame because\n * the dominant gravitational light-time correction\u{2014}the Shapiro delay\u{2014}is\n * calculated with respect to the Sun.\n */\nexport interface Position {\n x: Real;\n y: Real;\n z: Real;\n}"

Source§

const SERIALIZATION_CONFIG: SerializationConfig

Source§

type JsType = JsType

Source§

fn into_js(&self) -> Result<Self::JsType, Error>
where Self: Serialize,

Source§

fn from_js<T>(js: T) -> Result<Self, Error>
where T: Into<JsValue>, Self: DeserializeOwned,

Source§

impl Copy for Position

Source§

impl StructuralPartialEq for Position

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<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
Source§

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