Matrix3D
struct · ferroui-media3d · v0.5.0
struct Matrix3D
A 4x4 transformation of 3D space, with double-precision elements (WPF's
System.Windows.Media.Media3D.Matrix3D).
The convention is WPF's: points are row vectors multiplied on the left, p' = p * M, so the
translation is the fourth row (offset_x, offset_y, offset_z) and the projective terms are
the fourth column (m14, m24, m34, m44). a * b is a followed by b;
append multiplies on the right and prepend on the
left. The default value is Matrix3D::IDENTITY, as in WPF.
The methods that change the matrix take &mut self, as WPF's change the structure in place.
Members
m11m12m13m14m21m22m23m24m31m32m33m34offset_xoffset_yoffset_zm44IDENTITYnewset_identityis_identityis_affinedeterminanthas_inverseinvertappendprependrotaterotate_prependrotate_atrotate_at_prependscalescale_prependscale_atscale_at_prependtranslatetranslate_prependtransformtransform_pointstransform_vectortransform_vectorstransform_point4dtransform_points4dparse
m11
m11: f64
Row 1, column 1.
m12
m12: f64
Row 1, column 2.
m13
m13: f64
Row 1, column 3.
m14
m14: f64
Row 1, column 4 (projective).
m21
m21: f64
Row 2, column 1.
m22
m22: f64
Row 2, column 2.
m23
m23: f64
Row 2, column 3.
m24
m24: f64
Row 2, column 4 (projective).
m31
m31: f64
Row 3, column 1.
m32
m32: f64
Row 3, column 2.
m33
m33: f64
Row 3, column 3.
m34
m34: f64
Row 3, column 4 (projective).
offset_x
offset_x: f64
Row 4, column 1: the translation along X.
offset_y
offset_y: f64
Row 4, column 2: the translation along Y.
offset_z
offset_z: f64
Row 4, column 3: the translation along Z.
m44
m44: f64
Row 4, column 4 (projective).
IDENTITY
const IDENTITY: Matrix3D
The identity transformation (WPF's Matrix3D.Identity).
new
const fn new(m11: f64, m12: f64, m13: f64, m14: f64, m21: f64, m22: f64, m23: f64, m24: f64, m31: f64, m32: f64, m33: f64, m34: f64, offset_x: f64, offset_y: f64, offset_z: f64, m44: f64) -> Self
A matrix with the given elements, row by row.
set_identity
fn set_identity(self: &mut Self)
Makes this the identity.
is_identity
fn is_identity(self: &Self) -> bool
Whether this is the identity, element by element.
is_affine
fn is_affine(self: &Self) -> bool
Whether the matrix is affine: no projective terms (m14, m24, m34 zero and m44 one).
determinant
fn determinant(self: &Self) -> f64
The determinant: of the upper 3x3 block for an affine matrix, of the whole matrix otherwise.
has_inverse
fn has_inverse(self: &Self) -> bool
Whether the matrix has an inverse: its determinant is not zero within ten machine epsilons.
invert
fn invert(self: &mut Self) -> Result<(), Matrix3DError>
Replaces the matrix by its inverse; Matrix3DError::NotInvertible (and the matrix
unchanged) when it has none (has_inverse is false).
append
fn append(self: &mut Self, matrix: Matrix3D)
Multiplies the matrix by matrix on the right: this transformation, then matrix.
prepend
fn prepend(self: &mut Self, matrix: Matrix3D)
Multiplies the matrix by matrix on the left: matrix, then this transformation.
rotate
fn rotate(self: &mut Self, quaternion: Quaternion)
Appends the rotation of the quaternion about the origin.
rotate_prepend
fn rotate_prepend(self: &mut Self, quaternion: Quaternion)
Prepends the rotation of the quaternion about the origin.
rotate_at
fn rotate_at(self: &mut Self, quaternion: Quaternion, center: Point3D)
Appends the rotation of the quaternion about center.
rotate_at_prepend
fn rotate_at_prepend(self: &mut Self, quaternion: Quaternion, center: Point3D)
Prepends the rotation of the quaternion about center.
scale
fn scale(self: &mut Self, scale: Vector3D)
Appends a scale by the components of the vector, about the origin.
scale_prepend
fn scale_prepend(self: &mut Self, scale: Vector3D)
Prepends a scale by the components of the vector, about the origin.
scale_at
fn scale_at(self: &mut Self, scale: Vector3D, center: Point3D)
Appends a scale by the components of the vector, about center.
scale_at_prepend
fn scale_at_prepend(self: &mut Self, scale: Vector3D, center: Point3D)
Prepends a scale by the components of the vector, about center.
translate
fn translate(self: &mut Self, offset: Vector3D)
Appends a translation by the vector.
translate_prepend
fn translate_prepend(self: &mut Self, offset: Vector3D)
Prepends a translation by the vector.
transform
fn transform(self: &Self, point: Point3D) -> Point3D
The point transformed by the matrix, divided by its w when the matrix is not affine.
transform_points
fn transform_points(self: &Self, points: &mut [Point3D])
Transforms the points in place, as transform.
transform_vector
fn transform_vector(self: &Self, vector: Vector3D) -> Vector3D
The vector transformed by the matrix: by its upper 3x3 block, so the translation and the projective terms do not apply.
transform_vectors
fn transform_vectors(self: &Self, vectors: &mut [Vector3D])
Transforms the vectors in place, as transform_vector.
transform_point4d
fn transform_point4d(self: &Self, point: Point4D) -> Point4D
The homogeneous point transformed by the whole matrix, without a divide.
transform_points4d
fn transform_points4d(self: &Self, points: &mut [Point4D])
Transforms the homogeneous points in place, as
transform_point4d.
parse
fn parse(text: &str) -> Result<Self, FormatError>
Parses the text form: "Identity", or the 16 elements row by row (commas, white space or
both between the numbers) in the invariant culture.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeBorrow<T>BorrowMut<T>CloneToUninitInto<U>From<T>TryInto<U>TryFrom<U>AnyToOwnedToStringPropertyValueAnyValueClassDefaultsErasedDestructorIntoEitherMarkupTypedCloneCopyDebugStructuralPartialEqPartialEqDefaultMulMulAssignFromStrDisplayMul<Matrix3D>
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.