Convert the quaternion to a 3x3 rotation matrix and apply this rotation to your vector.
For a unit (w, x, y, z)
quaternion, this matrix is:
( 1 - 2 * ( y * y + z * z ) 2 * ( x * y - z * w ) 2 * (x * z + y * w ) )
R = ( 2 * ( x * y + z * w ) 1 - 2 * ( x * x + z * z ) 2 * (y * z - x * w ) )
( 2 * ( x * z - y * w ) 2 * ( y * z + x * w ) 1 - 2 * (x * x + y * y ) )
If your vector has such a simple form as (0, 0, -1)
, you will not need to compute all the 9 coefficients of the rotation matrix since the result of the matrix vector multiplication only uses some of the coefficients (the last column of R
).