py3dframe.rotate_around_axis#

rotate_around_axis(frame, axis, angle, point=None, use_global=False, inplace=True)[source]#

Rotate a frame around a specified axis by a given angle.

The frame is rotated around the specified axis by the given angle in radians.

If use_global is set to True, the rotation is applied in the global coordinate system. Otherwise, the rotation is applied in the local coordinate system of the frame (in the parent frame).

Rotation Around Axis

See also

Parameters:
  • frame (Frame) – The frame to rotate.

  • axis (numpy.ndarray) – A 3D vector representing the axis around which to rotate the frame. The vector not need to be normalized.

  • angle (float) – The angle in radians to rotate around the specified axis.

  • point (Optional[numpy.ndarray], optional) – A 3D point representing a point through which the rotation axis passes. If None, the rotation is performed around the frame’s origin. Default is None.

  • use_global (bool, optional) – If True, the rotation is applied in the global coordinate system. If False, the rotation is applied in the local coordinate system of the frame. Default is False.

  • inplace (bool, optional) – If True, the rotation is applied to the input frame and the same frame is returned. If False, a new rotated frame is returned and the input frame remains unchanged. Default is True.

Returns:

The rotated frame.

Return type:

Frame

Examples

from py3dframe import Frame
from py3dframe import rotate_around_axis
import numpy as np

# Create a default frame
frame = Frame.canonical()

# Define an axis to rotate around (e.g., the z-axis)
axis = np.array([0.0, 0.0, 1.0])
angle_rad = np.pi / 2  # 90 degrees in radians

# Rotate the frame by 90 degrees around the specified axis in the local coordinate system
rotated_frame = rotate_around_axis(frame, axis, angle_rad, use_global=False, inplace=True)

# The orientation of the rotated frame is now changed
print(rotated_frame.orientation)