Struct Matrix
Represents a 3x3 affine transformation matrix used for transformations in two-dimensional space.
Implements
Inherited Members
Namespace: System.Windows.Media
Assembly: OpenSilver.dll
Syntax
public struct Matrix : IFormattable
Constructors
| Improve this Doc View SourceMatrix(Double, Double, Double, Double, Double, Double)
Initializes a Matrix structure.
Declaration
public Matrix(double m11, double m12, double m21, double m22, double offsetX, double offsetY)
Parameters
Type | Name | Description |
---|---|---|
System.Double | m11 | |
System.Double | m12 | |
System.Double | m21 | |
System.Double | m22 | |
System.Double | offsetX | |
System.Double | offsetY |
Properties
| Improve this Doc View SourceDeterminant
Gets the determinant of this Matrix structure.
Declaration
public readonly double Determinant { get; }
Property Value
Type | Description |
---|---|
System.Double | The determinant of this Matrix. |
HasInverse
Gets a value that indicates whether this Matrix structure is invertible.
Declaration
public readonly bool HasInverse { get; }
Property Value
Type | Description |
---|---|
System.Boolean | true if the System.Windows.Media.Matrix has an inverse; otherwise, false. The default is true. |
Identity
Gets an identity Matrix.
Declaration
public static readonly Matrix Identity { get; }
Property Value
Type | Description |
---|---|
Matrix |
IsIdentity
Gets a value that indicates whether this Matrix structure is an identity matrix.
Declaration
public readonly bool IsIdentity { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
M11
Gets or sets the value of the first row and first column of this Matrix structure. The default value is 1.
Declaration
public double M11 { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
M12
Gets or sets the value of the first row and second column of this Matrix structure. The default value is 0.
Declaration
public double M12 { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
M21
Gets or sets the value of the second row and first column of this Matrix structure. The default value is 0.
Declaration
public double M21 { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
M22
Gets or sets the value of the second row and second column of this Matrix structure. The default value is 1.
Declaration
public double M22 { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
OffsetX
Gets or sets the value of the third row and first column of this Matrix structure. The default value is 0.
Declaration
public double OffsetX { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
OffsetY
Gets or sets the value of the third row and second column of this Matrix structure. The default value is 0.
Declaration
public double OffsetY { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
Methods
| Improve this Doc View SourceAppend(Matrix)
Declaration
public void Append(Matrix matrix)
Parameters
Type | Name | Description |
---|---|---|
Matrix | matrix |
Equals(Object)
Determines whether the specified System.Object is a Matrix structure that is identical to this Matrix.
Declaration
public override bool Equals(object o)
Parameters
Type | Name | Description |
---|---|---|
System.Object | o | The System.Object to compare. |
Returns
Type | Description |
---|---|
System.Boolean | true if o is a Matrix structure that is identical to this Matrix structure; otherwise, false. |
Overrides
Equals(Matrix)
Determines whether the specified Matrix structure is identical to this instance.
Declaration
public bool Equals(Matrix value)
Parameters
Type | Name | Description |
---|---|---|
Matrix | value | The instance of Matrix to compare to this instance. |
Returns
Type | Description |
---|---|
System.Boolean | true if instances are equal; otherwise, false. |
Equals(Matrix, Matrix)
Determines whether the two specified Matrix structures are identical.
Declaration
public static bool Equals(Matrix matrix1, Matrix matrix2)
Parameters
Type | Name | Description |
---|---|---|
Matrix | matrix1 | The first Matrix structure to compare. |
Matrix | matrix2 | The second Matrix structure to compare. |
Returns
Type | Description |
---|---|
System.Boolean | true if matrix1 and matrix2 are identical; otherwise, false. |
GetHashCode()
Returns the hash code for this Matrix structure.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 | The hash code for this instance. |
Overrides
Invert()
Inverts this Matrix structure.
Declaration
public void Invert()
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | The Matrix structure is not invertible. |
Multiply(Matrix, Matrix)
Declaration
public static Matrix Multiply(Matrix trans1, Matrix trans2)
Parameters
Type | Name | Description |
---|---|---|
Matrix | trans1 | The first Matrix structure to multiply. |
Matrix | trans2 | The second Matrix structure to multiply. |
Returns
Type | Description |
---|---|
Matrix | The result of multiplying trans1 by trans2. |
Parse(String)
Converts a System.String representation of a matrix into the equivalent Matrix structure.
Declaration
public static Matrix Parse(string source)
Parameters
Type | Name | Description |
---|---|---|
System.String | source | The System.String representation of the matrix. |
Returns
Type | Description |
---|---|
Matrix | The equivalent Matrix structure. |
Prepend(Matrix)
Declaration
public void Prepend(Matrix matrix)
Parameters
Type | Name | Description |
---|---|---|
Matrix | matrix |
Rotate(Double)
Applies a rotation of the specified angle about the origin of this Matrix structure.
Declaration
public void Rotate(double angle)
Parameters
Type | Name | Description |
---|---|---|
System.Double | angle | The angle of rotation. |
RotateAt(Double, Double, Double)
Rotates this matrix about the specified point.
Declaration
public void RotateAt(double angle, double centerX, double centerY)
Parameters
Type | Name | Description |
---|---|---|
System.Double | angle | The angle, in degrees, by which to rotate this matrix. |
System.Double | centerX | The x-coordinate of the point about which to rotate this matrix. |
System.Double | centerY | The y-coordinate of the point about which to rotate this matrix. |
RotateAtPrepend(Double, Double, Double)
Prepends a rotation of the specified angle at the specified point to this Matrix structure.
Declaration
public void RotateAtPrepend(double angle, double centerX, double centerY)
Parameters
Type | Name | Description |
---|---|---|
System.Double | angle | The rotation angle, in degrees. |
System.Double | centerX | The x-coordinate of the rotation center. |
System.Double | centerY | The y-coordinate of the rotation center. |
RotatePrepend(Double)
Prepends a rotation of the specified angle to this Matrix structure.
Declaration
public void RotatePrepend(double angle)
Parameters
Type | Name | Description |
---|---|---|
System.Double | angle | The angle of rotation to prepend. |
Scale(Double, Double)
Appends the specified scale vector to this Matrix structure.
Declaration
public void Scale(double scaleX, double scaleY)
Parameters
Type | Name | Description |
---|---|---|
System.Double | scaleX | The value by which to scale this Matrix along the x-axis. |
System.Double | scaleY | The value by which to scale this Matrix along the y-axis. |
ScaleAtPrepend(Double, Double, Double, Double)
Prepends the specified scale about the specified point of this Matrix.
Declaration
public void ScaleAtPrepend(double scaleX, double scaleY, double centerX, double centerY)
Parameters
Type | Name | Description |
---|---|---|
System.Double | scaleX | The x-axis scale factor. |
System.Double | scaleY | The y-axis scale factor. |
System.Double | centerX | The x-coordinate of the point about which the scale operation is performed. |
System.Double | centerY | The y-coordinate of the point about which the scale operation is performed. |
ScalePrepend(Double, Double)
Prepends the specified scale vector to this Matrix structure.
Declaration
public void ScalePrepend(double scaleX, double scaleY)
Parameters
Type | Name | Description |
---|---|---|
System.Double | scaleX | The value by which to scale this Matrix structure along the x-axis. |
System.Double | scaleY | The value by which to scale this Matrix structure along the y-axis. |
SetIdentity()
Changes this Matrix structure into an identity matrix.
Declaration
public void SetIdentity()
Skew(Double, Double)
Appends a skew of the specified degrees in the x and y dimensions to this Matrix structure.
Declaration
public void Skew(double skewX, double skewY)
Parameters
Type | Name | Description |
---|---|---|
System.Double | skewX | The angle in the x dimension by which to skew this Matrix. |
System.Double | skewY | The angle in the y dimension by which to skew this Matrix. |
SkewPrepend(Double, Double)
Prepends a skew of the specified degrees in the x and y dimensions to this Matrix structure.
Declaration
public void SkewPrepend(double skewX, double skewY)
Parameters
Type | Name | Description |
---|---|---|
System.Double | skewX | The angle in the x dimension by which to skew this Matrix. |
System.Double | skewY | The angle in the y dimension by which to skew this Matrix. |
ToString()
Creates a System.String representation of this Matrix structure.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | A System.String containing the M11, M12, M21, M22, OffsetX, and OffsetY values of this Matrix. |
Overrides
ToString(IFormatProvider)
Creates a System.String representation of this Matrix structure with culture-specific formatting information.
Declaration
public string ToString(IFormatProvider provider)
Parameters
Type | Name | Description |
---|---|---|
System.IFormatProvider | provider | The culture-specific formatting information. |
Returns
Type | Description |
---|---|
System.String | A System.String containing the M11, M12, M21, M22, OffsetX, and OffsetY values of this Matrix. |
Transform(Point)
Transforms the specified point by the Matrix and returns the result.
Declaration
public Point Transform(Point point)
Parameters
Type | Name | Description |
---|---|---|
Point | point | The point to transform. |
Returns
Type | Description |
---|---|
Point | The result of transforming point by this Matrix. |
Transform(Point[])
Transforms the specified points by this Matrix.
Declaration
public void Transform(Point[] points)
Parameters
Type | Name | Description |
---|---|---|
Point[] | points | The points to transform. The original points in the array are replaced by their transformed values. |
Transform(Vector)
Transforms the specified vector by this Matrix.
Declaration
public Vector Transform(Vector vector)
Parameters
Type | Name | Description |
---|---|---|
Vector | vector | The vector to transform. |
Returns
Type | Description |
---|---|
Vector | The result of transforming vector by this Matrix. |
Transform(Vector[])
Transforms the specified vectors by this Matrix.
Declaration
public void Transform(Vector[] vectors)
Parameters
Type | Name | Description |
---|---|---|
Vector[] | vectors | The vectors to transform. The original vectors in the array are replaced by their transformed values. |
Translate(Double, Double)
Appends a translation of the specified offsets to this Matrix structure.
Declaration
public void Translate(double offsetX, double offsetY)
Parameters
Type | Name | Description |
---|---|---|
System.Double | offsetX | The amount to offset this Matrix along the x-axis. |
System.Double | offsetY | The amount to offset this Matrix along the y-axis. |
TranslatePrepend(Double, Double)
Prepends a translation of the specified offsets to this Matrix structure.
Declaration
public void TranslatePrepend(double offsetX, double offsetY)
Parameters
Type | Name | Description |
---|---|---|
System.Double | offsetX | The amount to offset this Matrix along the x-axis. |
System.Double | offsetY | The amount to offset this Matrix along the y-axis. |
Operators
| Improve this Doc View SourceEquality(Matrix, Matrix)
Declaration
public static bool operator ==(Matrix matrix1, Matrix matrix2)
Parameters
Type | Name | Description |
---|---|---|
Matrix | matrix1 | |
Matrix | matrix2 |
Returns
Type | Description |
---|---|
System.Boolean |
Inequality(Matrix, Matrix)
Declaration
public static bool operator !=(Matrix matrix1, Matrix matrix2)
Parameters
Type | Name | Description |
---|---|---|
Matrix | matrix1 | |
Matrix | matrix2 |
Returns
Type | Description |
---|---|
System.Boolean |
Multiply(Matrix, Matrix)
Declaration
public static Matrix operator *(Matrix trans1, Matrix trans2)
Parameters
Type | Name | Description |
---|---|---|
Matrix | trans1 | The first Matrix structure to multiply. |
Matrix | trans2 | The second Matrix structure to multiply. |
Returns
Type | Description |
---|---|
Matrix | The result of multiplying trans1 by trans2. |
Explicit Interface Implementations
| Improve this Doc View SourceIFormattable.ToString(String, IFormatProvider)
Creates a string representation of this object based on the format string and IFormatProvider passed in. If the provider is null, the CurrentCulture is used. See the documentation for IFormattable for more information.
Declaration
string IFormattable.ToString(string format, IFormatProvider provider)
Parameters
Type | Name | Description |
---|---|---|
System.String | format | |
System.IFormatProvider | provider |
Returns
Type | Description |
---|---|
System.String | A string representation of this object. |