Transform.translate#
- Transform.translate(
- *vector: float | VectorLike[float],
- multiply_mode: Literal['pre', 'post'] | None = None,
Compose a translation matrix.
Create a translation matrix and
compose()it with the current transformationmatrixaccording to pre-multiply or post-multiply semantics.Internally, the matrix is stored in the
matrix_list.- Parameters:
- *vector
float|VectorLike[float] Vector to use for translation. May be a single vector (one
arg) or unpacked vector (threeargs).- multiply_mode‘pre’ | ‘post’,
optional Multiplication mode to use when composing the matrix. By default, the object’s
multiply_modeis used, but this can be overridden. Set this to'pre'for pre-multiplication or'post'for post-multiplication.
- *vector
Examples#
Download Python source code | Download Jupyter notebook
Compose 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.]])
Compose 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.]])
See Also#
pyvista.DataObjectFilters.translateTranslate a mesh.
translation,has_translationGet info about the transform’s translation component.
Used In#
Docstring Examples
Transform(2 uses)Transform.decompose(1 use)
Gallery Examples