# spacepy.coordinates.quaternionToMatrix

spacepy.coordinates.quaternionToMatrix(Qin, scalarPos='last', normalize=True)

  Given an input quaternion, return the equivalent rotation matrix.

  The output has one more axis than the input (the last axis) and the shape is otherwise unchanged, allowing multi-dimensional quaternion input.

  Parameters
    Qin array_like

      input quaternion or array of quaternions, must be normalized.

  Returns
    out array_like

      Rotation matrix

  Other Parameters
    scalarPos str

      Location of the scalar component of the input quaternion, either ‘last’ (default) or ‘first’.

    normalize True

      Normalize input quaternions before conversion (default). If False, raises error for non-normalized.

  Raises
    NotImplementedError

      for invalid values of `scalarPos`.

    ValueError

      for inputs which are not valid normalized quaternions or arrays thereof: if the size doesn’t end in (4), if the quaternion is not normalized and `normalize` is False.

  See also

  `quaternionFromMatrix`

  Notes

  New in version 0.2.2.

  Implementation of the Euler–Rodrigues formula.

  Examples

      >>> import spacepy.coordinates
      >>> spacepy.coordinates.quaternionToMatrix([0.5, 0.5, 0.5, 0.5])
      array([[ 0.,  0.,  1.],
             [ 1.,  0.,  0.],
             [ 0.,  1.,  0.]])