Transform.rotate_vector

Transform.rotate_vector#

Transform.rotate_vector(
vector: VectorLikeFloat,
angle: float,
*,
point: VectorLikeFloat | None = None,
multiply_mode: Literal['pre', 'post'] | None = None,
) → Transform[source]#

Compose a rotation about a vector.

Create a matrix for rotation about the vector and compose() it with the current transformation matrix according to pre-multiply or post-multiply semantics.

Internally, the matrix is stored in the matrix_list.

Parameters:
vectorVectorLikeFloat

Vector to rotate about.

anglefloat

Angle in degrees to rotate about the vector.

pointVectorLikeFloat, optional

Point to rotate about. By default, the object’s point is used, but this can be overridden. If set, two additional transformations are composed and added to the matrix_list:

multiply_mode‘pre’ | ‘post’, optional

Multiplication mode to use when composing 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.

Examples#

Download Python source code | Download Jupyter notebook

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.        ]])

See Also#

rotate_x, rotate_y, rotate_z, rotate

Similar rotation methods.

rotation_matrix, rotation_axis_angle, as_rotation, has_rotation

Get this transform’s rotation component.

pyvista.DataObjectFilters.rotate_vector

Rotate a mesh about a vector.