Matrix.Multiply 메서드

정의

지정된 Matrix를 앞에 추가하여 지정된 Matrix를 이 Matrix에 곱합니다.Multiplies this Matrix by the specified Matrix by prepending the specified Matrix.

오버로드

Multiply(Matrix)

지정된 Matrix를 앞에 추가하여 matrix 매개 변수에 지정된 매트릭스를 이 Matrix에 곱합니다.Multiplies this Matrix by the matrix specified in the matrix parameter, by prepending the specified Matrix.

Multiply(Matrix, MatrixOrder)

matrix 매개 변수에 지정된 순서대로 order 매개 변수에 지정된 매트릭스를 이 Matrix에 곱합니다.Multiplies this Matrix by the matrix specified in the matrix parameter, and in the order specified in the order parameter.

Multiply(Matrix)

지정된 Matrix를 앞에 추가하여 matrix 매개 변수에 지정된 매트릭스를 이 Matrix에 곱합니다.Multiplies this Matrix by the matrix specified in the matrix parameter, by prepending the specified Matrix.

public:
 void Multiply(System::Drawing::Drawing2D::Matrix ^ matrix);
public void Multiply (System.Drawing.Drawing2D.Matrix matrix);
member this.Multiply : System.Drawing.Drawing2D.Matrix -> unit

매개 변수

matrix
Matrix

Matrix에 곱할 Matrix입니다.The Matrix by which this Matrix is to be multiplied.

예제

예제를 보려면 Multiply를 참조하세요.For an example, see Multiply.

Multiply(Matrix, MatrixOrder)

matrix 매개 변수에 지정된 순서대로 order 매개 변수에 지정된 매트릭스를 이 Matrix에 곱합니다.Multiplies this Matrix by the matrix specified in the matrix parameter, and in the order specified in the order parameter.

public:
 void Multiply(System::Drawing::Drawing2D::Matrix ^ matrix, System::Drawing::Drawing2D::MatrixOrder order);
public void Multiply (System.Drawing.Drawing2D.Matrix matrix, System.Drawing.Drawing2D.MatrixOrder order);
member this.Multiply : System.Drawing.Drawing2D.Matrix * System.Drawing.Drawing2D.MatrixOrder -> unit

매개 변수

matrix
Matrix

Matrix에 곱할 Matrix입니다.The Matrix by which this Matrix is to be multiplied.

order
MatrixOrder

곱할 순서를 나타내는 MatrixOrder입니다.The MatrixOrder that represents the order of the multiplication.

예제

다음 코드 예제는 Windows Forms에서 사용 하도록 설계 되었으며 필요 PaintEventArgs e, Paint 이벤트 개체입니다.The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, an Paint event object. 이 코드에서는 다음 작업을 수행합니다.The code performs the following actions:

  • 세 개의 행렬을 만듭니다.Creates three matrices.

  • 화면에 행렬 1의 콘텐츠를 나열 합니다.Lists the contents of matrix 1 to the screen.

  • 행렬 2 1 매트릭스를 곱합니다 행렬 1의에서 결과 저장 합니다.Multiplies matrix 1 by matrix 2 and stores the result in matrix 1.

  • 화면에 행렬 1의 콘텐츠를 나열 합니다.Lists the contents of matrix 1 to the screen.

  • 매트릭스 1 3, 매트릭스에에서 저장 된 결과 곱하고 다시 1 행렬에 결과 저장 합니다.Multiplies the result stored in matrix 1 by matrix 3, and again stores the result in matrix 1.

  • 화면에 행렬 1의 콘텐츠를 나열 합니다.Lists the contents of matrix 1 to the screen.

  • (파란색 사각형) 1 매트릭스 변환을 적용 하기 전에 화면에 사각형을 그립니다.Draws a rectangle to the screen prior to applying the matrix 1 transform (the blue rectangle).

  • 변환 사각형에 적용 됩니다.Applies the transform to the rectangle.

  • 이전 사각형과 동일한 좌표를 사용 하 여 화면 (빨간색 사각형)으로 변환된 된 사각형을 그립니다.Draws the transformed rectangle to the screen (the red rectangle), using the same coordinates as the previous rectangle.

표시는 빨간색 사각형 2 가로 방향으로의 비율로 배율 조정 된 후 90도 회전 하 고 y 방향에서 (번역된) 250 지점 x 방향의 및 50 포인트를 이동 합니다.Notice that the red rectangle has been scaled by a factor of two in the horizontal direction, then rotated 90 degrees, and then moved (translated) 250 points in the x direction and 50 points in the y direction.

public:
   void MultiplyExample( PaintEventArgs^ e )
   {
      Pen^ myPen = gcnew Pen( Color::Blue,1.0f );
      Pen^ myPen2 = gcnew Pen( Color::Red,1.0f );

      // Set up the matrices.
      Matrix^ myMatrix1 = gcnew Matrix( 2.0f,0.0f,0.0f,1.0f,0.0f,0.0f );
      Matrix^ myMatrix2 = gcnew Matrix( 0.0f,1.0f,-1.0f,0.0f,0.0f,0.0f );
      Matrix^ myMatrix3 = gcnew Matrix( 1.0f,0.0f,0.0f,1.0f,250.0f,50.0f );

      // Display the elements of the starting matrix.
      ListMatrixElements( e, myMatrix1, "Beginning Matrix", 6, 40 );

      // Multiply Matrix1 by Matrix 2.
      myMatrix1->Multiply( myMatrix2, MatrixOrder::Append );

      // Display the result of the multiplication of Matrix1 and
      // Matrix2.
      ListMatrixElements( e, myMatrix1, "Matrix After 1st Multiplication", 6, 60 );

      // Multiply the result from the previous multiplication by
      // Matrix3.
      myMatrix1->Multiply( myMatrix3, MatrixOrder::Append );

      // Display the result of the previous multiplication
      // multiplied by Matrix3.
      ListMatrixElements1( e, myMatrix1, "Matrix After 2nd Multiplication", 6, 80 );

      // Draw the rectangle prior to transformation.
      e->Graphics->DrawRectangle( myPen, 0, 0, 100, 100 );

      // Make the transformation.
      e->Graphics->Transform = myMatrix1;

      // Draw the rectangle after transformation.
      e->Graphics->DrawRectangle( myPen2, 0, 0, 100, 100 );
   }

   //-------------------------------------------------------
   // The following function is a helper function to
   // list the contents of a matrix.
   //-------------------------------------------------------
   void ListMatrixElements1( PaintEventArgs^ e, Matrix^ matrix, String^ matrixName, int numElements, int y )
   {
      // Set up variables for drawing the array
      // of points to the screen.
      int i;
      float x = 20,X = 200;
      System::Drawing::Font^ myFont = gcnew System::Drawing::Font( "Arial",8 );
      SolidBrush^ myBrush = gcnew SolidBrush( Color::Black );

      // Draw the matrix name to the screen.
      e->Graphics->DrawString( String::Concat( matrixName, ":  " ), myFont, myBrush, (float)x, (float)y );

      // Draw the set of path points and types to the screen.
      for ( i = 0; i < numElements; i++ )
      {
         e->Graphics->DrawString( String::Concat( matrix->Elements[ i ], ", " ), myFont, myBrush, (float)X, (float)y );
         X += 30;
      }
   }
public void MultiplyExample(PaintEventArgs e)
{
    Pen myPen = new Pen(Color.Blue, 1);
    Pen myPen2 = new Pen(Color.Red, 1);
             
    // Set up the matrices.
    Matrix myMatrix1 = new Matrix(
        2.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);  
    
    Matrix myMatrix2 = new Matrix(
        0.0f, 1.0f, -1.0f, 0.0f, 0.0f, 0.0f); 
  
    Matrix myMatrix3 = new Matrix(
        1.0f, 0.0f, 0.0f, 1.0f, 250.0f, 50.0f);  
 
             
    // Display the elements of the starting matrix.
    ListMatrixElements(e, myMatrix1, "Beginning Matrix", 6, 40);
             
    // Multiply Matrix1 by Matrix 2.
    myMatrix1.Multiply(myMatrix2, MatrixOrder.Append);
             
    // Display the result of the multiplication of Matrix1 and
             
    // Matrix2.
    ListMatrixElements(e,
        myMatrix1,
        "Matrix After 1st Multiplication",
        6,
        60);
             
    // Multiply the result from the pervious multiplication by
    // Matrix3.
    myMatrix1.Multiply(myMatrix3, MatrixOrder.Append);
             
    // Display the result of the previous multiplication
    // multiplied by Matrix3.
    ListMatrixElements1(e,
        myMatrix1,
        "Matrix After 2nd Multiplication",
        6,
        80);
             
    // Draw the rectangle prior to transformation.
    e.Graphics.DrawRectangle(myPen, 0, 0, 100, 100);
             
    // Make the transformation.
    e.Graphics.Transform = myMatrix1;
             
    // Draw the rectangle after transformation.
    e.Graphics.DrawRectangle(myPen2, 0, 0, 100, 100);
}
             
//-------------------------------------------------------
// The following function is a helper function to
// list the contents of a matrix.
//-------------------------------------------------------
public void ListMatrixElements1(
    PaintEventArgs e,
    Matrix matrix,
    string matrixName,
    int numElements,
    int y)
{
             
    // Set up variables for drawing the array
    // of points to the screen.
    int i;
    float x = 20, X = 200;
    Font myFont = new Font("Arial", 8);
    SolidBrush myBrush = new SolidBrush(Color.Black);
             
    // Draw the matrix name to the screen.
    e.Graphics.DrawString(
        matrixName + ":  ",
        myFont,
        myBrush,
        x,
        y);
             
    // Draw the set of path points and types to the screen.
    for(i=0; i<numElements; i++)
    {
        e.Graphics.DrawString(
            matrix.Elements[i].ToString() + ", ",
            myFont,
            myBrush,
            X,
            y);
        X += 30;
    }
}
Public Sub MultiplyExample(ByVal e As PaintEventArgs)
    Dim myPen As New Pen(Color.Blue, 1)
    Dim myPen2 As New Pen(Color.Red, 1)

    ' Set up the matrices.
    Dim myMatrix1 As New Matrix(2.0F, 0.0F, 0.0F, 1.0F, 0.0F, 0.0F)

    ' Scale.
    Dim myMatrix2 As New Matrix(0.0F, 1.0F, -1.0F, 0.0F, 0.0F, 0.0F)

    ' Rotate 90.
    Dim myMatrix3 As New Matrix(1.0F, 0.0F, 0.0F, 1.0F, 250.0F, 50.0F)

    ' Display the elements of the starting matrix.
    ListMatrixElementsHelper(e, myMatrix1, "Beginning Matrix", 6, 40)

    ' Multiply Matrix1 by Matrix 2.
    myMatrix1.Multiply(myMatrix2, MatrixOrder.Append)

    ' Display the result of the multiplication of Matrix1 and
    ' Matrix2.
    ListMatrixElementsHelper(e, myMatrix1, _
    "Matrix After 1st Multiplication", 6, 60)

    ' Multiply the result from the pervious multiplication by
    ' Matrix3.
    myMatrix1.Multiply(myMatrix3, MatrixOrder.Append)

    ' Display the result of the previous multiplication
    ' multiplied by Matrix3.
    ListMatrixElementsHelper1(e, myMatrix1, _
    "Matrix After 2nd Multiplication", 6, 80)

    ' Draw the rectangle prior to transformation.
    e.Graphics.DrawRectangle(myPen, 0, 0, 100, 100)
    e.Graphics.Transform = myMatrix1

    ' Draw the rectangle after transformation.
    e.Graphics.DrawRectangle(myPen2, 0, 0, 100, 100)
End Sub

' A helper function to list the contents of a matrix.
Public Sub ListMatrixElementsHelper1(ByVal e As PaintEventArgs, _
ByVal matrix As Matrix, ByVal matrixName As String, ByVal numElements As Integer, _
ByVal y As Integer)

    ' Set up variables for drawing the array

    ' of points to the screen.
    Dim i As Integer
    Dim x As Single = 20
    Dim j As Single = 200
    Dim myFont As New Font("Arial", 8)
    Dim myBrush As New SolidBrush(Color.Black)

    ' Draw the matrix name to the screen.
    e.Graphics.DrawString(matrixName + ":  ", myFont, myBrush, x, y)

    ' Draw the set of path points and types to the screen.
    For i = 0 To numElements - 1
        e.Graphics.DrawString(matrix.Elements(i).ToString() + ", ", _
        myFont, myBrush, j, y)
        j += 30
    Next i
End Sub

설명

지정 된 순서가 PrependMatrix 앞에 붙은 순서로 지정 된 매트릭스를 곱합니다.If the specified order is Prepend, this Matrix is multiplied by the specified matrix in a prepended order. 지정 된 순서가 AppendMatrix 추가 된 순서 대로 지정 된 매트릭스를 곱합니다.If the specified order is Append, this Matrix is multiplied by the specified matrix in an appended order.

적용 대상