py3dframe.Frame.convention#
- property Frame.convention: int#
The convention to express the transformation between the parent frame and this frame.
Note
This property is settable.
The convention can be an integer between 0 and 7 corresponding to the conventions described in the table below:
Index
Formula
0
\(\mathbf{X}_E = \mathbf{R} \mathbf{X}_F + \mathbf{T}\)
1
\(\mathbf{X}_E = \mathbf{R} \mathbf{X}_F - \mathbf{T}\)
2
\(\mathbf{X}_E = \mathbf{R} (\mathbf{X}_F + \mathbf{T})\)
3
\(\mathbf{X}_E = \mathbf{R} (\mathbf{X}_F - \mathbf{T})\)
4
\(\mathbf{X}_F = \mathbf{R} \mathbf{X}_E + \mathbf{T}\)
5
\(\mathbf{X}_F = \mathbf{R} \mathbf{X}_E - \mathbf{T}\)
6
\(\mathbf{X}_F = \mathbf{R} (\mathbf{X}_E + \mathbf{T})\)
7
\(\mathbf{X}_F = \mathbf{R} (\mathbf{X}_E - \mathbf{T})\)
Where:
\(\mathbf{X}_E\) is a point expressed in the parent frame coordinates.
\(\mathbf{X}_F\) is the same point expressed in the frame coordinates.
\(\mathbf{R}\) is the rotation matrix between the parent frame and this frame.
\(\mathbf{T}\) is the translation vector between the parent frame and this frame.
Note
The default convention is 0.
This can be useful when working with different libraries or applications that use different conventions for representing 3D transformations (as OPENCV, OPENGL, ROS, …).
- Parameters:
convention (int) – Integer in
[0, 7]selecting the convention to express the transformation between the parent frame and this frame.- Returns:
The convention parameter.
- Return type:
Examples
Lets create a frame with given axes and origin with the default convention 0.
import numpy from py3dframe import Frame origin = numpy.array([-1, -2, -3]) x_axis = numpy.array([1, 1, 0]) / numpy.sqrt(2) y_axis = numpy.array([-1, 1, 0]) / numpy.sqrt(2) z_axis = numpy.array([0, 0, 1]) frame = Frame.from_axes(origin=origin, x_axis=x_axis, y_axis=y_axis, z_axis=z_axis, convention=0)
If an application uses another convention, you can access the translation and rotation in this convention by changing the convention of the frame.
frame.convention = 4 # Change the convention of the frame to convention 4. print("Rotation matrix in convention 4:", frame.rotation_matrix)
The rotation returned is the rotation between the parent frame and this frame in convention 4.