pyvista.Transform.translate

pyvista.Transform.translate#

Transform.translate(
*vector: float | VectorLike[float],
multiply_mode: Literal['pre', 'post'] | None = None,
) Transform[source]#

Concatenate a translation matrix.

Create a translation matrix 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:
*vectorfloat | VectorLike[float]

Vector to use for translation. May be a single vector (one arg) or unpacked vector (three args).

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.

See also

pyvista.DataSetFilters.translate()

Translate a mesh.

Examples

Concatenate a translation matrix.

>>> import pyvista as pv
>>> transform = pv.Transform().translate(1, 2, 3)
>>> transform.matrix
array([[1., 0., 0., 1.],
       [0., 1., 0., 2.],
       [0., 0., 1., 3.],
       [0., 0., 0., 1.]])

Concatenate a second translation matrix using +.

>>> transform = transform + (1, 1, 1)
>>> transform.matrix
array([[1., 0., 0., 2.],
       [0., 1., 0., 3.],
       [0., 0., 1., 4.],
       [0., 0., 0., 1.]])