py3dframe.FrameTransform.inverse_transform#
- FrameTransform.inverse_transform(*, point=None, vector=None)[source]#
Transform a point or a vector from the output frame to the input frame.
If the point is provided, the method will return the coordinates of the point in the input frame. If the vector is provided, the method will return the coordinates of the vector in the input frame.
Several points / vectors can be transformed at the same time by providing a 2D numpy array with shape (3, N).
If both the point and the vector are provided, the method will raise a ValueError. If neither the point nor the vector is provided, the method will return None.
In the convention 0:
\[X_{\text{input_frame}} = R * X_{\text{output_frame}} + T\]\[V_{\text{input_frame}} = R * V_{\text{output_frame}}\]- Parameters:
point (Optional[array_like], optional) – The coordinates of the point in the output frame with shape (3, N). Default is None.
vector (Optional[array_like], optional) – The coordinates of the vector in the output frame with shape (3, N). Default is None.
- Returns:
The coordinates of the point or the vector in the input frame with shape (3, N).
- Return type:
- Raises:
ValueError – If the point or the vector is not provided. If point and vector are both provided.
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)
The FrameTransform object can be used to transform points or vectors from the output frame to the input frame.
X_o = np.array([0, 0, 0]).reshape((3, 1)) # Point in the output frame coordinates X_i = transform.inverse_transform(point=X_o) # Transform the point to the input frame coordinates print(X_i) # Output: [[1.] [2.] [3.]] V_o = np.array([1, 0, 0]).reshape((3, 1)) # Vector in the output frame coordinates V_i = transform.inverse_transform(vector=V_o) # Transform the vector to the input frame coordinates print(V_i) # Output: [[1.] [0.] [0.]]