py3dframe.Frame.parent#

property Frame.parent: Frame | None#

The parent frame of this frame (by default the canonical frame if None).

Note

This property is settable.

The parent frame is used to define this frame relatively this parent frame.

Warning

If you change the parent frame of a frame, the current transformation (translation and rotation) of the frame will be kept unchanged but the global transformation (global translation and global rotation) of the frame will change according to the new parent frame.

Parameters:

parent (Optional[Frame]) – The parent frame in which the frame will be defined. If None, the frame will be defined in the global frame (the canonical frame).

Returns:

The parent frame of the frame. If None, the frame is defined in the global frame (the canonical frame).

Return type:

Optional[Frame]

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)

If the train moves and the person stays immobile in the train, the person axis will be unchanged relative to the train frame but will move relative to the global frame.

train.origin = [10, 0, 0] # The train moves 10 units along the x-axis of the global frame.

print("Person origin in the parent frame:", person.origin)
# Output: Person origin in the parent frame: [[ 0.] [ 1.] [ 0.]]

print("Person origin in the global frame:", person.global_origin)
# Output: Person origin in the global frame: [[10.] [ 1.] [ 0.]]

The parent frame allows to define a hierarchy of frames.