Struct Transformation

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

A transformation corresponds to a translation of a rotation of a scaling

The rotation here is encoded by a Quaternion

Implementations§

Source§

impl Transformation

Source

pub fn new() -> Self

Create a new identity transformation

Source

pub fn with_scale(self, scale: Vec3) -> Self

Set the scaling of a transformation

Source

pub fn with_translation(self, translation: Vec3) -> Self

Set the translation of a transformation

Source

pub fn with_rotation(self, rotation: Quat) -> Self

Set the rotation of a transformation

Source

pub fn scale(&mut self) -> Vec3

Get the scale

Source

pub fn translation(&mut self) -> Vec3

Set the translation of a transformation

Source

pub fn rotation(&self) -> Quat

Set the rotation of a transformation

Source

pub fn set_scale(&mut self, scale: Vec3)

Set the scaling of a transformation

Source

pub fn set_translation(&mut self, translation: Vec3)

Set the translation of a transformation

Source

pub fn set_rotation(&mut self, rotation: Quat)

Set the rotation of a transformation

Source

pub fn copy_from(&mut self, other: &Self)

Copy the transformation from another

Source

pub fn combine(&mut self, base: &Self, other: &Self)

Combine two transformations into this

To operate correctly the scales must be

Source

pub fn translate(&mut self, translation: &Vec3, scale: f32)

Pre-apply a translation to the transformation

Source

pub fn rotate_axis_angle(&mut self, axis: &Vec3, angle: f32)

Rotate the transformation by an angle about an axis

Source

pub fn rotate_by(&mut self, quaternion: &Quat)

Rotate the transformation by an angle about an axis

Source

pub fn mat4(&self) -> Mat4

Create a mat4 from the Transformation

Source

pub fn mat4_inverse(&self) -> Mat4

Create a mat4 from the inverse of this Transformation

Source

pub fn from_mat4(&mut self, m: Mat4)

Set this translation from a Mat4 (assuming it can be done)

Source

pub fn mat4_after(&self, pre_mat: &Mat4) -> Mat4

Calculate a Mat4 of this transformation premultiplied by another Mat4

Source

pub fn interpolate(&mut self, t: f32, in0: &Self, in1: &Self)

Set this transformation to be an interpolation between two others

Source

pub fn distance(&self, other: &Self) -> f32

Calculate an approximate ‘distance’ between two transformations

Trait Implementations§

Source§

impl Clone for Transformation

Source§

fn clone(&self) -> Transformation

Returns a duplicate 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 Transformation

Source§

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

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

impl Default for Transformation

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for Transformation

Source§

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

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

impl Copy for Transformation

Auto Trait Implementations§

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.