Skip to main content

Drift

Struct Drift 

Source
pub struct Drift {
    pub constant: Dt,
    pub rate: Dt,
    pub accel: Dt,
}
Expand description

Quadratic polynomial for the accumulated difference between an observer’s proper time (what a real clock measures) and a chosen coordinate time such as TT, TAI, or any other Scale.

The form is (\mathrm{offset} = a_0 + a_1 s + a_2 s^2), where (s) is elapsed coordinate time. The three coefficients are a fixed offset, a constant fractional rate, and a quadratic term (aging, or a changing rate). GNSS and spacecraft clock steering use this polynomial.

All three coefficients are stored as Dt. The rate coefficient is dimensionless (seconds per second); the acceleration coefficient is seconds per second squared. from_spacetime fills only the linear term from the general-relativity interval.

Fields§

§constant: Dt

Constant term (a_0), a fixed time offset between proper time and the chosen coordinate time.

§rate: Dt

Linear coefficient (a_1), a fractional rate in seconds per second (for example a clock that runs steadily fast or slow).

§accel: Dt

Quadratic coefficient (a_2), in seconds per second squared (aging, or a rate that itself changes). from_spacetime leaves this at zero.

Implementations§

Source§

impl Drift

Source

pub const ZERO: Self

Polynomial with all coefficients zero, meaning no correction at all.

Use this when the observer’s clock is already synchronized with the chosen coordinate time.

Source

pub const fn new(constant: Dt, rate: Dt, accel: Dt) -> Drift

Creates a Drift polynomial from its three coefficients.

constant is a time offset, rate is dimensionless (seconds per second), and accel is seconds per second squared. All three are stored as Dt.

Source

pub const fn from_constant(c: Dt) -> Drift

Creates a Drift consisting of a pure constant offset.

This is the usual constructor when only a fixed time bias is known (for example after a one-time clock synchronization).

Source

pub const fn from_offset_and_rate(offset: Dt, rate: Dt) -> Drift

Creates a Drift consisting of a constant offset together with a constant linear drift rate.

This form is very common for GNSS receivers and spacecraft clock steering, where a steady fractional frequency offset must be corrected in addition to any fixed bias.

Source

pub const fn proper_time_rate(&self) -> Real

Instantaneous rate (d\tau/dt) implied by this polynomial’s linear term (1 + rate, dimensionless).

When this Drift was built with from_spacetime, that term is the general-relativity interval. Otherwise it is the rate you stored (steering, a measured frequency offset, aging). 1.0 means the linear term ticks in step with the coordinate time the polynomial is written against. The constant and quadratic coefficients do not enter this value.

Source

pub const fn time_diff_after(&self, span: &Dt) -> Dt

Evaluates the polynomial after span of coordinate time.

The result is (a_0 + a_1 s + a_2 s^2) as a Dt. When this polynomial was built with from_spacetime, that value is (\Delta\tau - \Delta t). Otherwise it is whatever offset, rate, and aging you stored (steering, a measured frequency offset, and so on).

Arithmetic saturates like Dt add and mul. Scaled products ((a\cdot b)/10^{18}) avoid wrapping or early-clamping the intermediate (a\cdot b) when it exceeds i128 but the result still fits.

Source

pub fn time_diff_after_with_noise( &self, span: &Dt, stochastic_offset_sec: Real, ) -> Dt

Adds stochastic_offset_sec to the result of time_diff_after.

The polynomial is left as you stored it. Pass noise at evaluation time (measured residuals, a Monte-Carlo draw, and so on). Pass 0.0 to get the same result as time_diff_after.

Source

pub const fn from_spacetime(spacetime: &Spacetime) -> Drift

Builds a linear Drift from a Spacetime snapshot.

The linear coefficient is the general-relativity tick-rate offset Spacetime::proper_time_rate_offset ((d\tau/dt-1)). The constant and quadratic terms are zero. Build the Spacetime from whichever potential, velocity, or metric lapse you have, then call this.

Source§

impl Drift

Source

pub const WIRE_VERSION: u8 = 1

Wire format version for this type’s outer envelope.

Independent of nested Dt::WIRE_VERSION.

Source

pub const WIRE_SIZE: usize

Size of the canonical wire representation in bytes.

One version byte plus three Dt::WIRE_SIZE records (constant, rate, accel).

Source

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

Serializes this polynomial into a fixed buffer.

§Wire format
Source

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

Deserializes from exactly WIRE_SIZE bytes.

§Errors

Returns None only when:

Nested scale/target bytes never fail decode (see Dt::from_wire_bytes).

§Security

Composes the safety guarantees of Dt::from_wire_bytes. Safe for untrusted input.

Trait Implementations§

Source§

impl Clone for Drift

Source§

fn clone(&self) -> Drift

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 Drift

Source§

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

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

impl<'de> Deserialize<'de> for Drift

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 Eq for Drift

Source§

impl Hash for Drift

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Drift

Source§

fn cmp(&self, other: &Drift) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Drift

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl PartialOrd for Drift

Source§

fn partial_cmp(&self, other: &Drift) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for Drift

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 Drift

Source§

impl Tsify for Drift

Source§

const DECL: &'static str = "/**\n * Quadratic polynomial for the accumulated difference between an observer\u{2019}s\n * proper time (what a real clock measures) and a chosen coordinate time such\n * as TT, TAI, or any other [`Scale`].\n *\n * The form is \\(\\mathrm{offset} = a_0 + a_1 s + a_2 s^2\\), where \\(s\\) is\n * elapsed coordinate time. The three coefficients are a fixed offset, a\n * constant fractional rate, and a quadratic term (aging, or a changing rate).\n * GNSS and spacecraft clock steering use this polynomial.\n *\n * All three coefficients are stored as [`Dt`]. The rate coefficient is\n * dimensionless (seconds per second); the acceleration coefficient is seconds\n * per second squared. [`from_spacetime`](Self::from_spacetime) fills only the\n * linear term from the general-relativity interval.\n */\nexport interface Drift {\n /**\n * Constant term \\(a_0\\), a fixed time offset between proper time and the\n * chosen coordinate time.\n */\n constant: Dt;\n /**\n * Linear coefficient \\(a_1\\), a fractional rate in seconds per second\n * (for example a clock that runs steadily fast or slow).\n */\n rate: Dt;\n /**\n * Quadratic coefficient \\(a_2\\), in seconds per second squared (aging, or\n * a rate that itself changes). [`from_spacetime`](Self::from_spacetime)\n * leaves this at zero.\n */\n accel: Dt;\n}"

Source§

const SERIALIZATION_CONFIG: SerializationConfig

Source§

type JsType = JsType

Must be a type imported through #[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.
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§

fn into_ts(&self) -> Result<Ts<Self>, Error>
where Self: Sized + Serialize,

Calls Ts::from_rust on self, returning a Result<Ts<Self>, crate::Error>. Read more

Auto Trait Implementations§

§

impl Freeze for Drift

§

impl RefUnwindSafe for Drift

§

impl Send for Drift

§

impl Sync for Drift

§

impl Unpin for Drift

§

impl UnsafeUnpin for Drift

§

impl UnwindSafe for Drift

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<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

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

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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 = !

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