Axis angle to Vector

Started by
15 comments, last by Nanook 14 years, 5 months ago
but in alvaro's example rotated_vector is the new direction?

Advertisement
I got a function to do quaternion * Vector3 , but how do I do Vector3 * quaternion? I've tried to look around for a formula, but cant find one?
Quote:Original post by Nanook
I got a function to do quaternion * Vector3 , but how do I do Vector3 * quaternion? I've tried to look around for a formula, but cant find one?


In the formula I posted, both multiplications are simply quaternion multiplications. The Vector3 in the middle is to be interpreted as a quaternion with 0 real part, x*i+y*j+z*k.

I think what alvaro wrote might be a bit cryptic - what it means is that you pretend the vector is a quaternion - make a new quaternion, set x,y,z directly from the vector and set w=0. Then you can multiply as normal.
but that would return a quaternion though? And I need the direction vector..
Quote:but that would return a quaternion though? And I need the direction vector..
It does return a quaternion, but you can convert this quaternion back to vector form by dropping the 'w' component.

You mentioned though that you have a 'quaternion * vector3' function available. I'm guessing that this function in fact rotates the input vector using the specified quaternion. If so, it's a clear case of operator overloading abuse (IMO), but is nevertheless probably the easiest way to perform the rotation that you need. Or, you could do it 'manually' as described previously.

To reiterate, all you need to do to find the current direction vector for your object is to transform the local-space forward direction vector using the object's transform. If this isn't working for you, perhaps you could post the relevant code and describe exactly how it's not working.
I got it working now.. I found out my quaternion class was not working properly.. been having trouble with this for a long time.. as quaternions are a bit ahead of what we've learned so far we downloaded a quatarnion class from the net so I thought it was me doing something wrong, but it was actualy the class :p

Thanks for your help :)

This topic is closed to new replies.

Advertisement