Class Rotation

Class Documentation

class Rotation

A class representing a planar rotation.

The rotation angle is always within the range [-PI, PI]. This class mimics the tf2::Matrix3x3/tf2::Quaternion classes to the extent possible.

Public Functions

inline Rotation()

No initialization constructor.

inline explicit Rotation(const tf2Scalar angle)

Constructor from scalars.

Parameters:

angle – The rotation angle in radians

inline Rotation operator-() const

Return the reverse rotation.

inline Rotation &operator+=(const Rotation &rhs)

Add a rotation to this one.

Parameters:

rhs – The rotation to add to this one

inline Rotation &operator-=(const Rotation &rhs)

Subtract a rotation from this one.

Parameters:

rhs – The rotation to subtract

inline Rotation &operator*=(const tf2Scalar rhs)

Scale the rotation.

Parameters:

rhs – Scale factor

inline Rotation &operator/=(const tf2Scalar rhs)

Inversely scale the rotation.

Parameters:

rhs – Scale factor to divide by

inline bool operator==(const Rotation &other) const

Check if two rotations are equal.

inline bool operator!=(const Rotation &other) const

Check if two vectors are not equal.

inline tf2Scalar distance2(const Rotation &other) const

Return the distance squared between this and another rotation.

inline tf2Scalar distance(const Rotation &other) const

Return the distance between this and another rotation.

inline Vector2 rotate(const Vector2 &vec) const

Rotate a vector by this rotation.

Parameters:

vec – The vector to rotate

inline Vector2 unrotate(const Vector2 &vec) const

Rotate a vector by the inverse of this rotation.

Parameters:

vec – The vector to rotate

inline Rotation inverse() const

Return the inverse of this rotation.

inline Rotation absolute() const

Return a rotation with the absolute values of each element.

inline Rotation lerp(const Rotation &other, const tf2Scalar ratio) const

Return the linear interpolation between this and another rotation.

The interpolation always uses the shortest path between this and other

Parameters:
  • other – The other rotation

  • ratio – The ratio of this to other (ratio=0 => return this, ratio=1 => return other)

inline const tf2Scalar &getAngle() const

Return the angle value in radians.

inline const tf2Scalar &angle() const
inline void setAngle(const tf2Scalar angle)

Set the angle value in radians.

inline void setMax(const Rotation &other)

Set the angle to the max of this and another rotation.

Parameters:

other – The other Rotation to compare with

inline void setMin(const Rotation &other)

Set the angle to the min of this and another rotation.

Parameters:

other – The other Rotation to compare with

inline void setValue(const tf2Scalar angle)

Set the rotation to the provided angle in radians.

Parameters:

angle – The angle value in radians

inline void setZero()

Set the rotation to zero

inline bool isZero() const

Check if all the elements of this vector are zero

inline bool fuzzyZero() const

Check if all the elements of this vector close to zero

inline Eigen::Matrix2d getRotationMatrix() const

Get a 2x2 rotation matrix.

inline Eigen::Matrix3d getHomogeneousMatrix() const

Get a 3x3 homogeneous transformation matrix with just the rotation portion populated.