FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    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.

    View source

    Members

    m11

    m11: f64
    

    Row 1, column 1.

    Source

    m12

    m12: f64
    

    Row 1, column 2.

    Source

    m13

    m13: f64
    

    Row 1, column 3.

    Source

    m14

    m14: f64
    

    Row 1, column 4 (projective).

    Source

    m21

    m21: f64
    

    Row 2, column 1.

    Source

    m22

    m22: f64
    

    Row 2, column 2.

    Source

    m23

    m23: f64
    

    Row 2, column 3.

    Source

    m24

    m24: f64
    

    Row 2, column 4 (projective).

    Source

    m31

    m31: f64
    

    Row 3, column 1.

    Source

    m32

    m32: f64
    

    Row 3, column 2.

    Source

    m33

    m33: f64
    

    Row 3, column 3.

    Source

    m34

    m34: f64
    

    Row 3, column 4 (projective).

    Source

    offset_x

    offset_x: f64
    

    Row 4, column 1: the translation along X.

    Source

    offset_y

    offset_y: f64
    

    Row 4, column 2: the translation along Y.

    Source

    offset_z

    offset_z: f64
    

    Row 4, column 3: the translation along Z.

    Source

    m44

    m44: f64
    

    Row 4, column 4 (projective).

    Source

    IDENTITY

    const IDENTITY: Matrix3D
    

    The identity transformation (WPF's Matrix3D.Identity).

    Source

    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.

    Source

    set_identity

    fn set_identity(self: &mut Self)
    

    Makes this the identity.

    Source

    is_identity

    fn is_identity(self: &Self) -> bool
    

    Whether this is the identity, element by element.

    Source

    is_affine

    fn is_affine(self: &Self) -> bool
    

    Whether the matrix is affine: no projective terms (m14, m24, m34 zero and m44 one).

    Source

    determinant

    fn determinant(self: &Self) -> f64
    

    The determinant: of the upper 3x3 block for an affine matrix, of the whole matrix otherwise.

    Source

    has_inverse

    fn has_inverse(self: &Self) -> bool
    

    Whether the matrix has an inverse: its determinant is not zero within ten machine epsilons.

    Source

    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).

    Source

    append

    fn append(self: &mut Self, matrix: Matrix3D)
    

    Multiplies the matrix by matrix on the right: this transformation, then matrix.

    Source

    prepend

    fn prepend(self: &mut Self, matrix: Matrix3D)
    

    Multiplies the matrix by matrix on the left: matrix, then this transformation.

    Source

    rotate

    fn rotate(self: &mut Self, quaternion: Quaternion)
    

    Appends the rotation of the quaternion about the origin.

    Source

    rotate_prepend

    fn rotate_prepend(self: &mut Self, quaternion: Quaternion)
    

    Prepends the rotation of the quaternion about the origin.

    Source

    rotate_at

    fn rotate_at(self: &mut Self, quaternion: Quaternion, center: Point3D)
    

    Appends the rotation of the quaternion about center.

    Source

    rotate_at_prepend

    fn rotate_at_prepend(self: &mut Self, quaternion: Quaternion, center: Point3D)
    

    Prepends the rotation of the quaternion about center.

    Source

    scale

    fn scale(self: &mut Self, scale: Vector3D)
    

    Appends a scale by the components of the vector, about the origin.

    Source

    scale_prepend

    fn scale_prepend(self: &mut Self, scale: Vector3D)
    

    Prepends a scale by the components of the vector, about the origin.

    Source

    scale_at

    fn scale_at(self: &mut Self, scale: Vector3D, center: Point3D)
    

    Appends a scale by the components of the vector, about center.

    Source

    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.

    Source

    translate

    fn translate(self: &mut Self, offset: Vector3D)
    

    Appends a translation by the vector.

    Source

    translate_prepend

    fn translate_prepend(self: &mut Self, offset: Vector3D)
    

    Prepends a translation by the vector.

    Source

    transform

    fn transform(self: &Self, point: Point3D) -> Point3D
    

    The point transformed by the matrix, divided by its w when the matrix is not affine.

    Source

    transform_points

    fn transform_points(self: &Self, points: &mut [Point3D])
    

    Transforms the points in place, as transform.

    Source

    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.

    Source

    transform_vectors

    fn transform_vectors(self: &Self, vectors: &mut [Vector3D])
    

    Transforms the vectors in place, as transform_vector.

    Source

    transform_point4d

    fn transform_point4d(self: &Self, point: Point4D) -> Point4D
    

    The homogeneous point transformed by the whole matrix, without a divide.

    Source

    transform_points4d

    fn transform_points4d(self: &Self, points: &mut [Point4D])
    

    Transforms the homogeneous points in place, as transform_point4d.

    Source

    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.

    Source

    Trait implementations

    • Send
    • Sync
    • Freeze
    • UnsafeUnpin
    • Unpin
    • UnwindSafe
    • RefUnwindSafe
    • Borrow<T>
    • BorrowMut<T>
    • CloneToUninit
    • Into<U>
    • From<T>
    • TryInto<U>
    • TryFrom<U>
    • Any
    • ToOwned
    • ToString
    • PropertyValue
    • AnyValue
    • ClassDefaults
    • ErasedDestructor
    • IntoEither
    • MarkupTyped
    • Clone
    • Copy
    • Debug
    • StructuralPartialEq
    • PartialEq
    • Default
    • Mul
    • MulAssign
    • FromStr
    • Display
    • Mul<Matrix3D>

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.