Skip to main content

Transform

Struct Transform 

pub struct Transform {
    pub q: [f32; 4],
    pub p: [f32; 3],
}
Expand description

The engine’s transform: a rotation (a quaternion) and an offset. A placed model keeps its position this way.

Original: Math::Transform.

Fields§

§q: [f32; 4]

The rotation, a unit quaternion (x, y, z, w).

§p: [f32; 3]

The offset, applied after the rotation.

Implementations§

§

impl Transform

pub fn from_yaw_pitch_offset( yaw: f32, pitch: f32, offset: [f32; 3], ) -> Transform

A transform from a yaw, a pitch (degrees) and an offset. The rotation uses the sines and cosines of the half angles: q = (−cy·sp, −sy·sp, −cp·sy, cp·cy).

Original: Math::Transform::FromYawPitchOffset, Runtime 0x18007e540.

pub fn character_rotation(yaw: f32) -> [f32; 4]

The rotation a CharacterComponent’s update writes: (+0, +0, −sinf(h), cosf(h)) with h = (yaw × DEG_TO_RAD) × 0.5, rounded in that order (a model’s FromYawPitchOffset halves first, and its zeros are negative).

Original: FUN_14010e990.

pub fn of_model(yaw: f32, position: [f32; 3]) -> Transform

A placed entity’s model transform: its yaw, pitch 0, its position.

pub fn rotate(&self, v: [f32; 3]) -> [f32; 3]

v turned by the rotation: q · (v, 0) · q̄.

Original: Math::Quaternion::Rotate, Runtime 0x18001ea20.

pub fn apply(&self, v: [f32; 3]) -> [f32; 3]

A point moved by the transform: rotated, then offset.

Original: Math::Transform::operator*(Vector3), Runtime 0x18001eae0.

pub fn inverse(&self) -> Transform

The inverse transform: the conjugate rotation, and the negated offset turned by it.

Original: Math::Transform::Inverse, Runtime 0x18005e620.

pub fn heading_of(&self, local_yaw: f32) -> f32

A heading in the model’s own space, turned into the world: the heading of from_yaw_pitch(local_yaw, 0) after the rotation.

Original: FUN_140128d50.

Trait Implementations§

§

impl Clone for Transform

§

fn clone(&self) -> Transform

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
§

impl Copy for Transform

§

impl Debug for Transform

§

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

Formats the value using the given formatter. Read more
§

impl Default for Transform

§

fn default() -> Transform

The identity.

§

impl PartialEq for Transform

§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
§

impl StructuralPartialEq for Transform

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, 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.