pub struct Matrix3 {
pub m11: f64,
pub m12: f64,
pub m13: f64,
pub m21: f64,
pub m22: f64,
pub m23: f64,
pub m31: f64,
pub m32: f64,
pub m33: f64,
}Expand description
A 3x3 matrix for rotations and coordinate transformations.
The matrix is stored in row-major order:
| m11 m12 m13 |
| m21 m22 m23 |
| m31 m32 m33 |Fields§
§m11: f64§m12: f64§m13: f64§m21: f64§m22: f64§m23: f64§m31: f64§m32: f64§m33: f64Implementations§
Source§impl Matrix3
impl Matrix3
Sourcepub fn new(
m11: f64,
m12: f64,
m13: f64,
m21: f64,
m22: f64,
m23: f64,
m31: f64,
m32: f64,
m33: f64,
) -> Self
pub fn new( m11: f64, m12: f64, m13: f64, m21: f64, m22: f64, m23: f64, m31: f64, m32: f64, m33: f64, ) -> Self
Create a new Matrix3 from individual elements.
Sourcepub fn from_rows(row1: Vector3, row2: Vector3, row3: Vector3) -> Self
pub fn from_rows(row1: Vector3, row2: Vector3, row3: Vector3) -> Self
Create a matrix from row vectors.
Sourcepub fn from_cols(col1: Vector3, col2: Vector3, col3: Vector3) -> Self
pub fn from_cols(col1: Vector3, col2: Vector3, col3: Vector3) -> Self
Create a matrix from column vectors.
Sourcepub fn rotation_x(angle: f64) -> Self
pub fn rotation_x(angle: f64) -> Self
Create a rotation matrix about the X axis.
Sourcepub fn rotation_y(angle: f64) -> Self
pub fn rotation_y(angle: f64) -> Self
Create a rotation matrix about the Y axis.
Sourcepub fn rotation_z(angle: f64) -> Self
pub fn rotation_z(angle: f64) -> Self
Create a rotation matrix about the Z axis. This rotates vectors counter-clockwise when viewed from +Z axis.
Sourcepub fn determinant(&self) -> f64
pub fn determinant(&self) -> f64
Compute the determinant.
Sourcepub fn inverse(&self) -> Option<Self>
pub fn inverse(&self) -> Option<Self>
Compute the inverse of the matrix. Returns None if the matrix is singular.
Sourcepub fn is_identity(&self, epsilon: f64) -> bool
pub fn is_identity(&self, epsilon: f64) -> bool
Check if this is approximately an identity matrix.
Sourcepub fn is_rotation(&self, epsilon: f64) -> bool
pub fn is_rotation(&self, epsilon: f64) -> bool
Check if this is approximately a rotation matrix (orthogonal with det = 1).
Trait Implementations§
impl Copy for Matrix3
impl StructuralPartialEq for Matrix3
Auto Trait Implementations§
impl Freeze for Matrix3
impl RefUnwindSafe for Matrix3
impl Send for Matrix3
impl Sync for Matrix3
impl Unpin for Matrix3
impl UnwindSafe for Matrix3
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