Struct ultraviolet::mat::DMat4x4
source · [−]Expand description
A 4x4 square matrix.
Useful for performing linear transformations (rotation, scaling) on 4d vectors, or for performing arbitrary transformations (linear + translation, projection, etc) on homogeneous 3d vectors.
Note that most constructors assume that the matrix will be used as a homogeneous 3d transformation matrix.
Fields
cols: [DVec4x4; 4]
Implementations
sourceimpl DMat4x4
impl DMat4x4
pub const fn new(
col1: DVec4x4,
col2: DVec4x4,
col3: DVec4x4,
col4: DVec4x4
) -> Self
pub fn identity() -> Self
sourcepub fn from_translation(trans: DVec3x4) -> Self
pub fn from_translation(trans: DVec3x4) -> Self
Assumes homogeneous 3d coordinates.
sourcepub fn from_scale(scale: f64x4) -> Self
pub fn from_scale(scale: f64x4) -> Self
Assumes homogeneous 3d coordinates.
sourcepub fn from_nonuniform_scale(scale: DVec3x4) -> Self
pub fn from_nonuniform_scale(scale: DVec3x4) -> Self
Assumes homogeneous 3d coordinates.
sourcepub fn from_scale_4d(scale: f64x4) -> Self
pub fn from_scale_4d(scale: f64x4) -> Self
Full 4d diagonal matrix.
sourcepub fn from_nonuniform_scale_4d(scale: DVec4x4) -> Self
pub fn from_nonuniform_scale_4d(scale: DVec4x4) -> Self
Full 4d nonuniform scaling matrix.
sourcepub fn from_euler_angles(roll: f64x4, pitch: f64x4, yaw: f64x4) -> Self
pub fn from_euler_angles(roll: f64x4, pitch: f64x4, yaw: f64x4) -> Self
Angles are applied in the order roll -> pitch -> yaw
- Roll is rotation inside the xy plane (“around the z axis”)
- Pitch is rotation inside the yz plane (“around the x axis”)
- Yaw is rotation inside the xz plane (“around the y axis”)
Assumes homogeneous 3d coordinates.
Important: This function assumes a right-handed, y-up coordinate space where:
- +X axis points right
- +Y axis points up
- +Z axis points towards the viewer (i.e. out of the screen)
This means that you may see unexpected behavior when used with OpenGL or DirectX
as they use a different coordinate system. You should use the appropriate
projection matrix in projection
module to fit your use case to remedy this.
sourcepub fn from_rotation_x(angle: f64x4) -> Self
pub fn from_rotation_x(angle: f64x4) -> 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.
Assumes homogeneous 3d coordinates.
Important: This function assumes a right-handed, y-up coordinate space where:
- +X axis points right
- +Y axis points up
- +Z axis points towards the viewer (i.e. out of the screen)
This means that you may see unexpected behavior when used with OpenGL or DirectX
as they use a different coordinate system. You should use the appropriate
projection matrix in projection
module to fit your use case to remedy this.
sourcepub fn from_rotation_y(angle: f64x4) -> Self
pub fn from_rotation_y(angle: f64x4) -> 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.
Assumes homogeneous 3d coordinates.
Important: This function assumes a right-handed, y-up coordinate space where:
- +X axis points right
- +Y axis points up
- +Z axis points towards the viewer (i.e. out of the screen)
This means that you may see unexpected behavior when used with OpenGL or DirectX
as they use a different coordinate system. You should use the appropriate
projection matrix in projection
module to fit your use case to remedy this.
sourcepub fn from_rotation_z(angle: f64x4) -> Self
pub fn from_rotation_z(angle: f64x4) -> 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.
Assumes homogeneous 3d coordinates.
Important: This function assumes a right-handed, y-up coordinate space where:
- +X axis points right
- +Y axis points up
- +Z axis points towards the viewer (i.e. out of the screen)
This means that you may see unexpected behavior when used with OpenGL or DirectX
as they use a different coordinate system. You should use the appropriate
projection matrix in projection
module to fit your use case to remedy this.
sourcepub fn from_rotation_around(axis: DVec4x4, angle: f64x4) -> Self
pub fn from_rotation_around(axis: DVec4x4, angle: f64x4) -> Self
Create a new rotation matrix from a rotation around the given axis. The axis will be interpreted as a 3d vector. This is here as a convenience function for users coming from other libraries.
Important: This function assumes a right-handed, y-up coordinate space where:
- +X axis points right
- +Y axis points up
- +Z axis points towards the viewer (i.e. out of the screen)
This means that you may see unexpected behavior when used with OpenGL or DirectX
as they use a different coordinate system. You should use the appropriate
projection matrix in projection
module to fit your use case to remedy this.
sourcepub fn from_angle_plane(angle: f64x4, plane: DBivec3x4) -> Self
pub fn from_angle_plane(angle: f64x4, plane: DBivec3x4) -> 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.
Assumes homogeneous 3d coordinates.
sourcepub fn translated(&self, translation: &DVec3x4) -> Self
pub fn translated(&self, translation: &DVec3x4) -> Self
Assumes homogeneous 3d coordinates.
sourcepub fn look_at(eye: DVec3x4, at: DVec3x4, up: DVec3x4) -> Self
pub fn look_at(eye: DVec3x4, at: DVec3x4, up: DVec3x4) -> Self
Constructs a ‘look-at’ matrix from an eye position, a focus position to look towards, and a vector that defines the ‘up’ direction.
This function assumes a right-handed, y-up coordinate space.
sourcepub fn look_at_lh(eye: DVec3x4, at: DVec3x4, up: DVec3x4) -> Self
pub fn look_at_lh(eye: DVec3x4, at: DVec3x4, up: DVec3x4) -> Self
Constructs a ‘look-at’ matrix from an eye position, a focus position to look towards, and a vector that defines the ‘up’ direction.
This function assumes a left-handed, y-up coordinate space.
pub fn transpose(&mut self)
pub fn transposed(&self) -> Self
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.
pub fn determinant(&self) -> f64x4
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 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.
sourcepub fn transform_vec3(&self, vec: DVec3x4) -> DVec3x4
pub fn transform_vec3(&self, vec: DVec3x4) -> DVec3x4
Transform a Vec3 by self, interpreting it as a vector.
sourcepub fn transform_point3(&self, point: DVec3x4) -> DVec3x4
pub fn transform_point3(&self, point: DVec3x4) -> DVec3x4
Transform a Vec3 by self, interpreting it as a point.
sourcepub fn extract_translation(&self) -> DVec3x4
pub fn extract_translation(&self) -> DVec3x4
If self
represents an affine transformation, return its translation components.
Otherwise, the returned value has undefined properties.
sourcepub fn extract_rotation(&self) -> DRotor3x4
pub fn extract_rotation(&self) -> DRotor3x4
If the 3x3 left upper block of self
is a rotation, return the corresponding
rotor. Otherwise, the returned value is a Rotor3
with undefined properties.
sourcepub fn into_isometry(&self) -> DIsometry3x4
pub fn into_isometry(&self) -> DIsometry3x4
If self represents an Isometry3
(i.e. self is a product of the from T * R
where
T
is a translation and R
a rotation), return the isometry
If self
does not represent an isometry, the returned value has undefined
properties.
sourcepub fn truncate(&self) -> DMat3x4
pub fn truncate(&self) -> DMat3x4
Truncate self
to a matrix consisting of the 3x3 left upper block.
If you need a rotation, consider using Self::extract_rotation()
instead.
pub fn layout() -> Layout
pub fn as_array(&self) -> &[f64x4; 16]
pub fn as_component_array(&self) -> &[DVec4x4; 4]
pub fn as_slice(&self) -> &[f64x4]
pub fn as_component_slice(&self) -> &[DVec4x4]
pub fn as_byte_slice(&self) -> &[u8]ⓘNotable traits for &'_ mut [u8]impl<'_> Write for &'_ mut [u8]impl<'_> Read for &'_ [u8]
pub fn as_mut_slice(&mut self) -> &mut [f64x4]
pub fn as_mut_component_slice(&mut self) -> &mut [DVec4x4]
pub fn as_mut_byte_slice(&mut self) -> &mut [u8]ⓘNotable traits for &'_ mut [u8]impl<'_> Write for &'_ mut [u8]impl<'_> Read for &'_ [u8]
sourcepub const fn as_ptr(&self) -> *const f64x4
pub const fn as_ptr(&self) -> *const f64x4
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 f64x4
pub fn as_mut_ptr(&mut self) -> *mut f64x4
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
sourceimpl AddAssign<DMat4x4> for DMat4x4
impl AddAssign<DMat4x4> for DMat4x4
sourcefn add_assign(&mut self, rhs: DMat4x4)
fn add_assign(&mut self, rhs: DMat4x4)
Performs the +=
operation. Read more
impl Copy for DMat4x4
impl StructuralPartialEq for DMat4x4
Auto Trait Implementations
impl RefUnwindSafe for DMat4x4
impl Send for DMat4x4
impl Sync for DMat4x4
impl Unpin for DMat4x4
impl UnwindSafe for DMat4x4
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
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
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more