Struct Point

Source
pub struct Point {
    pub position: Vector3,
    pub orientation: Quaternion,
    pub timestamp: Timestamp,
    pub frame: String,
}
Expand description

Represents a point in space with a position, orientation, and timestamp.

The Point struct encapsulates a 3D position using a Vector3, an orientation using a Quaternion, and a Timestamp to indicate when the point was recorded.

§Examples

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

let position = Vector3 {
    x: 1.0,
    y: 2.0,
    z: 3.0,
};
let orientation = Quaternion {
    w: 1.0,
    x: 0.0,
    y: 0.0,
    z: 0.0,
};
let timestamp = Timestamp::zero();
let frame = String::from("a");

let point = Point {
    position,
    orientation,
    timestamp,
    frame,
};

assert_eq!(point.position.x, 1.0);
assert_eq!(point.orientation.w, 1.0);

Fields§

§position: Vector3§orientation: Quaternion§timestamp: Timestamp§frame: String

Trait Implementations§

Source§

impl Clone for Point

Source§

fn clone(&self) -> Point

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Point

Source§

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

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

impl PartialEq for Point

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Point

Source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · 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 · 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 · 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 · 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 Transformable for Point

The Transformable trait defines an interface for objects that can be transformed using a Transform. Implementors of this trait can apply a transformation to themselves, modifying their position and orientation.

Below is an example of how to implement the Transformable trait for a Point.

§Examples

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

let position = Vector3 {
    x: 1.0,
    y: 2.0,
    z: 3.0,
};
let orientation = Quaternion {
    w: 1.0,
    x: 0.0,
    y: 0.0,
    z: 0.0,
};
let timestamp = Timestamp { t: 0 };
let frame = String::from("b");

let mut point = Point {
    position,
    orientation,
    timestamp,
    frame,
};

let transform = Transform {
    translation: Vector3 {
        x: 2.0,
        y: 0.0,
        z: 0.0,
    },
    rotation: Quaternion {
        w: 1.0,
        x: 0.0,
        y: 0.0,
        z: 0.0,
    },
    timestamp: Timestamp { t: 0 },
    parent: "a".into(),
    child: "b".into(),
};
let r = point.transform(&transform);
assert!(r.is_ok());
assert_eq!(point.frame, "a");
assert_eq!(point.position.x, 3.0);
Source§

fn transform(&mut self, transform: &Transform) -> Result<(), TransformError>

Applies a transformation to the Point.

§Arguments
  • transform - A reference to the Transform to be applied.
§Returns
  • Ok(()) if the transformation is successfully applied.
  • Err(TransformError) if the frames are incompatible or the timestamps do not match.
Source§

impl StructuralPartialEq for Point

Auto Trait Implementations§

§

impl Freeze for Point

§

impl RefUnwindSafe for Point

§

impl Send for Point

§

impl Sync for Point

§

impl Unpin for Point

§

impl UnwindSafe for Point

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<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 = Infallible

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.