pub struct Transform<P, O, S> {
    pub position: Vec3<P>,
    pub orientation: Quaternion<O>,
    pub scale: Vec3<S>,
}
Expand description

A convenient position + orientation + scale container, backed by two Vec3 and a Quaternion.

It can be easily interpolated and converted to a Mat4 of any layout.

let (p, rz, s) = (Vec3::unit_x(), 3.0_f32, 5.0_f32);
let a = Mat4::scaling_3d(s).rotated_z(rz).translated_3d(p);
let b = Mat4::from(Transform {
    position: p, 
    orientation: Quaternion::rotation_z(rz),
    scale: Vec3::broadcast(s),
});
assert_relative_eq!(a, b);

Fields

position: Vec3<P>

Local position.

orientation: Quaternion<O>

Local orientation; It is not named rotation because rotation denotes an operation, but not a current state.

scale: Vec3<S>

Local scale.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

The default Transform has a zero position, identity orientation and unit scale.

let a = Transform {
    position: Vec3::<f32>::zero(),
    orientation: Quaternion::<f32>::identity(),
    scale: Vec3::<f32>::one(),
};
assert_eq!(a, Transform::default());

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

Deserialize this value from the given Serde deserializer. Read more

A Mat4 can be obtained from a Transform, by rotating, then scaling, then translating.

Converts to this type from the input type.

A Mat4 can be obtained from a Transform, by rotating, then scaling, then translating.

Converts to this type from the input type.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

LERP on a Transform is defined as LERP-ing between the positions and scales, and performing SLERP between the orientations.

The resulting type after performing the LERP operation.

Returns the linear interpolation of from to to with factor unconstrained, using the supposedly fastest but less precise implementation. Read more

Returns the linear interpolation of from to to with factor unconstrained, using a possibly slower but more precise operation. Read more

Version of lerp_unclamped() that used a single RangeInclusive parameter instead of two values.

Version of lerp_unclamped_precise() that used a single RangeInclusive parameter instead of two values.

Alias to lerp_unclamped which constrains factor to be between 0 and 1 (inclusive). Read more

Version of lerp() that used a single RangeInclusive parameter instead of two values.

Alias to lerp_unclamped_precise which constrains factor to be between 0 and 1 (inclusive). Read more

Version of lerp_precise() that used a single RangeInclusive parameter instead of two values.

LERP on a Transform is defined as LERP-ing between the positions and scales, and performing SLERP between the orientations.

The resulting type after performing the LERP operation.

Returns the linear interpolation of from to to with factor unconstrained, using the supposedly fastest but less precise implementation. Read more

Returns the linear interpolation of from to to with factor unconstrained, using a possibly slower but more precise operation. Read more

Version of lerp_unclamped() that used a single RangeInclusive parameter instead of two values.

Version of lerp_unclamped_precise() that used a single RangeInclusive parameter instead of two values.

Alias to lerp_unclamped which constrains factor to be between 0 and 1 (inclusive). Read more

Version of lerp() that used a single RangeInclusive parameter instead of two values.

Alias to lerp_unclamped_precise which constrains factor to be between 0 and 1 (inclusive). Read more

Version of lerp_precise() that used a single RangeInclusive parameter instead of two values.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.