pub struct Transform {
pub location: Vector,
pub rotation: Quaternion,
pub scale: Vector,
}Expand description
Transform containing Location, Rotation, and Scale
This represents a complete 3D transformation including:
- Location: 3D position in world space
- Rotation: 3D rotation as a quaternion
- Scale: 3D scale factors
Fields§
§location: Vector3D position/location
rotation: Quaternion3D rotation as quaternion
scale: Vector3D scale factors
Implementations§
Source§impl Transform
impl Transform
Sourcepub fn new(location: Vector, rotation: Quaternion, scale: Vector) -> Self
pub fn new(location: Vector, rotation: Quaternion, scale: Vector) -> Self
Create a new transform with the given location, rotation, and scale
Sourcepub fn from_location(location: Vector) -> Self
pub fn from_location(location: Vector) -> Self
Create a transform with only location (identity rotation and scale)
Sourcepub fn from_rotation(rotation: Quaternion) -> Self
pub fn from_rotation(rotation: Quaternion) -> Self
Create a transform with only rotation (zero location, identity scale)
Sourcepub fn from_scale(scale: Vector) -> Self
pub fn from_scale(scale: Vector) -> Self
Create a transform with only scale (zero location, identity rotation)
Sourcepub fn from_uniform_scale(scale: f32) -> Self
pub fn from_uniform_scale(scale: f32) -> Self
Create a transform with uniform scale
Sourcepub fn from_location_rotator(location: Vector, rotator: Rotator) -> Self
pub fn from_location_rotator(location: Vector, rotator: Rotator) -> Self
Create a transform from location and rotator
Sourcepub fn from_location_rotator_scale(
location: Vector,
rotator: Rotator,
scale: Vector,
) -> Self
pub fn from_location_rotator_scale( location: Vector, rotator: Rotator, scale: Vector, ) -> Self
Create a transform from location, rotator, and scale
Sourcepub fn from_matrix(matrix: Matrix4) -> Self
pub fn from_matrix(matrix: Matrix4) -> Self
Create transform from a 4x4 matrix
Sourcepub fn get_rotator(self) -> Rotator
pub fn get_rotator(self) -> Rotator
Get the rotator representation of the rotation
Sourcepub fn set_rotator(&mut self, rotator: Rotator)
pub fn set_rotator(&mut self, rotator: Rotator)
Set rotation using a rotator
Sourcepub fn transform_point(self, point: Vector) -> Vector
pub fn transform_point(self, point: Vector) -> Vector
Transform a point by this transform (applies scale, rotation, and translation)
Sourcepub fn transform_vector(self, vector: Vector) -> Vector
pub fn transform_vector(self, vector: Vector) -> Vector
Transform a vector by this transform (applies scale and rotation, ignores translation)
Sourcepub fn transform_direction(self, direction: Vector) -> Vector
pub fn transform_direction(self, direction: Vector) -> Vector
Transform a direction vector (applies only rotation, ignores scale and translation)
Sourcepub fn combine(self, other: Transform) -> Self
pub fn combine(self, other: Transform) -> Self
Combine this transform with another (this transform is applied first)
Sourcepub fn get_forward_vector(self) -> Vector
pub fn get_forward_vector(self) -> Vector
Get the forward vector for this transform
Sourcepub fn get_right_vector(self) -> Vector
pub fn get_right_vector(self) -> Vector
Get the right vector for this transform
Sourcepub fn get_up_vector(self) -> Vector
pub fn get_up_vector(self) -> Vector
Get the up vector for this transform
Sourcepub fn is_nearly_equal(self, other: Transform, tolerance: f32) -> bool
pub fn is_nearly_equal(self, other: Transform, tolerance: f32) -> bool
Check if this transform is nearly equal to another
Sourcepub fn is_nearly_identity(self, tolerance: f32) -> bool
pub fn is_nearly_identity(self, tolerance: f32) -> bool
Check if this transform is nearly the identity transform
Sourcepub fn lerp(self, other: Transform, alpha: f32) -> Self
pub fn lerp(self, other: Transform, alpha: f32) -> Self
Linearly interpolate between two transforms
Sourcepub fn add_location(self, delta: Vector) -> Self
pub fn add_location(self, delta: Vector) -> Self
Add translation to this transform
Sourcepub fn add_rotation(self, delta_rotation: Quaternion) -> Self
pub fn add_rotation(self, delta_rotation: Quaternion) -> Self
Add rotation to this transform
Sourcepub fn add_uniform_scale(self, delta_scale: f32) -> Self
pub fn add_uniform_scale(self, delta_scale: f32) -> Self
Add uniform scale to this transform