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).

Used with Velocity and gravitational potentials when building proper-time rates and trajectory samples. The caller chooses the reference frame (e.g. Earth-centered or barycentric); this type does not tag the frame.

Fields§

§x: Real

X-coordinate in meters (SI).

§y: Real

Y-coordinate in meters (SI).

§z: Real

Z-coordinate in meters (SI).

Implementations§

Source§

impl Position

Source

pub const ZERO: Self

The zero vector (origin of the chosen coordinate system).

Source

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

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

Source

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

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 (distance from the origin).

Source

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

Straight-line (Euclidean) distance to another position.

Source

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

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 useful when you need an intermediate position along a straight-line segment between two known points.

§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::physics::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)
Source§

impl Position

Source

pub const WIRE_SIZE: usize = 24

Size of the canonical wire representation in bytes (24 bytes).

Source

pub fn to_wire_bytes(&self) -> [u8; 24]

Serializes this [Position into a fixed 24-byte buffer.

All fields are stored as little-endian IEEE 754 f64.

Source

pub fn from_wire_bytes(bytes: &[u8]) -> Option<Self>

Deserializes a Position from exactly 24 bytes.

§Security

Accepts any f64 bit pattern (including NaN/Inf) to match the type’s own invariants. Fixed size makes it immune to length-based attacks. Safe for untrusted input.

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

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

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

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

Inequality operator !=. Read more
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 StructuralPartialEq for Position

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 * Used with [`Velocity`](crate::physics::Velocity) and gravitational potentials\n * when building proper-time rates and trajectory samples. The caller chooses\n * the reference frame (e.g. Earth-centered or barycentric); this type does not\n * tag the frame.\n */\nexport interface Position {\n /**\n * X-coordinate in meters (SI).\n */\n x: Real;\n /**\n * Y-coordinate in meters (SI).\n */\n y: Real;\n /**\n * Z-coordinate in meters (SI).\n */\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,

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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: Sized + 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: Sized + ErasableGeneric<Repr = Self::Repr>,

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