Introduction
The vtkMatrixBuilder
class provides a system to create a mat4
transformation matrix. All functions return the MatrixBuilder Object
instance, allowing transformations to be chained.
Usage
let point = [2,5,12]; |
The vtkMatrixBuilder class has two functions, vtkMatrixBuilder.buildFromDegree()
andvtkMatrixbuilder.buildFromRadian()
, predefining the angle format used for
transformations and returning a MatrixBuilder instance. The matrix is
initialized with the Identity Matrix.
Methods
apply
Multiplies the array by the MatrixBuilder’s internal matrix, in sets of
3. Updates the array in place. If specified, offset
starts at a given
position in the array, and nbIterations
will determine the number of
iterations (sets of 3) to loop through. Assumes the typedArray
is an
array of multiples of 3, unless specifically handling with offset and
iterations. Returns the instance for chaining.
Argument | Type | Required | Description |
---|---|---|---|
typedArray |
Array. |
Yes | The Array value. |
offset |
Number | No | |
nbIterations |
Number | No |
getMatrix
Returns the internal mat4
matrix.
identity
Resets the MatrixBuilder to the Identity matrix.
invert
Inverts the MatrixBuilder matrix.
multiply
Argument | Type | Required | Description |
---|---|---|---|
mat4x4 |
mat4 | Yes |
multiply3x3
Multiply the current matrix with the provided 3x3 matrix.
Argument | Type | Required | Description |
---|---|---|---|
mat3x3 |
mat3 | Yes | column-first matrix |
new
Argument | Type | Required | Description |
---|---|---|---|
useDegree |
Boolean | No |
rotate
Normalizes the axis of rotation then rotates the current matrix angle
degrees/radians around the provided axis.
Argument | Type | Required | Description |
---|---|---|---|
angle |
Number | Yes | |
axis |
Vector3 | Yes |
rotateFromDirections
Multiplies the current matrix with a transformation matrix created by
normalizing both direction vectors and rotating around the axis of the
crossProduct by the angle from the dotProduct of the two directions.
Argument | Type | Required | Description |
---|---|---|---|
originDirection |
Array. |
Yes | |
targetDirection |
Array. |
Yes |
rotateX
Rotates angle
degrees/radians around the X axis.
Argument | Type | Required | Description |
---|---|---|---|
angle |
Number | Yes |
rotateY
Rotates angle
degrees/radians around the Y axis.
Argument | Type | Required | Description |
---|---|---|---|
angle |
Number | Yes |
rotateZ
Rotates angle
degrees/radians around the Z axis.
Argument | Type | Required | Description |
---|---|---|---|
angle |
Number | Yes |
scale
Scales the matrix by sx, sy, sz.
Argument | Type | Required | Description |
---|---|---|---|
sx |
Number | Yes | |
sy |
Number | Yes | |
sz |
Number | Yes |
setMatrix
Copies the given mat4
into the builder. Useful if you already have a
transformation matrix and want to transform it further. Returns the
instance for chaining.
Argument | Type | Required | Description |
---|---|---|---|
mat4x4 |
mat4 | Yes |
translate
Translates the matrix by x, y, z.
Argument | Type | Required | Description |
---|---|---|---|
x |
Number | Yes | The x coordinate. |
y |
Number | Yes | The y coordinate. |
z |
Number | Yes | The z coordinate. |
Source
import { mat3, mat4 } from 'gl-matrix'; |
import { vec3, mat4, glMatrix } from 'gl-matrix'; |