Matrix Struct

Definition

Represents a 3x3 affine transformation matrix used for transformations in 2-D space.

public value class Matrix : IFormattable
[System.ComponentModel.TypeConverter(typeof(System.Windows.Media.MatrixConverter))]
[System.Serializable]
public struct Matrix : IFormattable
type Matrix = struct
    interface IFormattable
Public Structure Matrix
Implements IFormattable
Inheritance
Matrix
Attributes
Implements

Remarks

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:

M11 M12 0
M21 M22 0
OffsetX OffsetY 1

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.

XAML Attribute Usage

<object property="m11, m12, m21, m22, offsetX, offsetY"/>  
- or -  
<object property="Identity"/>  

XAML Values

m11
System.Double

The value in the first row and first column of this Matrix. For more information, see the M11 property.

m12
System.Double

The value in the first row and second column. For more information, see the M12 property.

m21
System.Double

The value in the second row and first column. For more information, see the M21 property.

m22
System.Double

The value in the second row and second column. For more information, see the M22 property.

offsetX
System.Double

The value in the third row and first column. For more information, see the OffsetX property.

offsetY
System.Double

The value in the third row and second column. For more information, see the OffsetY property.

Constructors

Matrix(Double, Double, Double, Double, Double, Double)

Initializes a new instance of the Matrix structure.

Properties

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.

Methods

Append(Matrix)

Appends the specified Matrix structure to this Matrix structure.

Equals(Matrix)

Determines whether the specified Matrix structure is identical to this instance.

Equals(Matrix, Matrix)

Determines whether the two specified Matrix structures are identical.

Equals(Object)

Determines whether the specified Object is a Matrix structure that is identical to this Matrix.

GetHashCode()

Returns the hash code for this Matrix structure.

Invert()

Inverts this Matrix structure.

Multiply(Matrix, Matrix)

Multiplies a Matrix structure by another Matrix structure.

Parse(String)

Converts a String representation of a matrix into the equivalent Matrix structure.

Prepend(Matrix)

Prepends the specified Matrix structure onto this Matrix structure.

Rotate(Double)

Applies a rotation of the specified angle about the origin of this Matrix structure.

RotateAt(Double, Double, Double)

Rotates this matrix about the specified point.

RotateAtPrepend(Double, Double, Double)

Prepends a rotation of the specified angle at the specified point to this Matrix structure.

RotatePrepend(Double)

Prepends a rotation of the specified angle to this Matrix structure.

Scale(Double, Double)

Appends the specified scale vector to this Matrix structure.

ScaleAt(Double, Double, Double, Double)

Scales this Matrix by the specified amount about the specified point.

ScaleAtPrepend(Double, Double, Double, Double)

Prepends the specified scale about the specified point of this Matrix.

ScalePrepend(Double, Double)

Prepends the specified scale vector to this Matrix structure.

SetIdentity()

Changes this Matrix structure into an identity matrix.

Skew(Double, Double)

Appends a skew of the specified degrees in the x and y dimensions to this Matrix structure.

SkewPrepend(Double, Double)

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.

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(Point[])

Transforms the specified points by this Matrix.

Transform(Vector)

Transforms the specified vector by this Matrix.

Transform(Vector[])

Transforms the specified vectors by this Matrix.

Translate(Double, Double)

Appends a translation of the specified offsets to this Matrix structure.

TranslatePrepend(Double, Double)

Prepends a translation of the specified offsets to this Matrix structure.

Operators

Equality(Matrix, Matrix)

Determines whether the two specified Matrix structures are identical.

Inequality(Matrix, Matrix)

Determines whether the two specified Matrix structures are not identical.

Multiply(Matrix, Matrix)

Multiplies a Matrix structure by another Matrix structure.

Explicit Interface Implementations

IFormattable.ToString(String, IFormatProvider)

Formats the value of the current instance using the specified format.

Applies to

See also