rotation — ALE Rotation Classes & Functions

namespace ale
class Rotation
#include <Rotation.h>

A generic 3D rotation.

Public Functions

Rotation()

Construct a default identity rotation.

Rotation(double w, double x, double y, double z)

Construct a rotation from a quaternion

Parameters:
  • w – The scalar component of the quaternion.

  • x – The x value of the vector component of the quaternion.

  • y – The y value of the vector component of the quaternion.

  • z – The z value of the vector component of the quaternion.

Rotation(const std::vector<double> &matrix)

Construct a rotation from a rotation matrix.

Parameters:

matrix – The rotation matrix in row-major order.

Rotation(const std::vector<double> &angles, const std::vector<int> &axes)

Construct a rotation from a set of Euler angle rotations.

Parameters:
  • angles – A vector of rotations about the axes.

  • axes – The vector of axes to rotate about, in order. 0 is X, 1 is Y, and 2 is Z.

Rotation(const std::vector<double> &axis, double theta)

Construct a rotation from a rotation about an axis.

Parameters:
  • axis – The axis of rotation.

  • theta – The rotation about the axis in radians.

~Rotation()
Rotation(Rotation &&other) noexcept
Rotation &operator=(Rotation &&other) noexcept
Rotation(const Rotation &other)
Rotation &operator=(const Rotation &other)
std::vector<double> toQuaternion() const

The rotation as a quaternion.

Returns:

The rotation as a scalar-first quaternion (w, x, y, z).

std::vector<double> toRotationMatrix() const

The rotation as a rotation matrix.

Returns:

The rotation as a rotation matrix in row-major order.

std::vector<double> toStateRotationMatrix(const Vec3d &av) const

Create a state rotation matrix from the rotation and an angular velocity.

Parameters:

av – The angular velocity vector.

Returns:

The state rotation matrix in row-major order.

std::vector<double> toEuler(const std::vector<int> &axes) const

The rotation as Euler angles.

Parameters:

axes – The axis order. 0 is X, 1 is Y, and 2 is Z.

Returns:

The rotations about the axes in radians.

std::pair<std::vector<double>, double> toAxisAngle() const

The rotation as a rotation about an axis.

Returns:

the axis of rotation and rotation in radians.

Vec3d operator()(const Vec3d &av) const

Rotate a vector

Parameters:
  • vector – The vector to rotate. Can be a 3 element position or 6 element state.

  • av – The angular velocity to use when rotating state vectors. Defaults to 0.

Returns:

The rotated vector.

State operator()(const State &state, const Vec3d &av = Vec3d(0.0, 0.0, 0.0)) const
Rotation inverse() const

Get the inverse rotation.

Rotation operator*(const Rotation &rightRotation) const

Chain this rotation with another rotation.

Rotations are sequenced right to left.

Rotation interpolate(const Rotation &nextRotation, double t, RotationInterpolation interpType) const

Interpolate between this rotation and another rotation.

Parameters:
  • t – The distance to interpolate. 0 is this and 1 is the next rotation.

  • interpType – The type of rotation interpolation to use.

  • The – interpolated rotation.

Private Members

std::unique_ptr<Impl> m_impl