pub struct Transform { /* private fields */ }Expand description
Semantic local spatial transform value.
Stores translation + unit-quaternion rotation + per-axis scale + optional dimensionless row-basis shear (XY, XZ, YZ). All constructed values are finite; operations that would produce a non-finite result leave the value unchanged and return an error.
Donor: oa::Transform.
Implementations§
Source§impl Transform
impl Transform
Sourcepub fn new(translation: Vec3, rotation: Quat, scale: Vec3, shear: Vec3) -> Self
pub fn new(translation: Vec3, rotation: Quat, scale: Vec3, shear: Vec3) -> Self
Construct from explicit components.
rotation is normalized on construction. scale must be non-zero on
each axis for the transform to be invertible, but construction does not
enforce this.
Sourcepub fn set_position(&mut self, position: Vec3)
pub fn set_position(&mut self, position: Vec3)
Set the translation component.
Sourcepub fn set_rotation(&mut self, rotation: Quat)
pub fn set_rotation(&mut self, rotation: Quat)
Set the rotation component. The quaternion is normalized.
Sourcepub fn look_at(&mut self, target: Vec3, world_up: Vec3)
pub fn look_at(&mut self, target: Vec3, world_up: Vec3)
Orient the transform to look toward target with the given world_up.
When target equals the current position or world_up is degenerate the
rotation is left unchanged.
Sourcepub fn set_rotation_degrees(&mut self, degrees: Vec3, order: RotationOrder)
pub fn set_rotation_degrees(&mut self, degrees: Vec3, order: RotationOrder)
Set rotation from Euler angles in degrees using order.
Leaves the rotation unchanged on non-finite or degenerate input.
Sourcepub fn rotation_degrees(&self, order: RotationOrder) -> Vec3
pub fn rotation_degrees(&self, order: RotationOrder) -> Vec3
Return the current rotation as Euler angles in degrees using order.
Returns Vec3::default() when the quaternion is degenerate.
Sourcepub fn pan_local(&mut self, right: f32, up: f32, forward: f32)
pub fn pan_local(&mut self, right: f32, up: f32, forward: f32)
Translate in local space: right × local-right + up × local-up +
forward × local-forward.
Sourcepub fn get_matrix(&self) -> Mat4
pub fn get_matrix(&self) -> Mat4
Compute the row-vector TRS+shear matrix.
The matrix is: S × Shear × R × T (row-major, row-vector convention).
Returns Mat4::identity for a default transform.
Sourcepub fn set_matrix(&mut self, matrix: Mat4) -> Result<()>
pub fn set_matrix(&mut self, matrix: Mat4) -> Result<()>
Decompose a finite non-singular affine matrix into this transform.
Leaves the transform unchanged on failure.
§Errors
Returns an error when matrix is non-finite, singular, or the
decomposed quaternion is degenerate.