pyvista.Transform.apply#
- Transform.apply(
- obj: VectorLike[float] | MatrixLike[float] | DataSet | MultiBlock,
- /,
- *,
- inverse: bool = False,
- copy: bool = True,
- transform_all_input_vectors: bool = False,
Apply the current transformation
matrix
to points or a dataset.Note
Points with integer values are cast to a float type before the transformation is applied. A similar casting is also performed when transforming datasets. See also the notes at
transform()
which is used by this filter under the hood.- Parameters:
- obj
VectorLike
[float
] |MatrixLike
[float
] |pyvista.DataSet
Object to apply the transformation to.
- inversebool, default:
False
Apply the transformation using the
inverse_matrix
instead of thematrix
.- copybool, default:
True
Return a copy of the input with the transformation applied. Set this to
False
to transform the input directly and return it. Only applies to NumPy arrays and datasets. A copy is always returned for tuple and list inputs or point arrays with integers.- transform_all_input_vectorsbool, default:
False
When
True
, all input vectors are transformed. Otherwise, only the points, normals and active vectors are transformed. Has no effect if the input is not a dataset.
- obj
- Returns:
np.ndarray
orpyvista.DataSet
Transformed array or dataset.
See also
pyvista.DataSetFilters.transform
Transform a dataset.
Examples
Apply a transformation to a point.
>>> import numpy as np >>> import pyvista as pv >>> point = (1, 2, 3) >>> transform = pv.Transform().scale(2) >>> transformed_point = transform.apply(point) >>> transformed_point array([2., 4., 6.])
Apply a transformation to a points array.
>>> points = np.array([[1, 2, 3], [4, 5, 6]]) >>> transformed_points = transform.apply(points) >>> transformed_points array([[ 2., 4., 6.], [ 8., 10., 12.]])
Apply a transformation to a dataset.
>>> dataset = pv.PolyData(points) >>> transformed_dataset = transform.apply(dataset) >>> transformed_dataset.points pyvista_ndarray([[ 2., 4., 6.], [ 8., 10., 12.]], dtype=float32)
Apply the inverse.
>>> inverted_dataset = transform.apply(dataset, inverse=True) >>> inverted_dataset.points pyvista_ndarray([[0.5, 1. , 1.5], [2. , 2.5, 3. ]], dtype=float32)