# mdtraj.utils.rotation_matrix_from_quaternion

mdtraj.utils.rotation_matrix_from_quaternion(q)

  Compute a 3x3 rotation matrix from a given quaternion (4-vector).

  Parameters:

    q (np.ndarray, size=(..., 4)) – Quaternion or array of quaternions (need not be normalized, zero norm OK)

  Returns:

    Rq – Orthogonal rotation matrices corresponding to quaternion(s) q. Given, for example, an input shape of (m, 4), Rq will have shape (m, 3, 3).

  Return type:

    np.ndarray, size=(…, 3, 3)

  Examples

      >>> q = np.array([0.1, 0.2, 0.3, -0.4])
      >>> Rq = rotation_matrix_from_quaternion(q)

  See also

  `uniform_quaternion`

  References

  [1]

  http://en.wikipedia.org/wiki/Rotation_matrix#Quaternion