# Transform

## Introduction

vtkTransform describes linear transformations via a 4x4 matrix.

A vtkTransform can be used to describe the full range of linear (also known as affine) coordinate transformations in three dimensions, which are internally represented as a 4x4 homogeneous transformation matrix. When you create a new vtkTransform, it is always initialized to the identity transformation.

Most of the methods for manipulating this transformation (e.g. transformMatrices, transformMatrix) (TODO: Translate, Rotate, Concatenate…) can operate in either PreMultiply (the default) or PostMultiply mode. In PreMultiply mode, the translation, concatenation, etc. will occur before any transformations which are represented by the current matrix. In PostMultiply mode, the additional transformation will occur after any transformations represented by the current matrix.

This class performs all of its operations in a right handed coordinate system with right handed rotations. Some other graphics libraries use left handed coordinate systems and rotations.

## Methods

### extend

Method used to decorate a given object (publicAPI+model) with vtkTransform characteristics.

Argument Type Required Description
`publicAPI` Yes object on which methods will be bounds (public)
`model` Yes object on which data structure will be bounds (protected)
`initialValues` ITransformInitialValues No (default: {})

### getInverse

#### Returns

Type Description
A new transform with an inversed internal matrix. Also copy the premultiply flag @see getPreMultiplyFlag.

### getMatrix

Mat4 matrix, used by vtkTransform to transform points, vertices, matrices…
Default is identity.

### getPreMultiplyFlag

The value of preMultiplyFlag indicates how matrix multiplications should occur.

When in premultiply mode:
All subsequent operations will occur before those already represented in the current transformation.
In homogeneous matrix notation, M = M*A where M is the current transformation matrix and A is the applied matrix.

When in postmultiply mode:
All subsequent operations will occur after those already represented in the current transformation.
In homogeneous matrix notation, M = A*M where M is the current transformation matrix and A is the applied matrix.

This flag is also used in @see transformMatrix and @see transformMatrices to indicate how transform is applied to matrices:
Premultiply: O_i = M * A_i
Postmultiply: O_i = A_i * M
where M is the current transformation matrix, A_i are the matrices in argument, O_i are the output matrices.

The default is PreMultiply.

### newInstance

Method used to create a new instance of vtkTransform.

Argument Type Required Description
`initialValues` ITransformInitialValues No for pre-setting some of its content

### postMultiply

Set preMultiplyFlag to false

### preMultiply

Set preMultiplyFlag to true

### setMatrix

Argument Type Required Description
`e00` Yes
`e01` Yes
`e02` Yes
`e03` Yes
`e10` Yes
`e11` Yes
`e12` Yes
`e13` Yes
`e20` Yes
`e21` Yes
`e22` Yes
`e23` Yes
`e30` Yes
`e31` Yes
`e32` Yes
`e33` Yes

### setMatrix

Argument Type Required Description
`matrix` mat4 Yes

### setPreMultiplyFlag

Argument Type Required Description
`preMultiplyFlag` Yes

### transformMatrices

Transform multiple matrices using the internal transform matrix
Modify the out array only

Argument Type Required Description
`matrices` Yes An array (typed or not) containing n*16 elements or of shape (n, 16)
`out` Yes An array (typed or not) containing n*16 elements or of shape (n, 16)

### transformMatrix

Transform a single matrix using the internal transform matrix
The resulting matrix is:
Mout = M * Min when in premultiply mode
Mout = Min * M when in postmultiply mode

Argument Type Required Description
`matrix` Yes The matrix to transform, is not modified (except if matrix === out)
`out` Yes The receiving output matrix, is modified, can be the same as matrix

#### Returns

Type Description
The out parameter

### transformPoint

Transform a single point using the internal transform matrix
The resulting point is: Pout = M * Pin where M is the internal matrix, Pin and Pout the in and out points

Argument Type Required Description
`point` Yes The point to transform, is not modified (except if point === out)
`out` Yes The receiving output point, is modified, can be the same as point

#### Returns

Type Description
The out parameter

### transformPoints

Transform multiple points using the internal transform matrix
`points` Yes An array (typed or not) containing n*3 elements or of shape (n, 3)
`out` Yes An array (typed or not) containing n*3 elements or of shape (n, 3)