converting quaternion to vector3

1.6k Views Asked by At

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

1

There are 1 best solutions below

0
On BEST ANSWER

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