Class Transform

Class Documentation

class Transform

Represents a transformation from one coordinate frame to another.

A Transform from frame A to frame B defines a relationship between the two frames, such that a spatial measurement in frame A can be represented equivalently in frame B by applying a translational and rotational offset. This process is known as applying a transform.

Transforms are specified as a translation and rotation of some “target” frame relative to some “source” frame. The “translation” is the target frame’s origin in source frame, and the “rotation” is the target frame’s orientation relative to the source frame’s orientation.

Conceptually, translations are applied “before” rotations. This means that the origin of the target frame is entirely defined by the translation in the source frame, and the rotation serves only to change the orientation of the target frame’s axes relative to the source frame.

Utilizes arm’s CMSIS matrix operations.

Param SOURCE:

represents the source frame of the transformation.

Param TARGET:

represents the target frame of the transformation.

Public Functions

Transform(const Position &translation, const Orientation &rotation)
Parameters:
  • rotation – Initial rotation of this transformation.

  • position – Initial translation of this transformation.

Transform(Position &&translation, Orientation &&rotation)
Transform(const CMSISMat<3, 1> &translation, const CMSISMat<3, 3> &rotation)
Parameters:
  • rotation – Initial rotation of this transformation.

  • position – Initial translation of this transformation.

Transform(CMSISMat<3, 1> &&translation, CMSISMat<3, 3> &&rotation)
Transform(float x, float y, float z, float roll, float pitch, float yaw)

Constructs rotations using XYZ Euler angles, so rotations are applied in order of A, B, then C. As an example, for an x-forward, z-up coordinate system, this is in the order of roll, pitch, then yaw.

Parameters:
  • x – Initial x-component of the translation.

  • y – Initial y-component of the translation.

  • z – Initial z-component of the translation.

  • A – Initial rotation angle about the x-axis.

  • B – Initial rotation angle about the y-axis.

  • C – Initial rotation angle about the z-axis.

Position apply(const Position &position) const

Apply this transform to a position.

Parameters:

position[in] Position in source frame.

Returns:

Position in target frame.

Vector apply(const Vector &vector) const

Rotates a vector in the source frame to a vector in the target frame.

Intended to be used for things like velocities and accelerations which represent the difference between two positions in space, since both positions get translated the same way, causing the translation to cancel out.

Parameters:

vectorVector as read by source frame.

Returns:

Vector in target frame’s basis.

Orientation apply(const Orientation &orientation) const
inline void updateTranslation(const Position &newTranslation)

Updates the translation of the current transformation matrix.

Parameters:

newTranslation – updated position of target in source frame.

inline void updateTranslation(Position &&newTranslation)
inline void updateTranslation(float x, float y, float z)

Updates the translation of the current transformation matrix.

Parameters:
  • x – new translation x-component.

  • y – new translation y-component.

  • z – new translation z-component.

inline void updateRotation(const Orientation &newRotation)

Updates the rotation of the current transformation matrix.

Parameters:

newRotation – updated orienation of target frame in source frame.

inline void updateRotation(Orientation &&newRotation)
inline void updateRotation(float roll, float pitch, float yaw)

Updates the rotation of the current transformation matrix. Takes rotation angles in the order of roll->pitch->yaw.

Parameters:
  • roll – updated rotation angle about the x-axis.

  • pitch – updated rotation angle about the y-axis.

  • yaw – updated rotation angle about the z-axis.

Transform getInverse() const
Returns:

Inverse of this Transform.

Transform compose(const Transform &second) const

Returns the composed transformation of the given transformations.

Returns:

Transformation from frame A to frame C.

inline Position getTranslation() const
inline Orientation getRotation() const
float getRoll() const

Get the roll of this transformation

float getPitch() const

Get the pitch of this transformation

float getYaw() const

Get the yaw of this transformation

inline float getX() const

Get the x-component of this transform’s translation

inline float getY() const

Get the y-component of this transform’s translation

inline float getZ() const

Get the z-component of this transform’s translation

Public Static Functions

static inline Transform identity()

Constructs an identity transform.