# converting quaternion to vector3

I am considering taking a given rotation quaternion $Q$, about a given point $P1$, and obtaining a vector3 $V$.

my thought pattern is thus: given a point $P1$, and a quaternion $Q$

obtain another point $P2$ in the direction of $Q$ an arbitrary distance X away (could equal 1),

then subtract those 2 points to arrive at a unique vector3 $V$

Is this sound logic, or have I made a mistake somewhere, and how would I arrive at $P2$ as I am a little lost on this?

EDIT: clarified problem

-
What do you mean by "in the direction of $Q$"? Overall, what are you trying to achieve? –  Rahul Apr 30 '12 at 18:18
@rahulnarain from my understanding a quaternion gives an orientation about a point, and then getting a second point in the direction of that orientation would yield a vector, or am I missing something? –  gardian06 Apr 30 '12 at 19:05
I think you're a little bit confused about what vectors represent - a vector is, at least in some sense, 'baseless' - they can exist anywhere, so as has been noted there's no need for P1 here. It might be more useful to explain what you're intending to do with the vector - as Rahul asks, what are you trying to achieve? –  Steven Stadnicki Jun 6 '12 at 16:01
@StevenStadnicki yes a vector is 'baseless', but at the same time not. A vector is by definition a magnitude, and a direction, but what makes them baseless is that they can be placed anywhere, and still have the same meaning. the same way that a quaternion is baseless as it is only an orientation that can be applied to any thing. my goal was to be able to use a quaternion to obtain a vector3 such that something like a forward, or look vector could be found, but thanks to some reasoning work a Vector3 can be treated as a quaternion which simplifies the problem to a quaternion identity. –  gardian06 Jun 6 '12 at 17:01

This question actually has flawed logic: even if $P1$ is given in order to arrive at $P2$ in 3space would require a vector3, so by nature you would need the very vector being solved for to even approach the problem.

Though it is still possible to work through the problem there is just more then one solution to the problem as follows.

Given a quaternion representing a rotation in 3space an axis-vector may be chosen to be manipulated by the quaternion to arrive at a vector in the direction of the quaternion, and the axis-vector chosen determines the solution found. technically there are 6 solutions for any given quaternion if not Vector to be rotated is given.

By virtue of quaternion multiplication $v' = q * v * q^*$ ($q^*$ referring to the conjugate of $q$) keeping in mind that this equation only holds if $v$ is not the zero-vector $<0,0,0>$, and $q$ is not the multiplicative identity $<1,0,0,0>$, and has been normalized.

treating the components of the vector $v$ as the imaginary vector ($ijk$) of a second quaternion, and the real portion of that quaternion as $0$. therefore $<x,y,z>\rightarrow<0,x,y,z>$, and quaternion multiplication can take place.

solution

$v'=q*v*c$ ($c$ referring to conjugate)

$=<Qw,Qx,Qy,Qz> *<0,Vx,Vy,Vz>*<Cw,Cx,Cy,Cz>=<0,V'x,V'y,V'z>$ shorthand without having to do all multiplication step by step:

v'x = 2*(Qw*Vz*Qj + Qi*Vz*Qk - Qw*Vy*Qk + Qi*Vy*Qj) + Vx*(Qw^2 + Qi^2 - Qj^2 - Qk^2);
v'y = 2*(Qw*Vx*Qk + Qi*Vx*Qj - Qw*Vz*Qi + Qj*Vz*Qk) + Vy*(Qw^2 - Qi^2 + Qj^2 - Qk^2);
v'z = 2*(Qw*Vy*Qi - Qw*Vx*Qj + Qi*Vx*Qk + Qj*Vy*Qk) + Vz*(Qw^2 - Qi^2 - Qj^2 + Qk^2);


text file containing diriviation can be obtained upon email request

-
can you please email me with the full dirivation Ahmed_namek@live.com –  Ahmed Namek Mar 21 at 16:14