calculus

Overview

rowan.calculus.derivative Compute the instantaneous derivative of unit quaternions.
rowan.calculus.integrate Integrate unit quaternions by angular velocity.

Details

Compute derivatives and integrals of quaternions.

rowan.calculus.derivative(q, v)

Compute the instantaneous derivative of unit quaternions.

Derivatives of quaternions are defined by the equation:

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

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

Parameters:
Returns:

Derivatives of q.

Return type:

(…, 4) numpy.ndarray

Example:

>>> rowan.calculus.derivative([1, 0, 0, 0], [1, 0, 0])
array([0. , 0.5, 0. , 0. ])
rowan.calculus.integrate(q, v, dt)

Integrate unit quaternions by angular velocity.

The integral uses 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:
Returns:

Integrals of q.

Return type:

(…, 4) numpy.ndarray

Example:

>>> rowan.calculus.integrate([1, 0, 0, 0], [0, 0, 1e-2], 1)
array([0.9999875 , 0.        , 0.        , 0.00499998])