#[cfg(not(feature = "std"))]
fn main() {
use core::time::Duration;
use log::info;
use transforms::{
geometry::{Quaternion, Transform, Vector3},
time::Timestamp,
Registry,
};
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("DEBUG")).init();
let mut registry = Registry::new();
let t1 = Timestamp::zero();
let t2 = (t1 + Duration::from_secs(1)).unwrap();
registry.add_transform(Transform {
translation: Vector3 {
x: 1.,
y: 0.,
z: 0.,
},
rotation: Quaternion {
w: 1.,
x: 0.,
y: 0.,
z: 0.,
},
timestamp: t1,
parent: "map".into(),
child: "conveyor".into(),
});
registry.add_transform(Transform {
translation: Vector3 {
x: 3.,
y: 0.,
z: 0.,
},
rotation: Quaternion {
w: 1.,
x: 0.,
y: 0.,
z: 0.,
},
timestamp: t2,
parent: "map".into(),
child: "conveyor".into(),
});
for &t in &[t1, t2] {
registry.add_transform(Transform {
translation: Vector3 {
x: 0.,
y: 0.5,
z: 0.,
},
rotation: Quaternion {
w: 1.,
x: 0.,
y: 0.,
z: 0.,
},
timestamp: t,
parent: "conveyor".into(),
child: "object".into(),
});
}
for &t in &[t1, t2] {
registry.add_transform(Transform {
translation: Vector3 {
x: 0.,
y: 2.,
z: 0.,
},
rotation: Quaternion {
w: 1.,
x: 0.,
y: 0.,
z: 0.,
},
timestamp: t,
parent: "map".into(),
child: "camera".into(),
});
}
let object_in_map_t1 = registry
.get_transform("map", "object", t1)
.expect("lookup at t1 failed");
info!("Object in map at t1: {:?}", object_in_map_t1.translation);
let object_in_map_t2 = registry
.get_transform("map", "object", t2)
.expect("lookup at t2 failed");
info!("Object in map at t2: {:?}", object_in_map_t2.translation);
let result = registry
.get_transform_at(
"camera", t2, "object", t1, "map", )
.expect("time travel lookup failed");
info!(
"Object-at-t1 in camera-at-t2 (time travel): {:?}",
result.translation
);
let drift = registry
.get_transform_at(
"object", t1, "object", t2, "map", )
.expect("drift lookup failed");
info!("Conveyor drift (t1 -> t2): {:?}", drift.translation);
registry.delete_transforms_before(t2);
}
#[cfg(feature = "std")]
fn main() {
panic!("The 'std' feature must be disabled for this example.");
}