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§
Source§impl Transform
impl Transform
Sourcepub fn from_yaw_pitch_offset(
yaw: f32,
pitch: f32,
offset: [f32; 3],
) -> 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.
Sourcepub fn character_rotation(yaw: f32) -> [f32; 4]
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.
Sourcepub fn of_model(yaw: f32, position: [f32; 3]) -> Transform
pub fn of_model(yaw: f32, position: [f32; 3]) -> Transform
A placed entity’s model transform: its yaw, pitch 0, its position.
Sourcepub fn rotate(&self, v: [f32; 3]) -> [f32; 3]
pub fn rotate(&self, v: [f32; 3]) -> [f32; 3]
v turned by the rotation: q · (v, 0) · q̄.
Original: Math::Quaternion::Rotate, Runtime 0x18001ea20.
Sourcepub fn apply(&self, v: [f32; 3]) -> [f32; 3]
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.
Sourcepub fn inverse(&self) -> Transform
pub fn inverse(&self) -> Transform
The inverse transform: the conjugate rotation, and the negated offset turned by it.
Original: Math::Transform::Inverse, Runtime 0x18005e620.
Sourcepub fn heading_of(&self, local_yaw: f32) -> f32
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.