pyvista.DataObjectFilters.translate

pyvista.DataObjectFilters.translate#

DataObjectFilters.translate(
xyz: VectorLike[float],
transform_all_input_vectors: bool = False,
inplace: bool = False,
) DataSet | MultiBlock[source]#

Translate the mesh.

Note

See also the notes at transform() which is used by this filter under the hood.

Parameters:
xyzVectorLike[float]

A vector of three floats.

transform_all_input_vectorsbool, default: False

When True, all input vectors are transformed. Otherwise, only the points, normals and active vectors are transformed.

inplacebool, default: False

Updates mesh in-place.

Returns:
DataSet | MultiBlock

Translated dataset. Return type matches input unless input dataset is a RectilinearGrid, in which case the output datatype is a StructuredGrid.

See also

pyvista.Transform.translate

Concatenate a translation matrix with a transformation.

Examples

Create a sphere and translate it by (2, 1, 2).

>>> import pyvista as pv
>>> mesh = pv.Sphere()
>>> mesh.center
(0.0, 0.0, 0.0)
>>> trans = mesh.translate((2, 1, 2), inplace=False)
>>> trans.center
(2.0, 1.0, 2.0)