pythonscipy

What is scipy's rotation function as_matrix from quaternion based on?


The scipy implementation of as_matrix (from quaternions) which appears here seems different to the usual one found in books or online (as in this wiki page).

Where did they get it from? There is no reference there.


Solution

  • The wikipedia page on rotation matrices shows 1's on the diagonal.

    I believe scipy replaces the 1's on the diagonal with

    w^2+x^2+y^2+z^2

    That makes them the same for a unit quaternion.

    For non-unit quaternions, scipy's matrix acts as both a rotation and a scaling.

    For example:

    if you take the quaternion = 2 +0i+0j+0k.

    The rotation matrix will be the identity matrix (with only a w term there is no rotation),

    Scipy's matrix will be 4*identity, because the quaternion was not a unit quaternion.