pub struct Matrix {
pub m11: f64,
pub m12: f64,
pub m13: f64,
pub m21: f64,
pub m22: f64,
pub m23: f64,
pub m31: f64,
pub m32: f64,
pub m33: f64,
}Expand description
A 3x3 matrix.
Matrix layout:
| 1st col | 2nd col | 3rd col |
1st row | scaleX | skewY | perspX |
2nd row | skewX | scaleY | perspY |
3rd row | transX | transY | perspZ |Note: the default value is the all-zero matrix, not the identity.
Fields§
§m11: f64The first element of the first row (scaleX).
m12: f64The second element of the first row (skewY).
m13: f64The third element of the first row (perspX).
m21: f64The first element of the second row (skewX).
m22: f64The second element of the second row (scaleY).
m23: f64The third element of the second row (perspY).
m31: f64The first element of the third row (offsetX/translateX).
m32: f64The second element of the third row (offsetY/translateY).
m33: f64The third element of the third row (perspZ).
Implementations§
Source§impl Matrix
impl Matrix
Sourcepub const fn new(
scale_x: f64,
skew_y: f64,
skew_x: f64,
scale_y: f64,
offset_x: f64,
offset_y: f64,
) -> Self
pub const fn new( scale_x: f64, skew_y: f64, skew_x: f64, scale_y: f64, offset_x: f64, offset_y: f64, ) -> Self
Initializes an affine Matrix (the third column is 0, 0, 1).
Sourcepub const fn new_3x3(
scale_x: f64,
skew_y: f64,
persp_x: f64,
skew_x: f64,
scale_y: f64,
persp_y: f64,
offset_x: f64,
offset_y: f64,
persp_z: f64,
) -> Self
pub const fn new_3x3( scale_x: f64, skew_y: f64, persp_x: f64, skew_x: f64, scale_y: f64, persp_y: f64, offset_x: f64, offset_y: f64, persp_z: f64, ) -> Self
Initializes a full 3x3 Matrix, given in row order.
Sourcepub fn is_identity(&self) -> bool
pub fn is_identity(&self) -> bool
Returns whether the matrix is the multiplicative identity matrix or not.
Sourcepub fn has_inverse(&self) -> bool
pub fn has_inverse(&self) -> bool
Returns whether the matrix has an inverse.
Sourcepub fn create_rotation(radians: f64) -> Matrix
pub fn create_rotation(radians: f64) -> Matrix
Creates a rotation matrix using the given rotation in radians.
Sourcepub fn create_rotation_at(radians: f64, center: Point) -> Matrix
pub fn create_rotation_at(radians: f64, center: Point) -> Matrix
Creates a rotation matrix using the given rotation in radians around a center point.
Sourcepub fn create_skew(x_angle: f64, y_angle: f64) -> Matrix
pub fn create_skew(x_angle: f64, y_angle: f64) -> Matrix
Creates a skew matrix from the given axis skew angles in radians.
Sourcepub const fn create_scale(x_scale: f64, y_scale: f64) -> Matrix
pub const fn create_scale(x_scale: f64, y_scale: f64) -> Matrix
Creates a scale matrix from the given X and Y components.
Sourcepub const fn create_scale_vector(scales: Vector) -> Matrix
pub const fn create_scale_vector(scales: Vector) -> Matrix
Creates a scale matrix from the given vector scale.
Sourcepub const fn create_translation_vector(position: Vector) -> Matrix
pub const fn create_translation_vector(position: Vector) -> Matrix
Creates a translation matrix from the given vector.
Sourcepub const fn create_translation(x_position: f64, y_position: f64) -> Matrix
pub const fn create_translation(x_position: f64, y_position: f64) -> Matrix
Creates a translation matrix from the given X and Y components.
Sourcepub fn to_radians(angle: f64) -> f64
pub fn to_radians(angle: f64) -> f64
Converts an angle in degrees to radians.
Sourcepub fn append(&self, value: Matrix) -> Matrix
pub fn append(&self, value: Matrix) -> Matrix
Appends another matrix as post-multiplication operation.
Equivalent to self * value.
Sourcepub fn prepend(&self, value: Matrix) -> Matrix
pub fn prepend(&self, value: Matrix) -> Matrix
Prepends another matrix as pre-multiplication operation.
Equivalent to value * self.
Sourcepub fn get_determinant(&self) -> f64
pub fn get_determinant(&self) -> f64
Calculates the determinant for this matrix.
Sourcepub fn equals(&self, other: Matrix) -> bool
pub fn equals(&self, other: Matrix) -> bool
Returns a boolean indicating whether the matrix is equal to the other given matrix (exact comparison of every element).
Sourcepub fn contains_perspective(&self) -> bool
pub fn contains_perspective(&self) -> bool
Determines if the current matrix contains perspective (non-affine) transforms.
Sourcepub fn try_invert(&self) -> Option<Matrix>
pub fn try_invert(&self) -> Option<Matrix>
Attempts to invert the matrix. Returns None when it is not invertible.
Sourcepub fn invert(&self) -> Matrix
pub fn invert(&self) -> Matrix
Inverts the matrix.
§Panics
Panics if the matrix is not invertible; use try_invert
when that is a possibility.
Sourcepub fn parse(s: &str) -> Result<Self, FormatError>
pub fn parse(s: &str) -> Result<Self, FormatError>
Parses a Matrix string: six (affine) or nine comma/space separated values.
Nine values are given in the order m11, m12, m21, m22, m31, m32, m13, m23, m33.
Sourcepub fn try_decompose_transform(matrix: Matrix) -> Option<MatrixDecomposed>
pub fn try_decompose_transform(matrix: Matrix) -> Option<MatrixDecomposed>
Decomposes the given matrix into translation, rotation, scale and skew.
Returns None for singular matrices and matrices containing perspective.
Trait Implementations§
Source§impl BatchValue for Matrix
impl BatchValue for Matrix
impl Copy for Matrix
Source§impl ExpressionVariantValue for Matrix
impl ExpressionVariantValue for Matrix
Source§const FFI_VARIANT_TYPE: Option<VariantType> = None
const FFI_VARIANT_TYPE: Option<VariantType> = None
None when the type cannot be a foreign function parameter.Source§fn try_from_variant(v: &ExpressionVariant) -> Option<Self>
fn try_from_variant(v: &ExpressionVariant) -> Option<Self>
Source§fn into_variant(self) -> ExpressionVariant
fn into_variant(self) -> ExpressionVariant
Source§impl From<Matrix> for ExpressionVariant
impl From<Matrix> for ExpressionVariant
Source§fn from(value: Matrix) -> ExpressionVariant
fn from(value: Matrix) -> ExpressionVariant
Source§impl MarkupTyped for Matrix
impl MarkupTyped for Matrix
Source§const MARKUP: &'static MarkupType
const MARKUP: &'static MarkupType
Source§impl MulAssign for Matrix
impl MulAssign for Matrix
Source§fn mul_assign(&mut self, value: Matrix)
fn mul_assign(&mut self, value: Matrix)
*= operation. Read moreSource§impl MulAssign<Matrix> for Point
impl MulAssign<Matrix> for Point
Source§fn mul_assign(&mut self, matrix: Matrix)
fn mul_assign(&mut self, matrix: Matrix)
*= operation. Read moreSource§impl Neg for Matrix
Negation is defined as inversion of the matrix.
impl Neg for Matrix
Negation is defined as inversion of the matrix.
§Panics
Panics if the matrix is not invertible.
Source§impl ServerPropertyValue for Matrix
impl ServerPropertyValue for Matrix
impl StructuralPartialEq for Matrix
Auto Trait Implementations§
impl Freeze for Matrix
impl RefUnwindSafe for Matrix
impl Send for Matrix
impl Sync for Matrix
impl Unpin for Matrix
impl UnsafeUnpin for Matrix
impl UnwindSafe for Matrix
Blanket Implementations§
Source§impl<T> AnyValue for Twhere
T: PartialEq + 'static,
impl<T> AnyValue for Twhere
T: PartialEq + 'static,
fn any_value_as_any(&self) -> &(dyn Any + 'static)
fn any_value_eq(&self, other: &(dyn AnyValue + 'static)) -> bool
fn any_value_type_name(&self) -> &'static str
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> ClassDefaults for Twhere
T: ?Sized,
impl<T> ClassDefaults for Twhere
T: ?Sized,
Source§fn static_constructor()
fn static_constructor()
affects_render, metadata
overrides). Read more