Struct ultraviolet::mat::Mat3
source · #[repr(C)]pub struct Mat3 {
pub cols: [Vec3; 3],
}
Expand description
A 3x3 square matrix.
Useful for performing linear transformations (rotation, scaling) on 3d vectors, or for performing arbitrary transformations (linear + translation, projection, etc) on homogeneous 2d vectors
Fields§
§cols: [Vec3; 3]
Implementations§
source§impl Mat3
impl Mat3
pub const fn new(col1: Vec3, col2: Vec3, col3: Vec3) -> Self
sourcepub fn from_translation(trans: Vec2) -> Self
pub fn from_translation(trans: Vec2) -> Self
Assumes homogeneous 2d coordinates.
sourcepub fn from_scale_homogeneous(scale: f32) -> Self
pub fn from_scale_homogeneous(scale: f32) -> Self
Assumes homogeneous 2d coordinates.
sourcepub fn from_nonuniform_scale_homogeneous(scale: Vec2) -> Self
pub fn from_nonuniform_scale_homogeneous(scale: Vec2) -> Self
Assumes homogeneous 2d coordinates.
sourcepub fn from_rotation_homogeneous(angle: f32) -> Self
pub fn from_rotation_homogeneous(angle: f32) -> Self
Builds a homogeneous 2d rotation matrix (in the xy plane) from a given angle in radians.
pub fn from_scale(scale: f32) -> Self
pub fn from_nonuniform_scale(scale: Vec3) -> Self
pub fn identity() -> Self
sourcepub fn from_euler_angles(roll: f32, pitch: f32, yaw: f32) -> Self
pub fn from_euler_angles(roll: f32, pitch: f32, yaw: f32) -> Self
Angles are applied in the order roll -> pitch -> yaw.
- Yaw is rotation inside the xz plane (“around the y axis”)
- Pitch is rotation inside the yz plane (“around the x axis”)
- Roll is rotation inside the xy plane (“around the z axis”)
sourcepub fn from_rotation_x(angle: f32) -> Self
pub fn from_rotation_x(angle: f32) -> Self
Create a new rotation matrix from a rotation “around the x axis”. This is here as a convenience function for users coming from other libraries; it is more proper to think of this as a rotation in the yz plane.
sourcepub fn from_rotation_y(angle: f32) -> Self
pub fn from_rotation_y(angle: f32) -> Self
Create a new rotation matrix from a rotation “around the y axis”. This is here as a convenience function for users coming from other libraries; it is more proper to think of this as a rotation in the xz plane.
sourcepub fn from_rotation_z(angle: f32) -> Self
pub fn from_rotation_z(angle: f32) -> Self
Create a new rotation matrix from a rotation “around the z axis”. This is here as a convenience function for users coming from other libraries; it is more proper to think of this as a rotation in the xy plane.
sourcepub fn from_rotation_around(axis: Vec3, angle: f32) -> Self
pub fn from_rotation_around(axis: Vec3, angle: f32) -> Self
Create a new rotation matrix from a rotation around the given axis. This is here as a convenience function for users coming from other libraries.
sourcepub fn from_angle_plane(angle: f32, plane: Bivec3) -> Self
pub fn from_angle_plane(angle: f32, plane: Bivec3) -> Self
Construct a rotation matrix given a bivector which defines a plane and rotation orientation, and a rotation angle.
plane
must be normalized!
This is the equivalent of an axis-angle rotation.
pub fn into_homogeneous(self) -> Mat4
pub fn determinant(&self) -> f32
sourcepub fn adjugate(&self) -> Self
pub fn adjugate(&self) -> Self
The adjugate of this matrix, i.e. the transpose of the cofactor matrix.
This is equivalent to the inverse but without dividing by the determinant of the matrix, which can be useful in some contexts for better performance.
One such case is when this matrix is interpreted as a a homogeneous transformation matrix, in which case uniform scaling will not affect the resulting projected 3d version of transformed points or vectors.
sourcepub fn inverse(&mut self)
pub fn inverse(&mut self)
If this matrix is not currently invertable, this function will return an invalid inverse. This status is not checked by the library.
sourcepub fn inversed(&self) -> Self
pub fn inversed(&self) -> Self
If this matrix is not currently invertable, this function will return an invalid inverse. This status is not checked by the library.
pub fn transpose(&mut self)
pub fn transposed(&self) -> Self
sourcepub fn transform_vec2(&self, vec: Vec2) -> Vec2
pub fn transform_vec2(&self, vec: Vec2) -> Vec2
Transform a Vec2 by self, interpreting it as a vector.
sourcepub fn transform_point2(&self, point: Vec2) -> Vec2
pub fn transform_point2(&self, point: Vec2) -> Vec2
Transform a Vec2 by self, interpreting it as a point.
sourcepub fn layout() -> Layout
pub fn layout() -> Layout
Get the core::alloc::Layout
of Self
sourcepub fn as_array(&self) -> &[f32; 9]
pub fn as_array(&self) -> &[f32; 9]
Interpret self
as a statically sized array of the base numeric type.
sourcepub fn as_mut_array(&mut self) -> &mut [f32; 9]
pub fn as_mut_array(&mut self) -> &mut [f32; 9]
Interpret self
as a statically sized array of the base numeric type.
sourcepub fn as_component_array(&self) -> &[Vec3; 3]
pub fn as_component_array(&self) -> &[Vec3; 3]
Interpret self
as a statically sized array of the component (column) vectors.
sourcepub fn as_mut_component_array(&mut self) -> &mut [Vec3; 3]
pub fn as_mut_component_array(&mut self) -> &mut [Vec3; 3]
Interpret self
as a statically sized array of the component (column) vectors.
sourcepub fn as_component_slice(&self) -> &[Vec3]
pub fn as_component_slice(&self) -> &[Vec3]
Interpret self
as a slice of the component (column) vectors.
sourcepub fn as_byte_slice(&self) -> &[u8] ⓘ
pub fn as_byte_slice(&self) -> &[u8] ⓘ
Interpret self
as a slice of bytes.
sourcepub fn as_mut_slice(&mut self) -> &mut [f32]
pub fn as_mut_slice(&mut self) -> &mut [f32]
Interpret self
as a slice of the base numeric type.
sourcepub fn as_mut_component_slice(&mut self) -> &mut [Vec3]
pub fn as_mut_component_slice(&mut self) -> &mut [Vec3]
Interpret self
as a slice of the component (column) vectors.
sourcepub fn as_mut_byte_slice(&mut self) -> &mut [u8] ⓘ
pub fn as_mut_byte_slice(&mut self) -> &mut [u8] ⓘ
Interpret self
as a slice of bytes.
sourcepub const fn as_ptr(&self) -> *const f32
pub const fn as_ptr(&self) -> *const f32
Returns a constant unsafe pointer to the underlying data in the underlying type. This function is safe because all types here are repr(C) and can be represented as their underlying type.
Safety
It is up to the caller to correctly use this pointer and its bounds.
sourcepub fn as_mut_ptr(&mut self) -> *mut f32
pub fn as_mut_ptr(&mut self) -> *mut f32
Returns a mutable unsafe pointer to the underlying data in the underlying type. This function is safe because all types here are repr(C) and can be represented as their underlying type.
Safety
It is up to the caller to correctly use this pointer and its bounds.
Trait Implementations§
source§impl AddAssign<Mat3> for Mat3
impl AddAssign<Mat3> for Mat3
source§fn add_assign(&mut self, rhs: Mat3)
fn add_assign(&mut self, rhs: Mat3)
+=
operation. Read moresource§impl<'de> Deserialize<'de> for Mat3
impl<'de> Deserialize<'de> for Mat3
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where D: Deserializer<'de>,
source§impl From<ColumnMatrix3<f32>> for Mat3
impl From<ColumnMatrix3<f32>> for Mat3
source§fn from(v: ColumnMatrix3<f32>) -> Self
fn from(v: ColumnMatrix3<f32>) -> Self
source§impl PartialEq<Mat3> for Mat3
impl PartialEq<Mat3> for Mat3
impl Copy for Mat3
impl Pod 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§
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> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere T: AnyBitPattern,
§type Bits = T
type Bits = T
Self
must have the same layout as the specified Bits
except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern
.source§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
bits
as &Self
.