pyvista.Transform.rotate_vector#
- Transform.rotate_vector(
- vector: VectorLike[float],
- angle: float,
- *,
- point: VectorLike[float] | None = None,
- multiply_mode: Literal['pre', 'post'] | None = None,
Concatenate a rotation about a vector.
Create a matrix for rotation about the vector and
concatenate()
it with the current transformationmatrix
according 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
point
is used, but this can be overridden. If set, two additional transformations are concatenated and added to thematrix_list
:translate()
topoint
before the rotationtranslate()
away frompoint
after the rotation
- multiply_mode‘pre’ | ‘post’,
optional
Multiplication mode to use when concatenating the matrix. By default, the object’s
multiply_mode
is used, but this can be overridden. Set this to'pre'
for pre-multiplication or'post'
for post-multiplication.
- vector
See also
pyvista.DataSet.rotate_vector
Rotate a mesh about a vector.
Examples
Concatenate 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. ]])
Concatenate 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. ]])