#[repr(C)]pub struct Mat3 {
pub cols: [Vec3; 3],
}Expand description
A 3x3 column-major matrix, typically used for 2D affine transformations (scale, rotation).
While it can represent any 3x3 matrix, its primary role in a 3D engine is often
as the upper-left rotation and scale part of a Mat4.
Fields§
§cols: [Vec3; 3]The columns of the matrix. cols[0] is the first column, and so on.
Implementations§
Source§impl Mat3
impl Mat3
Sourcepub fn from_cols(c0: Vec3, c1: Vec3, c2: Vec3) -> Mat3
pub fn from_cols(c0: Vec3, c1: Vec3, c2: Vec3) -> Mat3
Creates a new matrix from three column vectors.
Sourcepub fn from_scale_vec2(scale: Vec2) -> Mat3
pub fn from_scale_vec2(scale: Vec2) -> Mat3
Creates a 2D scaling matrix.
The Z-axis scale is set to 1.0, making it a no-op in that dimension.
Sourcepub fn from_scale(scale: Vec3) -> Mat3
pub fn from_scale(scale: Vec3) -> Mat3
Creates a 3D scaling matrix.
Sourcepub fn from_rotation_x(angle_radians: f32) -> Mat3
pub fn from_rotation_x(angle_radians: f32) -> Mat3
Creates a matrix for a rotation around the X-axis.
§Arguments
angle_radians: The angle of rotation in radians.
Sourcepub fn from_rotation_y(angle_radians: f32) -> Mat3
pub fn from_rotation_y(angle_radians: f32) -> Mat3
Creates a matrix for a right-handed rotation around the Y-axis.
§Arguments
angle_radians: The angle of rotation in radians.
Sourcepub fn from_rotation_z(angle_radians: f32) -> Mat3
pub fn from_rotation_z(angle_radians: f32) -> Mat3
Creates a matrix for a rotation around the Z-axis.
§Arguments
angle_radians: The angle of rotation in radians.
Sourcepub fn from_axis_angle(axis: Vec3, angle_radians: f32) -> Mat3
pub fn from_axis_angle(axis: Vec3, angle_radians: f32) -> Mat3
Creates a rotation matrix from a normalized axis and an angle.
§Arguments
axis: The axis of rotation. Must be a unit vector.angle_radians: The angle of rotation in radians.
Sourcepub fn from_quat(q: Quaternion) -> Mat3
pub fn from_quat(q: Quaternion) -> Mat3
Creates a rotation matrix from a quaternion. The quaternion is normalized before conversion to ensure a valid rotation matrix.
Sourcepub fn from_mat4(m4: &Mat4) -> Mat3
pub fn from_mat4(m4: &Mat4) -> Mat3
Creates a Mat3 from the upper-left 3x3 corner of a Mat4.
This effectively extracts the rotation and scale components, discarding translation.
Sourcepub fn determinant(&self) -> f32
pub fn determinant(&self) -> f32
Computes the determinant of the matrix.
The determinant is a scalar value indicating the volume scaling factor of the linear transformation. A determinant of 0 means the matrix is not invertible.
Sourcepub fn transpose(&self) -> Mat3
pub fn transpose(&self) -> Mat3
Returns the transpose of the matrix, where rows and columns are swapped.
Trait Implementations§
impl Copy for Mat3
impl StructuralPartialEq for Mat3
Auto Trait Implementations§
impl Freeze for Mat3
impl RefUnwindSafe for Mat3
impl Send for Mat3
impl Sync for Mat3
impl Unpin for Mat3
impl UnwindSafe for Mat3
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.