docs: def rmatrixquaternion(q):
      """Create a rotation matrix from q quaternion rotation.
      Quaternions are typed as Numeric Python numpy.arrays of length 4.
      """
      assert np.allclose(math.sqrt(np.dot(q,q)), 1.0)
  
      x, y, z, w = q
  
      xx = x*x
      xy = x*y
      xz = x*z
      xw = x*w
      yy = y*y
      yz = y*z
      yw = y*w
      zz = z*z
      zw = z*w
  
      r00 = 1.0 - 2.0 * (yy + zz)
      r01 =       2.0 * (xy - zw)
      r02 =       2.0 * (xz + yw)
  
      r10 =       2.0 * (xy + zw)
      r11 = 1.0 - 2.0 * (xx + zz)
      r12 =       2.0 * (yz - xw)
  
      r20 =       2.0 * (xz - yw)
      r21 =       2.0 * (yz + xw)
      r22 = 1.0 - 2.0 * (xx + yy)
  
      R = np.array([[r00, r01, r02],
                 [r10, r11, r12],
                 [r20, r21, r22]], float)
  
      assert np.allclose(np.linalg.det(R), 1.0)
      return R