Convert quaternion to vector?

12.7k Views Asked by At

Lets assume I have a rotation quaternion Q={1,1,1,0}, which represents a specific pointing direction, how can I extract this Vector(xyz) from it ? Or, how can I determine a matrixs determinante, because I already have a working solution that converts a quaternion to a matrix.

1

There are 1 best solutions below

10
On

If you are talking about recovering the direction vector for the axis from a rotation quaternion, and $q=a+bi+cj+dk$, then axis of rotation is the same direction as

$bi+cj+dk$, which would be the vector $(b,c,d)$ in $3$-space. If you need the unit vector in the direction you just normalize this, of course.

how can I determine a matrixs determinante,

Every rotation matrix you would convert a quaternion to has determinant $1$, so... I have no idea where you're going with that.

a rotation is nothing more then something that tells you how you are rotated , in which direction you are looking, and that can also be expressed as vector.

You seem to be having some difficulties expressing what you mean, and I think that this might stem from your belief that a quaternion represents a direction somehow. It doesn't, really. It represents a transformation (a rotation) of $3$-space in the context you are talking about.

What I think you're thinking of is this: given a camera pointing along (say) the $x$-axis, what direction will it be pointing after the transformation? That is a well-posed question, but it's not solely based on the quaternion, it's also based on the other input (the initial direction of the camera.)

In that case, then you're just going to have to take your initial camera direction expressed as a quaternion with real part zero (say $xi+yj+zk=v$) and see where it winds up pointing after $qvq^{-1}$.


Here is a concrete example based on the things you have said so far in the post and the comments. Suppose we have a camera pointing up the $z$ axis, and "the quaternion (x=4,x=3,x=2,w=1)" by which I guess you mean $4i+3j+2k+1$. We need to apply this quaternion to the vector for the camera's initial orientation $0i+0j+1k+0$.

Normally you would not deal with a rotation quaternion that is not unit length. But it turns out that for the purposes of rotation, doing $qxq^{-1}$ does the same thing whether or not you have normalized $q$. So we'll skip normalizing $q$.

The direct computation is $(4i+3j+2k+1)k(4i+3j+2k+1)^{-1}=\frac{22}{30}i+\frac{4}{30}j-\frac23 k$.

So the final direction of the camera is $(\frac{22}{30},\frac{4}{30},-\frac23)$