pyvista.Transform.rotate_vector#
- Transform.rotate_vector(
- vector: VectorLike[float],
- angle: float,
- *,
- point: VectorLike[float] | None = None,
- multiply_mode: Literal['pre', 'post'] | None = None,
Compose a rotation about a vector.
Create a matrix for rotation about the vector and
compose()it with the current transformationmatrixaccording to pre-multiply or post-multiply semantics.Internally, the matrix is stored in the
matrix_list.- Parameters:
- vector
VectorLike[float] Vector to rotate about.
- angle
float Angle in degrees to rotate about the vector.
- point
VectorLike[float],optional Point to rotate about. By default, the object’s
pointis used, but this can be overridden. If set, two additional transformations are composed and added to thematrix_list:translate()topointbefore the rotationtranslate()away frompointafter the rotation
- multiply_mode‘pre’ | ‘post’,
optional Multiplication mode to use when composing the matrix. By default, the object’s
multiply_modeis used, but this can be overridden. Set this to'pre'for pre-multiplication or'post'for post-multiplication.
- vector
See also
as_rotationGet this transform’s rotation component.
pyvista.DataObjectFilters.rotate_vectorRotate a mesh about a vector.
Examples
Compose a rotation of 30 degrees about the
(1, 1, 1)axis.>>> import pyvista as pv >>> transform = pv.Transform().rotate_vector((1, 1, 1), 30) >>> transform.matrix array([[ 0.9106836 , -0.24401694, 0.33333333, 0. ], [ 0.33333333, 0.9106836 , -0.24401694, 0. ], [-0.24401694, 0.33333333, 0.9106836 , 0. ], [ 0. , 0. , 0. , 1. ]])
Compose a second rotation of 45 degrees about the
(1, 2, 3)axis.>>> _ = transform.rotate_vector((1, 2, 3), 45) >>> transform.matrix array([[ 0.38042304, -0.50894634, 0.77217351, 0. ], [ 0.83349512, 0.55045308, -0.04782562, 0. ], [-0.40070461, 0.66179682, 0.63360933, 0. ], [ 0. , 0. , 0. , 1. ]])