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.
Usage
import vtkTransform from '@kitware/vtk.js/Common/Transform/Transform'; |
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
rotateWXYZ
Create a rotation matrix and concatenate it with the current transformation
according to preMultiply or postMultiply semantics.
The angle is expressed in degrees.
Argument | Type | Required | Description |
---|---|---|---|
angle |
Number | Yes | Angle in degrees |
x |
Number | Yes | X component of the rotation axis |
y |
Number | Yes | Y component of the rotation axis |
z |
Number | Yes | Z component of the rotation axis |
rotateX
Create a rotation matrix and concatenate it with the current transformation
according to preMultiply or postMultiply semantics.
The angle is expressed in degrees.
Argument | Type | Required | Description |
---|---|---|---|
angle |
Number | Yes | Angle in degrees |
rotateY
Create a rotation matrix about the X, Y, or Z axis and concatenate it with
the current transformation according to preMultiply or postMultiply
semantics.
Argument | Type | Required | Description |
---|---|---|---|
angle |
Number | Yes | Angle in degrees |
rotateZ
Create a rotation matrix about the X, Y, or Z axis and concatenate it with
the current transformation according to preMultiply or postMultiply
semantics.
Argument | Type | Required | Description |
---|---|---|---|
angle |
Number | Yes | Angle in degrees |
scale
Create a scale matrix (i.e. set the diagonal elements to x, y, z) and
concatenate it with the current transformation according to preMultiply or
postMultiply semantics.
Argument | Type | Required | Description |
---|---|---|---|
x |
Number | Yes | Diagonal element for X axis |
y |
Number | Yes | Diagonal element for Y axis |
z |
Number | Yes | Diagonal element for Z axis |
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
See @see transformMatrix for more info
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 |
transformNormal
Apply the transformation to a normal.
Argument | Type | Required | Description |
---|---|---|---|
inNormal |
vec3 | Yes | The normal vector to transform |
outNormal |
vec3 | Yes | The output vector |
Returns
Type | Description |
---|---|
vec3 | The transformed normal vector |
transformNormals
Apply the transformation to a series of normals, and append the results to
outNormals.
Argument | Type | Required | Description |
---|---|---|---|
inNormals |
vtkDataArray | Yes | The normal vectors to transform |
outNormals |
vtkDataArray | Yes | The output array |
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
See @see transformPoint for more info
Modify the out array only
Argument | Type | Required | Description |
---|---|---|---|
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) |
transformPointsNormalsVectors
Transform points, normals, and vectors simultaneously.
Argument | Type | Required | Description |
---|---|---|---|
inPoints |
vtkPoints | Yes | Input points |
outPoints |
vtkPoints | Yes | Output points |
inNormals |
vtkDataArray | Yes | Input normals |
outNormals |
vtkDataArray | Yes | Output normals |
inVectors |
vtkDataArray | Yes | Input vectors |
outVectors |
vtkDataArray | Yes | Output vectors |
inVectorsArr |
Array |
Yes | Optional input vectors arrays |
outVectorsArr |
Array |
Yes | Optional output vectors arrays |
transformVector
Apply the transformation to a vector.
Argument | Type | Required | Description |
---|---|---|---|
inVector |
vec3 | Yes | The vector to transform |
outVector |
vec3 | Yes | The output vector |
matrix=null |
mat3 | No | if null (default), the Transform matrix is being used. |
Returns
Type | Description |
---|---|
vec3 | The transformed vector |
transformVectors
Apply the transformation to a series of vectors, and append the results to
outVectors.
Argument | Type | Required | Description |
---|---|---|---|
inVectors |
vtkDataArray | Yes | The vectors to transform |
outVectors |
vtkDataArray | Yes | The output array |
translate
Create a translation matrix and concatenate it with the current
transformation according to preMultiply or postMultiply semantics.
Argument | Type | Required | Description |
---|---|---|---|
x |
Number | Yes | X component of the translation |
y |
Number | Yes | Y component of the translation |
z |
Number | Yes | Z component of the translation |
Source
import { mat3, mat4, vec3 } from 'gl-matrix'; |
import macro from 'vtk.js/Sources/macros'; |