Show / Hide Table of Contents

Struct Matrix

Represents a 3x3 affine transformation matrix used for transformations in two-dimensional space.

Implements
System.IFormattable
Inherited Members
System.Object.Equals(System.Object, System.Object)
System.Object.GetType()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: System.Windows.Media
Assembly: OpenSilver.dll
Syntax
public struct Matrix : IFormattable

Constructors

| Improve this Doc View Source

Matrix(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

The Matrix structure's M11 coefficient.

System.Double m12

The Matrix structure's M12 coefficient.

System.Double m21

The Matrix structure's M21 coefficient.

System.Double m22

The Matrix structure's M22 coefficient.

System.Double offsetX

The Matrix structure's OffsetX coefficient.

System.Double offsetY

The Matrix structure's OffsetY coefficient.

Properties

| Improve this Doc View Source

Determinant

Gets the determinant of this Matrix structure.

Declaration
public readonly double Determinant { get; }
Property Value
Type Description
System.Double

The determinant of this Matrix.

| Improve this Doc View Source

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.

| Improve this Doc View Source

Identity

Gets an identity Matrix.

Declaration
public static readonly Matrix Identity { get; }
Property Value
Type Description
Matrix
| Improve this Doc View Source

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
| Improve this Doc View Source

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
| Improve this Doc View Source

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
| Improve this Doc View Source

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
| Improve this Doc View Source

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
| Improve this Doc View Source

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
| Improve this Doc View Source

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 Source

Append(Matrix)

Appends the specified Matrix structure to this Matrix structure.

Declaration
public void Append(Matrix matrix)
Parameters
Type Name Description
Matrix matrix

The Matrix structure to append to this Matrix structure.

| Improve this Doc View Source

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
System.ValueType.Equals(System.Object)
| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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
System.ValueType.GetHashCode()
| Improve this Doc View Source

Invert()

Inverts this Matrix structure.

Declaration
public void Invert()
Exceptions
Type Condition
System.InvalidOperationException

The Matrix structure is not invertible.

| Improve this Doc View Source

Multiply(Matrix, Matrix)

Multiplies a Matrix structure by another Matrix structure.

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

Prepend(Matrix)

Prepends the specified Matrix structure onto this Matrix structure.

Declaration
public void Prepend(Matrix matrix)
Parameters
Type Name Description
Matrix matrix

The Matrix structure to prepend to this Matrix structure.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

SetIdentity()

Changes this Matrix structure into an identity matrix.

Declaration
public void SetIdentity()
| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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
System.ValueType.ToString()
| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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 Source

Equality(Matrix, Matrix)

Declaration
public static bool operator ==(Matrix matrix1, Matrix matrix2)
Parameters
Type Name Description
Matrix matrix1
Matrix matrix2
Returns
Type Description
System.Boolean
| Improve this Doc View Source

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
| Improve this Doc View Source

Multiply(Matrix, Matrix)

Multiplies a Matrix structure by another Matrix structure.

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 Source

IFormattable.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.

Implements

System.IFormattable
  • Improve this Doc
  • View Source