Skip to main content

Matrix Structure

A 3x3 matrix.

Definition

Namespace: Avalonia
Assembly: Avalonia.Base (in Avalonia.Base.dll)

public readonly struct Matrix : IEquatable<Matrix>
View Source
InheritanceObjectValueType → Matrix
ImplementsIEquatable(Matrix)

Remarks

Matrix layout: | 1st col | 2nd col | 3r col | 1st row | scaleX | skewY | perspX | 2nd row | skewX | scaleY | perspY | 3rd row | transX | transY | perspZ | Note: Skia.SkMatrix uses a transposed layout (where for example skewX/skewY and persp0/transX are swapped).

Constructors

Matrix(Double, Double, Double, Double, Double, Double)Initializes a new instance of the Matrix struct (equivalent to a 2x3 Matrix without perspective).
Matrix(Double, Double, Double, Double, Double, Double, Double, Double, Double)Initializes a new instance of the Matrix struct.

Properties

HasInverseHasInverse Property - returns true if this matrix is invertible, false otherwise.
IdentityReturns the multiplicative identity matrix.
IsIdentityReturns whether the matrix is the identity matrix.
M11The first element of the first row (scaleX).
M12The second element of the first row (skewY).
M13The third element of the first row (perspX: input x-axis perspective factor).
M21The first element of the second row (skewX).
M22The second element of the second row (scaleY).
M23The third element of the second row (perspY: input y-axis perspective factor).
M31The first element of the third row (offsetX/translateX).
M32The second element of the third row (offsetY/translateY).
M33The third element of the third row (perspZ: perspective scale factor).

Methods

Append(Matrix)Appends another matrix as post-multiplication operation. Equivalent to this * value;
ContainsPerspective()Determines if the current matrix contains perspective (non-affine) transforms (true) or only (affine) transforms that could be mapped into an 2x3 matrix (false).
CreateRotation(Double)Creates a rotation matrix using the given rotation in radians.
CreateScale(Vector)Creates a scale matrix from the given vector scale.
CreateScale(Double, Double)Creates a scale matrix from the given X and Y components.
CreateSkew(Double, Double)Creates a skew matrix from the given axis skew angles in radians.
CreateTranslation(Vector)Creates a translation matrix from the given vector.
CreateTranslation(Double, Double)Creates a translation matrix from the given X and Y components.
Equals(Matrix)Returns a boolean indicating whether the matrix is equal to the other given matrix.
Equals(Object)Returns a boolean indicating whether the given Object is equal to this matrix instance.
(Overrides ValueType.Equals(Object))
GetDeterminant()Calculates the determinant for this matrix.
GetHashCode()Returns the hash code for this instance.
(Overrides ValueType.GetHashCode())
GetType()Gets the Type of the current instance.
(Inherited from Object)
Invert()Inverts the Matrix.
Parse(String)Parses a Matrix string.
Prepend(Matrix)Prepends another matrix as pre-multiplication operation. Equivalent to value * this;
ToRadians(Double)Converts an angle in degrees to radians.
ToString()Returns a String representing this matrix instance.
(Overrides ValueType.ToString())
Transform(Point)Transforms the point with the matrix
TryDecomposeTransform(Matrix, Matrix.Decomposed)Decomposes given matrix into transform operations.
TryInvert(Matrix)Attempts to invert the Matrix.

Operators

Equality(Matrix, Matrix)Returns a boolean indicating whether the given matrices are equal.
Inequality(Matrix, Matrix)Returns a boolean indicating whether the given matrices are not equal.
Multiply(Matrix, Matrix)Multiplies two matrices together and returns the resulting matrix.
UnaryNegation(Matrix)Negates the given matrix by multiplying all values by -1.

Extension Methods

ToSKMatrix()
(Defined by SkiaSharpExtensions)

See Also

Reference

Avalonia Namespace