Basic
Reference for the gtFrame.basic module.
The gtFrame.basic module implements basic Frames. These do
not account for any dynamics and just convert a static position and rotation
into another.
Module Contents
- Variables:
origin2d
- Classes:
RootFrame2d
Frame2d
RootFrame3d
Frame3d
- class gtFrame.basic.Frame2d(position, rotation, parent_frame=<gtFrame.basic.RootFrame2d object>)
The frame 2d class represents a static 2d-frame.
- Parameters:
position (np.ndarray) – the relative position to the parent frame of reference
rotation (gtFrame.rotation.Rotation2d) – the relative rotation to the parent frame of reference
parent_frame (gtFrame.basic.Frame2d) – The parent frame of reference. The default value for this is
gtFrame.basic.origin2d.
- find_transform_path(frame)
Finds the reference path from this frame of reference to the given frame of reference. This is mainly used for the .transform_from and .transform_to methods. (This method is identical to
Frame3d.find_transform_path().)- Parameters:
frame (Frame2d) – the destination frame of reference
- Returns:
the path as a list with the first step on [0] and the last at [-1]
- Return type:
list
- find_transform_path_legacy(frame)
[LEGACY METHOD] This is same as find_transform_path but without the optimization.
Finds the reference path from this frame of reference to the given frame of reference. This is mainly used for the .transform_from and .transform_to methods. (This method is identical to
Frame3d.find_transform_path().)- Parameters:
frame (Frame2d) – the destination frame of reference
- Returns:
the path as a list with the first step on [0] and the last at [-1]
- Return type:
list
- static rotate_via_path(vector, path)
This function rotates a vector according to a given transform path. The function works like
gtFrame.basic.Frame2d.transform_via_path(), except that it only rotates the vectors and does not translate them.- Parameters:
vector (np.ndarray) – the vector to be rotated
path (list) – the transform path given by
gtFrame.basic.Frame2d.find_transform_path()
- Returns:
the rotated vector as a numpy array
- Return type:
np.ndarray
- transform_from(frame, vector)
Transform a vector expressed in an arbitrary frame of reference into this frame.
- Parameters:
frame (Frame2d) – the frame of reference, in which the vector is defined
vector (np.ndarray) – the vector to be transformed
- Returns:
the transformed vector
- Return type:
np.ndarray
- transform_from_parent(vector)
Transform a vector, expressed in the parent frame, into this frame.
- Parameters:
vector (np.ndarray) – vector expressed in parent frame
- Returns:
the vector expressed in this frame of reference
- Return type:
np.ndarray
- transform_to(frame, vector)
Transform a vector expressed in this frame of reference into a given frame of reference.
- Parameters:
frame (Frame2d) – the frame to which to transform to
vector (np.ndarray) – the vector to be transformed
- Returns:
the transformed vector
- Return type:
np.ndarray
- transform_to_parent(vector)
Return the given vector expressed in the parent frame of reference.
- Returns:
the vector in the parent frame of reference
- Return type:
np.ndarray
- static transform_via_path(vector, path)
Transforms a vector according to a given transform path.
- Parameters:
vector (np.ndarray) – the vector to be transformed
path (list) – the path for the transformation, as returned by
gtFrame.basic.Frame2d.find_transform_path()
- Returns:
the final vector after the transformations
- Return type:
np.ndarray
- class gtFrame.basic.Frame3d(position, rotation, parent_frame=<gtFrame.basic.RootFrame3d object>)
The Frame3d class represents a static 3d-frame.
- Parameters:
position (np.ndarray) – the relative position to the parent frame of reference
rotation (gtFrame.rotation.Rotation3d) – the relative rotation to the parent frame of reference
parent_frame (gtFrame.basic.Frame3d) – The parent frame of reference. The default value for this is
gtFrame.basic.origin3d.
- find_transform_path(frame)
Finds the reference path from this frame of reference to the given frame of reference. This is mainly used for the .transform_from and .transform_to methods. (This method is identical to
Frame2d.find_transform_path().)- Parameters:
frame (Frame3d) – the destination frame of reference
- Returns:
the path as a list with the first step on [0] and the last at [-1]
- Return type:
list
- find_transform_path_legacy(frame)
[LEGACY METHOD] This is same as find_transform_path but without the optimization.
Finds the reference path from this frame of reference to the given frame of reference. This is mainly used for the .transform_from and .transform_to methods. (This method is identical to
Frame2d.find_transform_path().)- Parameters:
frame (Frame3d) – the destination frame of reference
- Returns:
the path as a list with the first step on [0] and the last at [-1]
- Return type:
list
- static rotate_via_path(vector, path)
This function rotates a vector according to a given transform path. The function works like
gtFrame.basic.Frame3d.transform_via_path(), except that it only rotates the vectors and does not translate them.- Parameters:
vector (np.ndarray) – the vector to be rotated
path (list) – the transform path given by
gtFrame.basic.Frame3d.find_transform_path()
- Returns:
the rotated vector as a numpy array
- Return type:
np.ndarray
- transform_from(frame, vector)
Transform a vector expressed in an arbitrary frame of reference into this frame.
- Parameters:
frame (Frame3d) – the frame of reference, in which the vector is defined
vector (np.ndarray) – the vector to be transformed
- Returns:
the transformed vector
- Return type:
np.ndarray
- transform_from_parent(vector)
Transform a vector given in the parent frame of reference into this frame.
- Parameters:
vector (np.ndarray) – the vector to be transformed
- Returns:
the transformed vector
- Return type:
np.ndarray
- transform_to(frame, vector)
Transform a vector expressed in this frame of reference into a given frame of reference.
- Parameters:
frame (Frame3d) – the frame to which to transform to
vector (np.ndarray) – the vector to be transformed
- Returns:
the transformed vector
- Return type:
np.ndarray
- transform_to_parent(vector)
Transform a vector given in this frame of reference into the parent frame.
- Parameters:
vector (np.ndarray) – the vector to be transformed
- Returns:
the transformed vector
- Return type:
np.ndarray
- static transform_via_path(vector, path)
Transforms a vector according to a given transform path.
- Parameters:
vector (np.ndarray) – the vector to be transformed
path (list) – the path for the transformation, as returned by
gtFrame.basic.Frame3d.find_transform_path()
- Returns:
the final vector after the transformations
- Return type:
np.ndarray
- class gtFrame.basic.RootFrame2d
The RootFrame2d is the origin of the 2d-system and has a position vector of [0, 0] and a rotation of 0.
- find_transform_path(frame)
Finds the transform path from this frame of reference to the given frame.
- Parameters:
frame (Frame2d) – the frame of reference to find a transform path to
- Returns:
the transform path in a format that can be interpreted by Frame2d.transform_via_path().
- parent()
Returns the parent of the Frame. For RootFrame2d this is self.
- Returns:
self
- Return type:
- transform_from(frame, vector)
Transform a vector expressed in an arbitrary frame of reference into this frame. :param frame: the frame of reference, in which the vector is defined :type frame: Frame2d :param vector: the vector to be transformed :type vector: np.ndarray :return: the transformed vector :rtype: np.ndarray
- transform_to(frame, vector)
Transform a vector expressed in this frame of reference into a given frame of reference. :param frame: the frame to which to transform to :type frame: Frame2d :param vector: the vector to be transformed :type vector: np.ndarray :return: the transformed vector :rtype: np.ndarray
- class gtFrame.basic.RootFrame3d
The RootFrame3d is the origin of the 3d-system and has a position vector of [0, 0, 0] and a rotation of 0.
- find_transform_path(frame)
Finds the transform path from this frame of reference to the given frame.
- Parameters:
frame (Frame3d) – the frame of reference to find a transform path to
- Returns:
the transform path in a format that can be interpreted by Frame3d.transform_via_path().
- parent()
Returns the parent of the Frame. For RootFrame3d this is self.
- Returns:
self
- Return type:
- transform_from(frame, vector)
Transform a vector expressed in an arbitrary frame of reference into this frame. :param frame: the frame of reference, in which the vector is defined :type frame: Frame3d :param vector: the vector to be transformed :type vector: np.ndarray :return: the transformed vector :rtype: np.ndarray
- transform_to(frame, vector)
Transform a vector expressed in this frame of reference into a given frame of reference. :param frame: the frame to which to transform to :type frame: Frame3d :param vector: the vector to be transformed :type vector: np.ndarray :return: the transformed vector :rtype: np.ndarray