# How do I calculate a position in front of a quaternion given the initial position and the quaternion?

Well I want to determine the position in front of, lets say 'an object'.

'An objects' has a position (pX,pY,pZ) and a quaternion rotation (qX,qY,qZ,qW) (where qW seems always to be 0 - because this is from a game I want to modify, I never saw it become 1)

Now I would like to determine the position at n units in front of the position of the object according to the quaternion rotation. How would I do that?

Extra Info:

I know the quaternion combinations produce (when starting to transform from (1,0,0,0) if that matters):

(1,0,0,0) left side facing north

(-1,0,0,0) right side facing north

(0,-1,0,0) back facing north

(0,1,0,0) front facing north

(0,0,1,0) front facing the sky

(0,0,-1,0) front facing the ground

-
You need to be a bit more clear with your question. Are each of the $X,Y,Z$ the same? What does "in front" mean? Are you determining this after the rotation? –  muzzlator Feb 25 '13 at 11:54
if you mean position and quaternon, no, I edited the question to use "pX" and "qX". and as for the front, I know the quaternion combination (1,0,0,0) makes the object face it's front to the north and roof to the sky (up); (-1,0,0,0) makes the back face the north, while the object is still upwards. –  user51593 Feb 25 '13 at 13:30
sorry I mistaked the rotations, edited them accordingly in the question –  user51593 Feb 25 '13 at 13:43

So, let's suppose your "object" is a rocket, and, in its original position, its nose points along the $z$-axis. Then, after transformation by the quaternion $(w,x,y,z)$, the formula on the wikipedia page tells us that its nose points in the direction of the vector $v = (2xz -2yw, 2yz+2xw, 1 - 2x^2 - 2y^2)$. Then, a position $n$ units in front of the rocket is $p + n*v$, where $p = (pX, pY, pZ)$.