Matrix Structure
Represents a 3x3 affine transformation matrix used for transformations in 2-D space.
Assembly: WindowsBase (in WindowsBase.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
The Matrix type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | Determinant | Gets the determinant of this Matrix structure. |
![]() | HasInverse | Gets a value that indicates whether this Matrix structure is invertible. |
![]() ![]() | Identity | Gets an identity Matrix. |
![]() | IsIdentity | Gets a value that indicates whether this Matrix structure is an identity matrix. |
![]() | M11 | Gets or sets the value of the first row and first column of this Matrix structure. |
![]() | M12 | Gets or sets the value of the first row and second column of this Matrix structure. |
![]() | M21 | Gets or sets the value of the second row and first column of this Matrix structure. |
![]() | M22 | Gets or sets the value of the second row and second column of this Matrix structure. |
![]() | OffsetX | Gets or sets the value of the third row and first column of this Matrix structure. |
![]() | OffsetY | Gets or sets the value of the third row and second column of this Matrix structure. |
| Name | Description | |
|---|---|---|
![]() | Append | Appends the specified Matrix structure to this Matrix structure. |
![]() | Equals(Matrix) | Determines whether the specified Matrix structure is identical to this instance. |
![]() | Equals(Object) | Determines whether the specified Object is a Matrix structure that is identical to this Matrix. (Overrides ValueType::Equals(Object).) |
![]() ![]() | Equals(Matrix, Matrix) | Determines whether the two specified Matrix structures are identical. |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Returns the hash code for this Matrix structure. (Overrides ValueType::GetHashCode().) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | Invert | Inverts this Matrix structure. |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() ![]() | Multiply | Multiplies a Matrix structure by another Matrix structure. |
![]() ![]() | Parse | Converts a String representation of a matrix into the equivalent Matrix structure. |
![]() | Prepend | Prepends the specified Matrix structure onto this Matrix structure. |
![]() | Rotate | Applies a rotation of the specified angle about the origin of this Matrix structure. |
![]() | RotateAt | Rotates this matrix about the specified point. |
![]() | RotateAtPrepend | Prepends a rotation of the specified angle at the specified point to this Matrix structure. |
![]() | RotatePrepend | Prepends a rotation of the specified angle to this Matrix structure. |
![]() | Scale | Appends the specified scale vector to this Matrix structure. |
![]() | ScaleAt | Scales this Matrix by the specified amount about the specified point. |
![]() | ScaleAtPrepend | Prepends the specified scale about the specified point of this Matrix. |
![]() | ScalePrepend | Prepends the specified scale vector to this Matrix structure. |
![]() | SetIdentity | Changes this Matrix structure into an identity matrix. |
![]() | Skew | Appends a skew of the specified degrees in the x and y dimensions to this Matrix structure. |
![]() | SkewPrepend | Prepends a skew of the specified degrees in the x and y dimensions to this Matrix structure. |
![]() | ToString() | Creates a String representation of this Matrix structure. (Overrides ValueType::ToString().) |
![]() | ToString(IFormatProvider) | Creates a String representation of this Matrix structure with culture-specific formatting information. |
![]() | Transform(Point) | Transforms the specified point by the Matrix and returns the result. |
![]() | Transform(array<Point>) | Transforms the specified points by this Matrix. |
![]() | Transform(Vector) | Transforms the specified vector by this Matrix. |
![]() | Transform(array<Vector>) | Transforms the specified vectors by this Matrix. |
![]() | Translate | Appends a translation of the specified offsets to this Matrix structure. |
![]() | TranslatePrepend | Prepends a translation of the specified offsets to this Matrix structure. |
| Name | Description | |
|---|---|---|
![]() ![]() | Equality | Determines whether the two specified Matrix structures are identical. |
![]() ![]() | Inequality | Determines whether the two specified Matrix structures are not identical. |
![]() ![]() | Multiply | Multiplies a Matrix structure by another Matrix structure. |
| Name | Description | |
|---|---|---|
![]() ![]() | IFormattable::ToString | Formats the value of the current instance using the specified format. |
A 3x3 matrix is used for transformations in a 2-D x-y plane. Affine transformation matrices can be multiplied to form any number of linear transformations, such as rotation and skew (shear), followed by translation. An affine transformation matrix has its final column equal to (0, 0, 1), so only the members in the first two columns need to be specified. Note that vectors are expressed as row-vectors, not column vectors.
A WPF Matrix is stored using row-major order and has the following structure:
The members in the last row, OffsetX and OffsetY, represent translation values.
In methods and properties, the transformation matrix is usually specified as a vector with only six members, as follows:
(M11, M12, M21, M22, OffsetX, OffsetY)
Although you can use a Matrix structure directly to translate individual points, or with a MatrixTransform to transform objects, WPF also provides a set of classes that enable you to transform objects without working directly with matrices: RotateTransform, ScaleTransform, SkewTransform, and TranslateTransform.
This example shows how to use a Matrix to transform Point and Vector objects.
private void transformExamples() { Matrix myMatrix = new Matrix(5, 10, 15, 20, 25, 30); // // Transform a point. // Point myPoint = new Point(15,25); // pointResult is (475, 680). Point pointResult = myMatrix.Transform(myPoint); // // Transform an array of points. // Point[] myPointArray = new Point[] {new Point(15,25), new Point(30,35)}; // myPointArray[0] becomes (475, 680). // myPointArray[1] becomes (700, 1030). myMatrix.Transform(myPointArray); // // Transform a vector. // Vector myVector = new Vector(15,25); // vectorResult becomes (450, 650). Vector vectorResult = myMatrix.Transform(myVector); // // Transform an array of vectors. // Vector[] myVectorArray = new Vector[] {new Vector(15, 25), new Vector(30,35)}; // myVectorArray[0] becomes (450, 650). // myVectorArray[1] becomes (675, 1000). myMatrix.Transform(myVectorArray); }
More Code
| How to: Animate a Matrix by Using Key Frames | This example shows how to animate the Matrix property of a MatrixTransform by using key frames. |
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
