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. 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)Trait Implementations§
impl Copy for Position
Source§impl<'de> Deserialize<'de> for Position
impl<'de> Deserialize<'de> for Position
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl StructuralPartialEq for Position
Source§impl Tsify for Position
impl Tsify for Position
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. 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}"
const SERIALIZATION_CONFIG: SerializationConfig
Source§type JsType = JsType
type JsType = JsType
#[wasm_bindgen] extern "C" { .. }.
Ts<T> is #[repr(transparent)] over this and passes it across the
ABI as a plain JS handle, which any other representation would break.