pyvista.Transform.concatenate

pyvista.Transform.concatenate#

Transform.concatenate(
transform: pyvista.TransformLike,
*,
multiply_mode: Literal['pre', 'post'] | None = None,
) Transform[source]#

Concatenate a transformation matrix.

Create a 4x4 matrix from any transform-like input and concatenate it with the current transformation matrix according to pre-multiply or post-multiply semantics.

Internally, the matrix is stored in the matrix_list.

Parameters:
transformTransformLike

Any transform-like input such as a 3x3 or 4x4 array or matrix.

multiply_mode‘pre’ | ‘post’, optional

Multiplication mode to use when concatenating the matrix. By default, the object’s multiply_mode is used, but this can be overridden. Set this to 'pre' for pre-multiplication or 'post' for post-multiplication.

Examples

Define an arbitrary 4x4 affine transformation matrix and concatenate it.

>>> import pyvista as pv
>>> array = [
...     [0.707, -0.707, 0, 0],
...     [0.707, 0.707, 0, 0],
...     [0, 0, 1, 1.5],
...     [0, 0, 0, 2],
... ]
>>> transform = pv.Transform().concatenate(array)
>>> transform.matrix
array([[ 0.707, -0.707,  0.   ,  0.   ],
       [ 0.707,  0.707,  0.   ,  0.   ],
       [ 0.   ,  0.   ,  1.   ,  1.5  ],
       [ 0.   ,  0.   ,  0.   ,  2.   ]])

Define a second transformation and use + to concatenate it.

>>> array = [[1, 0, 0], [0, 0, -1], [0, -1, 0]]
>>> transform = transform + array
>>> transform.matrix
array([[ 0.707, -0.707,  0.   ,  0.   ],
       [ 0.   ,  0.   , -1.   , -1.5  ],
       [-0.707, -0.707,  0.   ,  0.   ],
       [ 0.   ,  0.   ,  0.   ,  2.   ]])