py3dframe.Frame.get_quaternion#
- Frame.get_quaternion(*, convention=None, scalar_first=True)[source]#
Access the quaternion representation of the rotation between the parent frame and this frame in a specific convention.
The quaternion is returned as a numpy array with shape (4,) in the scalar first [w, x, y, z] or scalar last [x, y, z, w] convention.
See also
attribute
parentto get or set the parent frame.attribute
conventionto get or set the convention of the frame.attribute
quaternionto get or set the quaternion in the convention of the frame.method
set_quaternion()to set the quaternion in a specific convention.method
get_global_quaternion()to get the quaternion between the global frame and this frame.
- Parameters:
- Returns:
The quaternion between the parent frame and this frame in the given convention with shape (4,).
- Return type:
Examples
Lets create a frame from its axes and origin with the default convention 0.
import numpy from py3dframe import Frame origin = numpy.array([-1, -2, -3]) x_axis = numpy.array([1, 1, 0]) / numpy.sqrt(2) y_axis = numpy.array([-1, 1, 0]) / numpy.sqrt(2) z_axis = numpy.array([0, 0, 1]) parent = ... # Define the parent frame if needed, otherwise parent=None to use the canonical frame. frame = Frame.from_axes(origin=origin, x_axis=x_axis, y_axis=y_axis, z_axis=z_axis, convention=0, parent=parent)
If an application using an other convention required the quaternion in the convention 4 with scalar first convention, you can access the quaternion in this convention with the
get_quaternion()method.quaternion_convention_4 = frame.get_quaternion(convention=4, scalar_first=True)