py3dframe.FrameTransform.dynamic#
- property FrameTransform.dynamic: bool#
The dynamic attribute controls whether the transformation is affected by changes in the input or output frame.
Note
This attribute is settable.
The dynamic attribute is a boolean. If True, the transformation will be affected by the changes in the input frame or the output frame. Otherwise, the transformation will be frozen at the time of the transformation object creation or at the time of the change of the dynamic attribute to False.
- Parameters:
dynamic (bool) – If True, the transformation will be affected by the changes in the input frame or the output frame.
- Returns:
If True, the transformation will be affected by the changes in the input frame or the output frame.
- Return type:
Examples
Lets create a FrameTransform object with the global frame as input frame and a local frame as output frame.
import numpy as np from py3dframe import Frame, FrameTransform frame_E = Frame.canonical() # Input frame - Global frame frame_F = Frame.from_axes(origin=[1, 2, 3], x_axis=[1, 0, 0], y_axis=[0, 1, 0], z_axis=[0, 0, 1]) # Output frame - Local frame transform = FrameTransform(input_frame=frame_E, output_frame=frame_F, dynamic=True, convention=0)
Here
dynamicis set toTrue, so the transformation will be affected by the changes in the input frame or the output frame.X_i = np.array([1, 2, 3]).reshape((3, 1)) X_o = transform.transform(point=X_i) print(X_o) # Output: [[0.] [0.] [0.]] print(transform.input_frame) # Output: Frame(origin=[[0.] [0.] [0.]], x_axis=[[1.] [0.] [0.]], y_axis=[[0.] [1.] [0.]], z_axis=[[0.] [0.] [1.]]) print(transform.get_active_input_frame()) # Output: Frame(origin=[[0.] [0.] [0.]], x_axis=[[1.] [0.] [0.]], y_axis=[[0.] [1.] [0.]], z_axis=[[0.] [0.] [1.]]) # Now, we change the input frame frame_E.origin = [1, 1, 1] X_o = transform.transform(point=X_i) print(X_o) # Output: [[1.] [1.] [1.]] print(transform.input_frame) # Output: Frame(origin=[[1.] [1.] [1.]], x_axis=[[1.] [0.] [0.]], y_axis=[[0.] [1.] [0.]], z_axis=[[0.] [0.] [1.]]) print(transform.get_active_input_frame()) # Output: Frame(origin=[[1.] [1.] [1.]], x_axis=[[1.] [0.] [0.]], y_axis=[[0.] [1.] [0.]], z_axis=[[0.] [0.] [1.]])
Lets set
dynamictoFalse, any modification of the input frame or the output frame will not affect the transformation.transform.dynamic = False X_i = [1, 2, 3] X_o = transform.transform(point=X_i) print(X_o) # Output: [[1.] [1.] [1.]] print(transform.input_frame) # Output: Frame(origin=[[1.] [1.] [1.]], x_axis=[[1.] [0.] [0.]], y_axis=[[0.] [1.] [0.]], z_axis=[[0.] [0.] [1.]]) print(transform.get_active_input_frame()) # Output: Frame(origin=[[1.] [1.] [1.]], x_axis=[[1.] [0.] [0.]], y_axis=[[0.] [1.] [0.]], z_axis=[[0.] [0.] [1.]]) # Now, we change the input frame frame_E.origin = [2, 2, 2] X_o = transform.transform(point=X_i) print(X_o) # Output: [[1.] [1.] [1.]] print(transform.input_frame) # Output: Frame(origin=[[2.] [2.] [2.]], x_axis=[[1.] [0.] [0.]], y_axis=[[0.] [1.] [0.]], z_axis=[[0.] [0.] [1.]]) print(transform.get_active_input_frame()) # Output: Frame(origin=[[1.] [1.] [1.]], x_axis=[[1.] [0.] [0.]], y_axis=[[0.] [1.] [0.]], z_axis=[[0.] [0.] [1.]])
Warning
Notice that when
dynamicis set toTrue, the transformation is unchanged when the user gives a new input frame or a new output frame. However, the input frame or the output frame of the transformation is updated. Use theget_active_input_frame()orget_active_output_frame()methods to extract the active input frame or the active output frame of the transformation.When
dynamicis set toFalse, if the user gives a new input frame or a new output frame, the transformation will unchanged too.new_input_frame = Frame.from_axes(origin=[3, 3, 3], x_axis=[0, 1, 0], y_axis=[0, 0, 1], z_axis=[1, 0, 0]) transform.input_frame = new_input_frame print(transform.input_frame) # Output: Frame(origin=[[3.] [3.] [3.]], x_axis=[[0.] [1.] [0.]], y_axis=[[0.] [0.] [1.]], z_axis=[[1.] [0.] [0.]]) print(transform.get_active_input_frame()) # Output: Frame(origin=[[1.] [1.] [1.]], x_axis=[[1.] [0.] [0.]], y_axis=[[0.] [1.] [0.]], z_axis=[[0.] [0.] [1.]])
When
dynamicis set to toTrue, the transformation instantly takes into account the new input frame or the new output frame.transform.dynamic = True print(transform.input_frame) # Output: Frame(origin=[[3.] [3.] [3.]], x_axis=[[0.] [1.] [0.]], y_axis=[[0.] [0.] [1.]], z_axis=[[1.] [0.] [0.]]) print(transform.get_active_input_frame()) # Output: Frame(origin=[[3.] [3.] [3.]], x_axis=[[0.] [1.] [0.]], y_axis=[[0.] [0.] [1.]], z_axis=[[1.] [0.] [0.]])