pub struct Transform {
pub position: Vec3,
pub rotation: Quat,
}Expand description
Transform representing position and orientation in 3D space.
Fields§
§position: Vec3Position in world space.
rotation: QuatOrientation as a unit quaternion.
Implementations§
Source§impl Transform
impl Transform
Sourcepub fn from_position(position: Vec3) -> Self
pub fn from_position(position: Vec3) -> Self
Create a new transform with the given position and identity rotation.
Sourcepub fn new(position: Vec3, rotation: Quat) -> Self
pub fn new(position: Vec3, rotation: Quat) -> Self
Create a new transform with the given position and rotation.
Sourcepub fn transform_point(&self, point: &Vec3) -> Vec3
pub fn transform_point(&self, point: &Vec3) -> Vec3
Transform a point from local space to world space.
Sourcepub fn transform_vector(&self, vector: &Vec3) -> Vec3
pub fn transform_vector(&self, vector: &Vec3) -> Vec3
Transform a vector (direction) from local space to world space.
Source§impl Transform
impl Transform
Sourcepub fn to_matrix4(&self) -> [[f64; 4]; 4]
pub fn to_matrix4(&self) -> [[f64; 4]; 4]
Convert to a 4x4 transformation matrix (column-major).
The matrix is [R | t; 0 0 0 1] where R is the rotation matrix.
Sourcepub fn euler_angles(&self) -> (f64, f64, f64)
pub fn euler_angles(&self) -> (f64, f64, f64)
Extract Euler angles (roll, pitch, yaw) from the rotation.
Sourcepub fn from_axis_angle(position: Vec3, axis: Vec3, angle: f64) -> Self
pub fn from_axis_angle(position: Vec3, axis: Vec3, angle: f64) -> Self
Create a transform from an axis-angle rotation and a position.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Transform
impl RefUnwindSafe for Transform
impl Send for Transform
impl Sync for Transform
impl Unpin for Transform
impl UnsafeUnpin for Transform
impl UnwindSafe for Transform
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.