RectilinearGrid.transform(trans: Union[vtkmodules.vtkCommonMath.vtkMatrix4x4, vtkmodules.vtkCommonTransforms.vtkTransform, numpy.ndarray], transform_all_input_vectors=False, inplace=True, progress_bar=False)

Transform this mesh with a 4x4 transform.


When using transform_all_input_vectors=True, there is no distinction in VTK between vectors and arrays with three components. This may be an issue if you have scalar data with three components (e.g. RGB data). This will be improperly transformed as if it was vector data rather than scalar data. One possible (albeit ugly) workaround is to store the three components as separate scalar arrays.

transvtk.vtkMatrix4x4, vtk.vtkTransform, or np.ndarray

Accepts a vtk transformation object or a 4x4 transformation matrix.

transform_all_input_vectorsbool, optional

When True, all arrays with three components are transformed. Otherwise, only the normals and vectors are transformed. See the warning for more details.

inplacebool, optional

When True, modifies the dataset inplace.

progress_barbool, optional

Display a progress bar to indicate progress.


Transformed dataset. Return type matches input.


Translate a mesh by (50, 100, 200).

>>> import numpy as np
>>> from pyvista import examples
>>> mesh = examples.load_airplane()

Here a 4x4 numpy.ndarray is used, but vtk.vtkMatrix4x4 and vtk.vtkTransform are also accepted.

>>> transform_matrix = np.array([[1, 0, 0, 50],
...                              [0, 1, 0, 100],
...                              [0, 0, 1, 200],
...                              [0, 0, 0, 1]])
>>> transformed = mesh.transform(transform_matrix)
>>> transformed.plot(show_edges=True)