calculus

Overview

rowan.calculus.derivative Compute the instantaneous derivative of unit quaternions, which is defined as
rowan.calculus.integrate Integrate unit quaternions by angular velocity using the following equation:

Details

This subpackage provides the ability to compute the derivative and integral of a quaternion.

rowan.calculus.derivative(q, v)

Compute the instantaneous derivative of unit quaternions, which is defined as

\[\dot{q} = \frac{1}{2} \boldsymbol{v} q\]

A derivation is provided here. For a more thorough explanation, see this page.

Parameters:
  • q ((..,4) np.array) – Array of quaternions.
  • v ((..,3) np.array) – Array of angular velocities.
Returns:

Array of shape (…, 4) containing element-wise derivatives of q.

Example:

q_prime = rowan.calculus.derivative([1, 0, 0, 0], [1, 0, 0])
rowan.calculus.integrate(q, v, dt)

Integrate unit quaternions by angular velocity using the following equation:

\[\dot{q} = \exp\left(\frac{1}{2} \boldsymbol{v} dt\right) q\]

Note that this formula uses the quaternion exponential, so the argument to the exponential (which appears to be a vector) is promoted to a quaternion with scalar part 0 before the exponential is taken. A concise derivation is provided in this paper. This webpage contains a more thorough explanation.

Parameters:
  • q ((..,4) np.array) – Array of quaternions.
  • v ((..,3) np.array) – Array of angular velocities.
  • dt ((..) np.array) – Array of timesteps.
Returns:

Array of shape (…, 4) containing element-wise integrals of q.

Example:

v_next = rowan.calculus.integrate([1, 0, 0, 0], [0, 0, 1e-2], 1)