py3dframe.Frame.set_global_rotation_vector#
- Frame.set_global_rotation_vector(rotation_vector, *, convention=None, degrees=False)[source]#
Set the rotation vector representation of the rotation between the global frame and this frame in the given convention.
The rotation vector must be a array-like with 3 elements representing the axis of rotation and the angle of rotation. The direction of the vector indicates the axis of rotation and the magnitude represents the angle of rotation.
See also
attribute
parentto get or set the parent frame.attribute
conventionto get or set the convention of the frame.attribute
global_rotation_vectorto get or set the rotation vector between the global frame and this frame in the convention of the frame.method
get_global_rotation_vector()to get the rotation vector between the global frame and this frame in a specific convention.method
set_rotation_vector()to set the rotation vector between the parent frame and this frame in a specific convention.
- Parameters:
rotation_vector (numpy.ndarray) – The rotation vector between the global frame and this frame in the given convention as an array-like with 3 elements.
convention (Optional[int], optional) – Integer in
[0, 7]selecting the convention. Defaults to the frame’s own convention.degrees (bool, optional) – If True, the rotation vector is in degrees. Default is False (radians).
- Return type:
None
Examples
Lets consider a train and a person standing into the train.
First we can define the train frame relative to the global frame (the canonical frame) and then we can define the person frame relative to the train frame.
from py3dframe import Frame train = Frame.from_axes(origin=[0, 0, 0], x_axis=[1, 0, 0], y_axis=[0, 1, 0], z_axis=[0, 0, 1], parent=None) person = Frame.from_axes(origin=[0, 1, 0], x_axis=[1, 0, 0], y_axis=[0, 1, 0], z_axis=[0, 0, 1], parent=train)
Lets assume the train moves.
train.set_translation([10, 0, 0], convention=0) # The train moves of 10 units along the x axis of the global frame.
If an application using an other convention gives the new rotation vector between the global frame and the person frame in the convention 4, you can set this rotation vector with the
set_global_rotation_vector()method:import numpy rotation_vector = ... # Get the new rotation vector between the global frame and the person frame in convention 4 from the application. person.set_global_rotation_vector(rotation_vector, convention=4, degrees=True) # Set the rotation vector between the global frame and the person frame in convention 4 in degrees.
The person frame is updated accordingly to keep the correct transformation between the global frame and the person frame.
Then we can determine the new orientation and position of the person relative to the train frame:
print("Person origin in the train frame:", person.origin) print("Person axes in the train frame:", person.axes)