pyvista.core.utilities.axis_rotation

Contents

pyvista.core.utilities.axis_rotation#

axis_rotation(points, angle, inplace=False, deg=True, axis='z')[source]#

Rotate points by angle about an axis.

Parameters:
pointsnumpy.ndarray

Array of points with shape (N, 3).

anglefloat

Rotation angle.

inplacebool, default: False

Updates points in-place while returning nothing.

degbool, default: True

If True, the angle is interpreted as degrees instead of radians.

axisstr, default: “z”

Name of axis to rotate about. Valid options are 'x', 'y', and 'z'.

Returns:
numpy.ndarray

Rotated points.

Examples

Rotate a set of points by 90 degrees about the x-axis in-place.

>>> import numpy as np
>>> import pyvista as pv
>>> from pyvista import examples
>>> points = examples.load_airplane().points
>>> points_orig = points.copy()
>>> pv.axis_rotation(points, 90, axis='x', deg=True, inplace=True)
>>> assert np.all(np.isclose(points[:, 0], points_orig[:, 0]))
>>> assert np.all(np.isclose(points[:, 1], -points_orig[:, 2]))
>>> assert np.all(np.isclose(points[:, 2], points_orig[:, 1]))