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: DtConstant term (a_0), a fixed time offset between proper time and the chosen coordinate time.
rate: DtLinear coefficient (a_1), a fractional rate in seconds per second (for example a clock that runs steadily fast or slow).
accel: DtQuadratic 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
impl Drift
Sourcepub const ZERO: Self
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.
Sourcepub const fn new(constant: Dt, rate: Dt, accel: Dt) -> Drift
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.
Sourcepub const fn from_constant(c: Dt) -> Drift
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).
Sourcepub const fn from_offset_and_rate(offset: Dt, rate: Dt) -> Drift
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.
Sourcepub const fn proper_time_rate(&self) -> Real
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.
Sourcepub const fn time_diff_after(&self, span: &Dt) -> Dt
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.
Sourcepub fn time_diff_after_with_noise(
&self,
span: &Dt,
stochastic_offset_sec: Real,
) -> Dt
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.
Sourcepub const fn from_spacetime(spacetime: &Spacetime) -> Drift
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
impl Drift
Sourcepub const WIRE_VERSION: u8 = 1
pub const WIRE_VERSION: u8 = 1
Wire format version for this type’s outer envelope.
Independent of nested
Dt::WIRE_VERSION.
Sourcepub const WIRE_SIZE: usize
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).
Sourcepub fn to_wire_bytes(&self) -> [u8; 58]
pub fn to_wire_bytes(&self) -> [u8; 58]
Serializes this polynomial into a fixed buffer.
§Wire format
- Byte
0:WIRE_VERSION - Next
Dt::WIRE_SIZEbytes:constant - Next
Dt::WIRE_SIZEbytes:rate - Next
Dt::WIRE_SIZEbytes:accel
Sourcepub fn from_wire_bytes(bytes: &[u8]) -> Option<Self>
pub fn from_wire_bytes(bytes: &[u8]) -> Option<Self>
Deserializes from exactly WIRE_SIZE bytes.
§Errors
Returns None only when:
bytesis not exactlyWIRE_SIZElong,- the version byte is not
WIRE_VERSION, or - any nested
Dt::from_wire_bytesfails (unknownDt::WIRE_VERSION).
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<'de> Deserialize<'de> for Drift
impl<'de> Deserialize<'de> for Drift
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 Eq for Drift
Source§impl Ord for Drift
impl Ord for Drift
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Drift
impl PartialOrd for Drift
impl StructuralPartialEq for Drift
Source§impl Tsify for Drift
impl Tsify for Drift
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}"
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.fn into_js(&self) -> Result<Self::JsType, Error>where
Self: Serialize,
fn from_js<T>(js: T) -> Result<Self, Error>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.