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, optional

Updates points in-place while returning nothing.

degbool, optional

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

axisstr, optional

Name of axis to rotate about. Valid options are 'x', 'y', and 'z'. Default value is '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
>>> from pyvista import examples
>>> points = examples.load_airplane().points
>>> points_orig = points.copy()
>>> pyvista.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]))