Matrix.SetIdentity Matrix.SetIdentity Matrix.SetIdentity Matrix.SetIdentity Method

定義

將這個 Matrix 結構變更為單位矩陣。Changes this Matrix structure into an identity matrix.

public:
 void SetIdentity();
public void SetIdentity ();
member this.SetIdentity : unit -> unit
Public Sub SetIdentity ()

範例

下列範例顯示如何將Matrix結構轉換成識別矩陣。The following example shows how to turn a Matrix structure into an identity matrix.

private Matrix identityExample()
{

    // Get the identity matrix, which is equal to 
    // (1,0,0,1,0,0). 
    Matrix myMatrix = Matrix.Identity;


    Matrix m = new Matrix(1,0,0,1,0,0);

    return myMatrix;
    
       
}

備註

識別矩陣的值為 1, 係數為 [1, 1], [2, 2], [3, 3], 而在其餘係數中的值為0。An identity matrix has a value of 1 in coefficients [1,1],[2,2],[3,3] and a value of 0 in the rest of the coefficients. 這會與將M11M22設定M21 M12 OffsetY為1、、、和設為0的相互關聯。 OffsetXThis correlates to setting M11 and M22 to 1 and M12, M21, OffsetX, and OffsetY to 0. 在仿射矩陣中, 這是用於Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) Matrix結構的實體系, 係數 [3, 1], [3, 2], [3.3] 隱含為分別為0、0、1的值。In an affine matrix, which is the implementation that Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) uses for the Matrix structure, coefficients [3,1],[3,2],[3.3] are implied to always have the values 0,0,1 respectively.

11 00 00
00 11 00
00 00 11

對於識別矩陣, ToString方法會傳回字串 "identity", 而不是傳回的係數。 MatrixFor an identity matrix, the ToString method returns the string "Identity", instead of the coefficients of the Matrix.

適用於

另請參閱