py3dframe.Frame.set_quaternion#
- Frame.set_quaternion(quaternion, *, convention=None, scalar_first=True)[source]#
Set the quaternion representation of the rotation between the parent frame and this frame in a specific convention.
The quaternion must be given as a array-like with 4 elements 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
get_quaternion()to get the quaternion in a specific convention.method
set_global_quaternion()to set the quaternion between the global frame and this frame.
- Parameters:
quaternion (numpy.ndarray) – The quaternion between the parent frame and this frame in the given convention as an array-like with 4 elements.
convention (Optional[int], optional) – Integer in
[0, 7]selecting the convention. Defaults to the frame’s own convention.scalar_first (bool, optional) – If True, the quaternion is in the scalar first convention. Default is True. If False, the quaternion is in the scalar last convention.
- Return type:
None
Examples
Lets create a default frame with convention 0.
from py3dframe import Frame parent = ... # Define the parent frame if needed, otherwise parent=None to use the canonical frame. frame = Frame.canonical(convention=0, parent=parent)
Lets assume, an application uses convention 4 to represent the transformation between two frames. The frame of reference of the application rotates and the new quaternion between the parent frame and this frame in convention 4 with scalar first convention can be extracted from the application.
import numpy quaternion = numpy.array(...) # Extract the quaternion from the application. frame.set_quaternion(quaternion, convention=4, scalar_first=True) # Set the quaternion in convention 4 with scalar first convention.