# Convert quaternion to vector? [closed]

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.

## closed as unclear what you're asking by Travis, rschwieb, Hans Lundmark, achille hui, JMoravitzApr 26 '17 at 16:52

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• Your question is extremely unspecified. "Given four real numbers, how can I get three real numbers from it?" Lots of ways. I would guess that you mean for the vector to be related to the quaternion in a nice way. You really should tell us what that is. I myself am not aware of any natural correspondence between $\mathbb H$ and $\mathbb R^3$ that is worth mentioning. – rschwieb Apr 26 '17 at 13:00
• Is "the weight" some universal constant? or is it related to the quaternion somehow? Are you talking about a rotation quaternion, and you want to find its axis? I guess not, if "the weight" turns out to be the length... – rschwieb Apr 26 '17 at 13:01
• @rschwieb There is one very important application of quaternions that gives a certain subset of the quaternions a very tight correspondence with vectors of $\Bbb R^3$, and that is rotations. I don't know whether this one is such a quaternion, though... – Arthur Apr 26 '17 at 13:07
• @rschwieb : Yes, im talking about rotation quaternions, and Im asking you : How do I need the weight when converting to a 3d vector ? – LMD Apr 26 '17 at 13:10
• @rschwieb : it represents the direction the camera is pointing after a rotation is applied, you were right. But I havent understood how you convert them in your answer. – LMD Apr 26 '17 at 16:07

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)$

• 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. Yes, so I was asking how can I represent the quaternion as vector. How can I express/calculate the vector ? So quaternion(abcd), vector=bcd ? Yes, Im talking about recovering the direction vector, youre totally right !, but i havent understood, for example, lets take the quaternion (x=4,x=3,x=2,w=1) how you would now calculate the vector ? – LMD Apr 26 '17 at 15:59
• @user7185318 From your last comment in the post's thread, you seem to have confirmed that you are actually looking for the final direction of the line of sight of a rotated camera. Let's go with that. So my response is: the last paragraph of my answer tells you how to find the final line of sight of a camera given its initial line of sight. I will say (for the umpteenth time) that "the direction vector of a quaternion" does not make any sense to me. You can talk about the direction of the axis of rotation, or the direction an input vector after it is transformed by $q$ – rschwieb Apr 26 '17 at 17:04
• If you want to know what direction a camera points after it has been rotated by this quaternion you are going to have to tell me where the camera is initially pointing. – rschwieb Apr 26 '17 at 17:04
• There appear to be lots of typos in your comment, but if you mean that you have a rotation quaternion $w+xi+yj+zk$, then its axis of rotation lies in the direction of $xi+yj+zk$. What more can I say? – rschwieb Apr 26 '17 at 17:06
• initially pointing x=0 y=0 z=1 – LMD Apr 26 '17 at 17:12