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: RealX-coordinate in meters (SI).
y: RealY-coordinate in meters (SI).
z: RealZ-coordinate in meters (SI).
Implementations§
Source§impl Position
impl Position
Sourcepub const fn new(x: Real, y: Real, z: Real) -> Position
pub const fn new(x: Real, y: Real, z: Real) -> Position
Creates a new Position directly from its Cartesian components in meters.
Sourcepub const fn from_au(x: Real, y: Real, z: Real) -> Position
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.
Sourcepub const fn distance_to(&self, other: &Self) -> Real
pub const fn distance_to(&self, other: &Self) -> Real
Straight-line (Euclidean) distance to another position.
Sourcepub const fn lerp(&self, other: &Self, t: Real) -> Position
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 positiont– 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)