Matrix Classe

Definição

Encapsula uma matriz afim 3 por 3 que representa uma transformação geométrica.Encapsulates a 3-by-3 affine matrix that represents a geometric transform. Essa classe não pode ser herdada.This class cannot be inherited.

public ref class Matrix sealed : MarshalByRefObject, IDisposable
public sealed class Matrix : MarshalByRefObject, IDisposable
type Matrix = class
    inherit MarshalByRefObject
    interface IDisposable
Public NotInheritable Class Matrix
Inherits MarshalByRefObject
Implements IDisposable
Herança
Implementações

Comentários

No GDI+, você pode armazenar uma transformação afim em um Matrix objeto.In GDI+ you can store an affine transformation in a Matrix object. Como a terceira coluna de uma matriz que representa uma transformação afim é sempre (0, 0, 1), você especifica apenas seis números nas duas primeiras colunas ao construir um Matrix objeto.Because the third column of a matrix that represents an affine transformation is always (0, 0, 1), you specify only the six numbers in the first two columns when you construct a Matrix object. A instrução Matrix myMatrix = new Matrix(0, 1, -1, 0, 3, 4) constrói a matriz mostrada na figura a seguir.The statement Matrix myMatrix = new Matrix(0, 1, -1, 0, 3, 4) constructs the matrix shown in the following figure.

TransformaçõesTransformations

Transformações de composiçãoComposite Transformations

Uma transformação de composição é uma sequência de transformações, uma seguida da outra.A composite transformation is a sequence of transformations, one followed by the other. Considere as matrizes e transformações na lista a seguir:Consider the matrices and transformations in the following list:

Matriz AMatrix A Girar 90 grausRotate 90 degrees
Matriz BMatrix B Dimensionar por um fator de 2 na direção xScale by a factor of 2 in the x direction
Matriz CMatrix C Mover 3 unidades na direção yTranslate 3 units in the y direction

Se começarmos com o ponto (2, 1) – representado pela matriz [2 1 1]-e multiplicar por a, B, então C, o ponto (2, 1) passará as três transformações na ordem listada.If we start with the point (2, 1) - represented by the matrix [2 1 1] - and multiply by A, then B, then C, the point (2, 1) will undergo the three transformations in the order listed.

[2 1 1]ABC = [-2 5 1][2 1 1]ABC = [-2 5 1]

Em vez de armazenar as três partes da transformação de composição em três matrizes separadas, você pode multiplicar A, B e C juntos para obter uma única matriz 3 × 3 que armazena a transformação de composição inteira.Rather than store the three parts of the composite transformation in three separate matrices, you can multiply A, B, and C together to get a single 3×3 matrix that stores the entire composite transformation. Suponha que a ABC = D. Em seguida, um ponto multiplicado por D fornece o mesmo resultado que um ponto multiplicado por A, B e, em seguida, C.Suppose ABC = D. Then a point multiplied by D gives the same result as a point multiplied by A, then B, then C.

[2 1 1]D = [-2 5 1][2 1 1]D = [-2 5 1]

A ilustração a seguir mostra as matrizes A, B, C e D.The following illustration shows the matrices A, B, C, and D.

TransformaçõesTransformations

O fato de que a matriz de uma transformação composta pode ser formada multiplicando as matrizes de transformação individuais significa que qualquer sequência de transformações afim pode ser armazenada em um único Matrix objeto.The fact that the matrix of a composite transformation can be formed by multiplying the individual transformation matrices means that any sequence of affine transformations can be stored in a single Matrix object.

Cuidado

A ordem de uma transformação de composição é importante.The order of a composite transformation is important. Em geral, girar, dimensionar e converter não é o mesmo que dimensionar, girar e converter.In general, rotate, then scale, then translate is not the same as scale, then rotate, then translate. Da mesma forma, a ordem de multiplicação de matriz é importante.Similarly, the order of matrix multiplication is important. Em geral, ABC não é o mesmo que BAC.In general, ABC is not the same as BAC.

A Matrix classe fornece vários métodos para criar uma transformação composta:,,,, Multiply Rotate RotateAt Scale Shear e Translate .The Matrix class provides several methods for building a composite transformation: Multiply, Rotate, RotateAt, Scale, Shear, and Translate. O exemplo a seguir cria a matriz de uma transformação de composição que primeiro gira 30 graus e, então, é dimensionada por um fator de 2 na direção y e movida em 5 unidades na direção x:The following example creates the matrix of a composite transformation that first rotates 30 degrees, then scales by a factor of 2 in the y direction, and then translates 5 units in the x direction:

Matrix myMatrix = new Matrix();
myMatrix.Rotate(30);
myMatrix.Scale(1, 2, MatrixOrder.Append);
myMatrix.Translate(5, 0, MatrixOrder.Append);
Dim myMatrix As New Matrix()
myMatrix.Rotate(30)
myMatrix.Scale(1, 2, MatrixOrder.Append)
myMatrix.Translate(5, 0, MatrixOrder.Append)

Construtores

Matrix()

Inicializa uma nova instância da classe Matrix como a matriz de identidade.Initializes a new instance of the Matrix class as the identity matrix.

Matrix(Rectangle, Point[])

Inicializa uma nova instância da classe Matrix para a transformação geométrica definida pelo retângulo e matriz de pontos especificados.Initializes a new instance of the Matrix class to the geometric transform defined by the specified rectangle and array of points.

Matrix(RectangleF, PointF[])

Inicializa uma nova instância da classe Matrix para a transformação geométrica definida pelo retângulo e matriz de pontos especificados.Initializes a new instance of the Matrix class to the geometric transform defined by the specified rectangle and array of points.

Matrix(Single, Single, Single, Single, Single, Single)

Inicializa uma nova instância da classe Matrix com os elementos especificados.Initializes a new instance of the Matrix class with the specified elements.

Propriedades

Elements

Obtém uma matriz de valores de ponto flutuante que representa os elementos deste Matrix.Gets an array of floating-point values that represents the elements of this Matrix.

IsIdentity

Obtém um valor que indica se este Matrix é a matriz de identidade.Gets a value indicating whether this Matrix is the identity matrix.

IsInvertible

Obtém um valor que indica se este Matrix pode ser invertido.Gets a value indicating whether this Matrix is invertible.

OffsetX

Obtém o valor de translação de x (o valor de dx ou o elemento na terceira linha e na primeira coluna) deste Matrix.Gets the x translation value (the dx value, or the element in the third row and first column) of this Matrix.

OffsetY

Obtém o valor de translação de y (o valor de dy ou o elemento na terceira linha e na segunda coluna) deste Matrix.Gets the y translation value (the dy value, or the element in the third row and second column) of this Matrix.

Métodos

Clone()

Cria uma cópia exata deste Matrix.Creates an exact copy of this Matrix.

CreateObjRef(Type)

Cria um objeto que contém todas as informações relevantes necessárias para gerar um proxy usado para se comunicar com um objeto remoto.Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(Herdado de MarshalByRefObject)
Dispose()

Libera todos os recursos usados por este Matrix.Releases all resources used by this Matrix.

Equals(Object)

Testa se o objeto especificado é um Matrix e é idêntico a este Matrix.Tests whether the specified object is a Matrix and is identical to this Matrix.

Finalize()

Permite que um objeto tente liberar recursos e executar outras operações de limpeza antes de ser recuperado pela coleta de lixo.Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.

GetHashCode()

Retorna um código hash.Returns a hash code.

GetLifetimeService()
Obsoleto.

Recupera o objeto de serviço de tempo de vida atual que controla a política de ciclo de vida para esta instância.Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(Herdado de MarshalByRefObject)
GetType()

Obtém o Type da instância atual.Gets the Type of the current instance.

(Herdado de Object)
InitializeLifetimeService()
Obsoleto.

Obtém um objeto de serviço de tempo de vida para controlar a política de tempo de vida para essa instância.Obtains a lifetime service object to control the lifetime policy for this instance.

(Herdado de MarshalByRefObject)
Invert()

Inverte esse Matrix, se ele for invertível.Inverts this Matrix, if it is invertible.

MemberwiseClone()

Cria uma cópia superficial do Object atual.Creates a shallow copy of the current Object.

(Herdado de Object)
MemberwiseClone(Boolean)

Cria uma cópia superficial do objeto MarshalByRefObject atual.Creates a shallow copy of the current MarshalByRefObject object.

(Herdado de MarshalByRefObject)
Multiply(Matrix)

Multiplica esse Matrix pela matriz especificada no parâmetro matrix, acrescentando o Matrix especificado.Multiplies this Matrix by the matrix specified in the matrix parameter, by prepending the specified Matrix.

Multiply(Matrix, MatrixOrder)

Multiplica este Matrix pela matriz especificada no parâmetro matrix e na ordem especificada no parâmetro order.Multiplies this Matrix by the matrix specified in the matrix parameter, and in the order specified in the order parameter.

Reset()

Redefine este Matrix para ter os elementos da matriz de identidade.Resets this Matrix to have the elements of the identity matrix.

Rotate(Single)

Preceda a isso Matrix uma rotação no sentido horário ao redor da origem e pelo ângulo especificado.Prepend to this Matrix a clockwise rotation, around the origin and by the specified angle.

Rotate(Single, MatrixOrder)

Aplica uma rotação no sentido horário de um valor especificado no parâmetro angle, em torno da origem (coordenadas x e y zero) para esse Matrix.Applies a clockwise rotation of an amount specified in the angle parameter, around the origin (zero x and y coordinates) for this Matrix.

RotateAt(Single, PointF)

Aplica uma rotação horária a esta Matrix em torno do ponto especificado no parâmetro point e pela precedência da rotação.Applies a clockwise rotation to this Matrix around the point specified in the point parameter, and by prepending the rotation.

RotateAt(Single, PointF, MatrixOrder)

Aplica uma rotação horária em torno do ponto especificado para este Matrix na ordem especificada.Applies a clockwise rotation about the specified point to this Matrix in the specified order.

Scale(Single, Single)

Aplica o vetor de escala especificado a este Matrix acrescentando o vetor de escala.Applies the specified scale vector to this Matrix by prepending the scale vector.

Scale(Single, Single, MatrixOrder)

Aplica o vetor de escala especificado (scaleX e scaleY) a esta Matrix usando a ordem especificada.Applies the specified scale vector (scaleX and scaleY) to this Matrix using the specified order.

Shear(Single, Single)

Aplica o vetor de distorção especificado a este Matrix acrescentando a transformação de distorção.Applies the specified shear vector to this Matrix by prepending the shear transformation.

Shear(Single, Single, MatrixOrder)

Aplica o vetor de distorção especificado a este Matrix na ordem especificada.Applies the specified shear vector to this Matrix in the specified order.

ToString()

Retorna uma cadeia de caracteres que representa o objeto atual.Returns a string that represents the current object.

(Herdado de Object)
TransformPoints(Point[])

Aplica a transformação geométrica representada por este Matrix a uma matriz especificada de pontos.Applies the geometric transform represented by this Matrix to a specified array of points.

TransformPoints(PointF[])

Aplica a transformação geométrica representada por este Matrix a uma matriz especificada de pontos.Applies the geometric transform represented by this Matrix to a specified array of points.

TransformVectors(Point[])

Aplica somente os componentes de escala e rotação deste Matrix à matriz especificada de pontos.Applies only the scale and rotate components of this Matrix to the specified array of points.

TransformVectors(PointF[])

Multiplica cada vetor em uma matriz pela matriz.Multiplies each vector in an array by the matrix. Os elementos de translação da matriz (terceira linha) são ignorados.The translation elements of this matrix (third row) are ignored.

Translate(Single, Single)

Aplica-se do vetor de conversão especificado (offsetX e offsetY) a este Matrix acrescentando o vetor de conversão.Applies the specified translation vector (offsetX and offsetY) to this Matrix by prepending the translation vector.

Translate(Single, Single, MatrixOrder)

Aplica-se o vetor de conversão especificada a este Matrix na ordem especificada.Applies the specified translation vector to this Matrix in the specified order.

VectorTransformPoints(Point[])

Multiplica cada vetor em uma matriz pela matriz.Multiplies each vector in an array by the matrix. Os elementos de translação da matriz (terceira linha) são ignorados.The translation elements of this matrix (third row) are ignored.

Aplica-se a