Expand description
A 3x3 column major matrix.
Fields
x_axis: Vec3
y_axis: Vec3
z_axis: Vec3
Implementations
sourceimpl Mat3
impl Mat3
sourcepub fn from_cols(x_axis: Vec3, y_axis: Vec3, z_axis: Vec3) -> Mat3
pub fn from_cols(x_axis: Vec3, y_axis: Vec3, z_axis: Vec3) -> Mat3
Creates a 3x3 matrix from three column vectors.
sourcepub fn from_cols_array(m: &[f32; 9]) -> Mat3
pub fn from_cols_array(m: &[f32; 9]) -> Mat3
Creates a 3x3 matrix from a [f32; 9]
stored in column major order.
If your data is stored in row major you will need to transpose
the
returned matrix.
sourcepub fn to_cols_array(&self) -> [f32; 9]
pub fn to_cols_array(&self) -> [f32; 9]
Creates a [f32; 9]
storing data in column major order.
If you require data in row major order transpose
the matrix first.
sourcepub fn from_cols_array_2d(m: &[[f32; 3]; 3]) -> Mat3
pub fn from_cols_array_2d(m: &[[f32; 3]; 3]) -> Mat3
Creates a 3x3 matrix from a [[f32; 3]; 3]
stored in column major order.
If your data is in row major order you will need to transpose
the
returned matrix.
sourcepub fn to_cols_array_2d(&self) -> [[f32; 3]; 3]
pub fn to_cols_array_2d(&self) -> [[f32; 3]; 3]
Creates a [[f32; 3]; 3]
storing data in column major order.
If you require data in row major order transpose
the matrix first.
sourcepub fn from_scale_angle_translation(
scale: Vec2,
angle: f32,
translation: Vec2
) -> Mat3
pub fn from_scale_angle_translation(
scale: Vec2,
angle: f32,
translation: Vec2
) -> Mat3
Creates a 3x3 homogeneous transformation matrix from the given scale
,
rotation angle
(in radians) and translation
.
The resulting matrix can be used to transform 2D points and vectors.
sourcepub fn from_quat(rotation: Quat) -> Mat3
pub fn from_quat(rotation: Quat) -> Mat3
Creates a 3x3 rotation matrix from the given quaternion.
sourcepub fn from_axis_angle(axis: Vec3, angle: f32) -> Mat3
pub fn from_axis_angle(axis: Vec3, angle: f32) -> Mat3
Creates a 3x3 rotation matrix from a normalized rotation axis
and
angle
(in radians).
sourcepub fn from_rotation_ypr(yaw: f32, pitch: f32, roll: f32) -> Mat3
pub fn from_rotation_ypr(yaw: f32, pitch: f32, roll: f32) -> Mat3
Creates a 3x3 rotation matrix from the given Euler angles (in radians).
sourcepub fn from_rotation_x(angle: f32) -> Mat3
pub fn from_rotation_x(angle: f32) -> Mat3
Creates a 3x3 rotation matrix from angle
(in radians) around the x axis.
sourcepub fn from_rotation_y(angle: f32) -> Mat3
pub fn from_rotation_y(angle: f32) -> Mat3
Creates a 3x3 rotation matrix from angle
(in radians) around the y axis.
sourcepub fn from_rotation_z(angle: f32) -> Mat3
pub fn from_rotation_z(angle: f32) -> Mat3
Creates a 3x3 rotation matrix from angle
(in radians) around the z axis.
sourcepub fn from_scale(scale: Vec3) -> Mat3
pub fn from_scale(scale: Vec3) -> Mat3
Creates a 3x3 non-uniform scale matrix.
pub fn set_x_axis(&mut self, x: Vec3)
please use .x_axis
instead
pub fn set_y_axis(&mut self, y: Vec3)
please use .y_axis
instead
pub fn set_z_axis(&mut self, z: Vec3)
please use .z_axis
instead
pub fn x_axis(&self) -> Vec3
please use .x_axis
instead
pub fn y_axis(&self) -> Vec3
please use .y_axis
instead
pub fn z_axis(&self) -> Vec3
please use .z_axis
instead
pub fn x_axis_mut(&mut self) -> &mut Vec3
please use .x_axis
instead
pub fn y_axis_mut(&mut self) -> &mut Vec3
please use .y_axis
instead
pub fn z_axis_mut(&mut self) -> &mut Vec3
please use .z_axis
instead
sourcepub fn determinant(&self) -> f32
pub fn determinant(&self) -> f32
Returns the determinant of self
.
sourcepub fn inverse(&self) -> Mat3
pub fn inverse(&self) -> Mat3
Returns the inverse of self
.
If the matrix is not invertible the returned matrix will be invalid.
sourcepub fn mul_scalar(&self, other: f32) -> Mat3
pub fn mul_scalar(&self, other: f32) -> Mat3
Multiplies a 3x3 matrix by a scalar.
sourcepub fn transform_point2(&self, other: Vec2) -> Vec2
pub fn transform_point2(&self, other: Vec2) -> Vec2
Transforms the given Vec2
as 2D point.
This is the equivalent of multiplying the Vec2
as a Vec3
where z
is 1.0
.
sourcepub fn transform_vector2(&self, other: Vec2) -> Vec2
pub fn transform_vector2(&self, other: Vec2) -> Vec2
Transforms the given Vec2
as 2D vector.
This is the equivalent of multiplying the Vec2
as a Vec3
where z
is 0.0
.
sourcepub fn abs_diff_eq(&self, other: Mat3, max_abs_diff: f32) -> bool
pub fn abs_diff_eq(&self, other: Mat3, max_abs_diff: f32) -> bool
Returns true if the absolute difference of all elements between self
and other
is less than or equal to max_abs_diff
.
This can be used to compare if two Mat3
’s contain similar elements. It
works best when comparing with a known value. The max_abs_diff
that
should be used used depends on the values being compared against.
For more on floating point comparisons see https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
Trait Implementations
sourceimpl PartialEq<Mat3> for Mat3
impl PartialEq<Mat3> for Mat3
sourceimpl PartialOrd<Mat3> for Mat3
impl PartialOrd<Mat3> for Mat3
sourcefn partial_cmp(&self, other: &Mat3) -> Option<Ordering>
fn partial_cmp(&self, other: &Mat3) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl Copy for Mat3
impl StructuralPartialEq for Mat3
Auto Trait Implementations
impl RefUnwindSafe for Mat3
impl Send for Mat3
impl Sync for Mat3
impl Unpin for Mat3
impl UnwindSafe for Mat3
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more