Skip to main content

Pose

Struct Pose 

Source
pub struct Pose { /* private fields */ }
Expand description

A 3D position and local-frame orientation after evaluating a linkage step.

§Pose and coordinate values

let rotation = Mat3::yaw(FRAC_PI_2) * Mat3::IDENTITY;
let forward = rotation.forward();
let left = rotation.left();
let up = rotation.up();
assert!(forward.is_close_to(&Vec3::from([0.0, 1.0, 0.0]), 1e-5));
assert!(left[0] < 0.0);
assert_eq!(up.into_array(), [0.0, 0.0, 1.0]);
assert!((rotation.as_array()[0][0]).abs() < 1e-5);
let position = Vec3::from([1.0, 2.0, 3.0]);
let offset = (position + Vec3::from([1.0, 0.0, 0.0])) * 2.0;
assert_eq!(offset[0], 4.0);
assert!(offset.distance_to(position) > 0.0);
assert!(offset.is_close_to(&Vec3::from([4.0, 4.0, 6.0]), 1e-5));
let pose = Pose::new(rotation, position);
let start = Pose::start();
let _orientation = pose.orientation();
let _position = pose.position();
let _screen = pose.project(&Projection::front_orthographic(Point::new(0, 0), 10.0));
assert!(!pose.is_close_to(&start, 1e-5));

Implementations§

Source§

impl Pose

Source

pub const fn new(orientation: Mat3, position: Vec3) -> Self

Create a pose from an orientation and position.

See the pose and coordinate example.

Source

pub fn project(self, projection: &Projection) -> (f32, f32)

Project this pose’s position through projection into screen-space (x, y).

See the pose and coordinate example.

Source

pub const fn start() -> Self

Return the origin pose with identity orientation.

See the pose and coordinate example.

Source

pub const fn orientation(self) -> Mat3

Return this pose’s orientation matrix.

Source

pub const fn position(self) -> Vec3

Return this pose’s position.

Source

pub fn is_close_to(&self, other: &Self, tolerance: f32) -> bool

Return true when all orientation and position components are within tolerance.

Trait Implementations§

Source§

impl Clone for Pose

Source§

fn clone(&self) -> Pose

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 Copy for Pose

Source§

impl Debug for Pose

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Pose

§

impl RefUnwindSafe for Pose

§

impl Send for Pose

§

impl Sync for Pose

§

impl Unpin for Pose

§

impl UnsafeUnpin for Pose

§

impl UnwindSafe for Pose

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> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
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<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
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> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
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, !>

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<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.