Matrix 結構

定義

表示 3x3 仿射轉換矩陣,可用於 2-D 空間中的轉換。

public value class Matrix : IFormattable
[System.ComponentModel.TypeConverter(typeof(System.Windows.Media.MatrixConverter))]
[System.Serializable]
public struct Matrix : IFormattable
[System.ComponentModel.TypeConverter(typeof(System.Windows.Media.MatrixConverter))]
public struct Matrix : IFormattable
[<System.ComponentModel.TypeConverter(typeof(System.Windows.Media.MatrixConverter))>]
[<System.Serializable>]
type Matrix = struct
    interface IFormattable
[<System.ComponentModel.TypeConverter(typeof(System.Windows.Media.MatrixConverter))>]
type Matrix = struct
    interface IFormattable
Public Structure Matrix
Implements IFormattable
繼承
Matrix
屬性
實作

備註

3x3 矩陣用於平面 2D x-y 平面中的轉換。 仿射轉換矩陣可以相乘來形成任何數目的線性轉換 (例如旋轉與扭曲 (傾斜)),後面再接著轉譯。 affine 轉換矩陣的最終資料行等於 (0, 0, 1) ,因此只需要指定前兩個數據行中的成員。 請注意,向量是以資料列向量表示,而不是資料行向量。

WPF Matrix 會使用資料列主要順序來儲存,並具有下列結構:

M11 M12 0
M21 M22 0
OffsetX OffsetY 1

最後一個資料列 OffsetXOffsetY 中的成員代表翻譯值。

在方法和屬性中,轉換矩陣通常會指定為只有六個成員的向量,如下所示:

(M11, M12, M21, M22, OffsetX, OffsetY)

雖然您可以直接使用 Matrix 結構來轉譯個別點,或搭配 MatrixTransform 來轉換物件,但 WPF 也提供一組類別,讓您不需要直接使用矩陣來轉換物件: RotateTransformScaleTransformSkewTransformTranslateTransform

XAML Attribute Usage

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

XAML 值

m11
System.Double

這個 Matrix 中第一列和第一欄的值。 如需詳細資訊,請參閱 M11 屬性 (Property)。

m12
System.Double

第一個資料列和第二個數據行中的值。 如需詳細資訊,請參閱 M12 屬性 (Property)。

m21
System.Double

第二個數據列和第一個資料行中的值。 如需詳細資訊,請參閱 M21 屬性 (Property)。

m22
System.Double

第二個數據列和第二個數據行中的值。 如需詳細資訊,請參閱 M22 屬性 (Property)。

offsetX
System.Double

第三個數據列和第一個資料行中的值。 如需詳細資訊,請參閱 OffsetX 屬性 (Property)。

offsetY
System.Double

第三個數據列和第二個數據行中的值。 如需詳細資訊,請參閱 OffsetY 屬性 (Property)。

建構函式

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

初始化 Matrix 結構的新執行個體。

屬性

Determinant

取得這個 Matrix 結構的行列式。

HasInverse

取得值,這個值表示這個 Matrix 結構是否可以反轉。

Identity

取得單位 Matrix

IsIdentity

取得值,這個值表示這個 Matrix 結構是否為單位矩陣。

M11

取得或設定這個 Matrix 之結構第一列第一行的值。

M12

取得或設定這個 Matrix 結構之第一列第二行的值。

M21

取得或設定這個 Matrix 結構之第二列第一行的值。

M22

取得或設定這個 Matrix 結構之第二列第二行的值。

OffsetX

取得或設定這個 Matrix 結構之第三列第一行的值。

OffsetY

取得或設定這個 Matrix 結構之第三列第二行的值。

方法

Append(Matrix)

在這個 Matrix 結構之後加上指定的 Matrix 結構。

Equals(Matrix)

判斷指定的 Matrix 結構是否與這個執行個體相同。

Equals(Matrix, Matrix)

判斷兩個指定的 Matrix 結構是否相同。

Equals(Object)

判斷所指定 ObjectMatrix 結構是否與這個 Matrix 相同。

GetHashCode()

傳回這個 Matrix 結構的雜湊程式碼。

Invert()

反轉這個 Matrix 結構。

Multiply(Matrix, Matrix)

Matrix 結構乘以另一個 Matrix 結構。

Parse(String)

將矩陣的 String 表示轉換為對等的 Matrix 結構。

Prepend(Matrix)

在這個 Matrix 結構之前加上指定的 Matrix 結構。

Rotate(Double)

使這個 Matrix 結構繞著原點旋轉指定的角度。

RotateAt(Double, Double, Double)

繞著指定的點旋轉這個矩陣。

RotateAtPrepend(Double, Double, Double)

在這個 Matrix 結構之前加上繞著指定的點進行的所指定角度的旋轉。

RotatePrepend(Double)

在這個 Matrix 結構之前加上所指定角度的旋轉。

Scale(Double, Double)

在這個 Matrix 結構之前加上指定的縮放向量。

ScaleAt(Double, Double, Double, Double)

以指定的點為中心,將這個 Matrix 縮放指定的量。

ScaleAtPrepend(Double, Double, Double, Double)

在這個 Matrix 前面加上以指定的點為中心的所指定縮放。

ScalePrepend(Double, Double)

在這個 Matrix 結構之前加上指定的縮放向量。

SetIdentity()

將這個 Matrix 結構變更為單位矩陣。

Skew(Double, Double)

在這個 Matrix 結構之後加上指定的 X 和 Y 維度度數的扭曲。

SkewPrepend(Double, Double)

在這個 Matrix 結構之前加上指定的 X 和 Y 維度度數的扭曲。

ToString()

建立這個 String 結構的 Matrix 表示。

ToString(IFormatProvider)

使用文化特性特定格式資訊,建立這個 String 結構的 Matrix 表示。

Transform(Point)

Matrix 轉換指定的點,然後傳回結果。

Transform(Point[])

依這個 Matrix 轉換指定的點。

Transform(Vector)

依這個 Matrix 轉換指定的向量。

Transform(Vector[])

依這個 Matrix 轉換指定的向量。

Translate(Double, Double)

在這個 Matrix 結構之後加上所指定位移的轉換。

TranslatePrepend(Double, Double)

在這個 Matrix 結構之前加上所指定位移的轉換。

運算子

Equality(Matrix, Matrix)

判斷兩個指定的 Matrix 結構是否相同。

Inequality(Matrix, Matrix)

判斷兩個指定的 Matrix 結構是否不同。

Multiply(Matrix, Matrix)

Matrix 結構乘以另一個 Matrix 結構。

明確介面實作

IFormattable.ToString(String, IFormatProvider)

使用指定的格式,格式化目前執行個體的值。

適用於

另請參閱