spacepy.coordinates.quaternionRotateVector

spacepy.coordinates.quaternionRotateVector(Qin, Vin, scalarPos='last', normalize=True)[source]

Given quaternions and vectors, return the vectors rotated by the quaternions

Parameters
Qinarray_like

input quaternion to rotate by

Vinarray-like

input vector to rotate

Returns
outarray_like

rotated vector

Examples

>>> import spacepy.coordinates
>>> import numpy as np
>>> vec = [1, 0, 0]
>>> quat_wijk = [np.sin(np.pi/4), 0, np.sin(np.pi/4), 0.0]
>>> quat_ijkw = [0.0, np.sin(np.pi/4), 0, np.sin(np.pi/4)]
>>> spacepy.coordinates.quaternionRotateVector(quat_ijkw, vec)
array([ 0.,  0., -1.])
>>> spacepy.coordinates.quaternionRotateVector(
...     quat_wijk, vec, scalarPos='first')
array([ 0.,  0., -1.])