Skip to main content

Localized

Trait Localized 

Source
pub trait Localized<T = Timestamp>
where T: TimePoint,
{ // Required methods fn frame(&self) -> &str; fn timestamp(&self) -> T; }
Expand description

A trait for types that are localized in a specific coordinate frame at a specific time.

This trait provides frame and timestamp introspection, enabling automatic transform lookup via Registry::get_transform_for.

Separate from Transformable so that types without frame/timestamp metadata can still implement Transformable independently.

§Examples

use transforms::{
    geometry::{Point, Quaternion, Vector3},
    time::Timestamp,
    Localized,
};

let point = Point {
    position: Vector3::new(1.0, 0.0, 0.0),
    orientation: Quaternion::identity(),
    timestamp: Timestamp::zero(),
    frame: "camera".into(),
};

assert_eq!(point.frame(), "camera");

Required Methods§

Source

fn frame(&self) -> &str

Returns the object’s current frame identifier.

Source

fn timestamp(&self) -> T

Returns the object’s timestamp.

Implementors§

Source§

impl<T> Localized<T> for Point<T>
where T: TimePoint,

The Localized trait provides frame and timestamp introspection for a Point, enabling automatic transform lookup via Registry::get_transform_for.

§Examples

use core::time::Duration;
use transforms::{
    geometry::{Point, Quaternion, Transform, Vector3},
    time::Timestamp,
    Registry, Transformable,
};

let mut registry = Registry::new(Duration::from_secs(10));
let t = Timestamp::now();

registry.add_transform(Transform {
    translation: Vector3::new(1.0, 0.0, 0.0),
    rotation: Quaternion::identity(),
    timestamp: t,
    parent: "map".into(),
    child: "camera".into(),
});

let mut point = Point {
    position: Vector3::new(1.0, 0.0, 0.0),
    orientation: Quaternion::identity(),
    timestamp: t,
    frame: "camera".into(),
};

// Localized lets the registry extract frame and timestamp automatically
let tf = registry.get_transform_for(&point, "map").unwrap();
point.transform(&tf).unwrap();
assert_eq!(point.frame, "map");
assert_eq!(point.position.x, 2.0);