py3dframe.Frame.get_global_rotation_matrix#

Frame.get_global_rotation_matrix(*, convention=None)[source]#

Access the rotation matrix representation of the rotation between the global frame and this frame in the given convention.

Parameters:

convention (Optional[int], optional) – Integer in [0, 7] selecting the convention. Defaults to the frame’s own convention.

Returns:

The rotation matrix between the global frame and this frame in the given convention with shape (3, 3).

Return type:

numpy.ndarray

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 and the person moves inside the train.

train.set_translation([10, 0, 0], convention=0) # The train moves of 10 units along the x axis of the global frame.

person.set_translation([0, 2, 0], convention=0) # The person moves by 1 unit along the y axis of the train frame.
person.set_euler_angles([0, 0, 45], convention=0, degrees=True) # The person rotates of 45 degrees around the z axis of the train frame.

If an application using an other convention required the rotation matrix between the global frame and the person frame in the convention 4, you can access this rotation matrix with the get_global_rotation_matrix() method:

global_rotation_person = person.get_global_rotation_matrix(convention=4) # Get the rotation matrix between the global frame and the person frame in convention 4.