Skip to main content
GameDev.net gamedev.net
🔒 Locked 🎮 Unity

Transformation Law Problem

Started by i-photon Apr 4, 2005 at 1:49 AM 2 replies 550+ views
Original Post
i-photon
i-photon
I have seen this fromula for rotating a vector by a quaternion: v' = Im(q*v*(-q)) where (-Q) is the conjugate Wich many articles describe as 'The Transformation Law'. I've tried it using the rules described in several books and pdfs for multiplication by the two entities. However, when I create a quaternion like this: ... Quaternion Q(cos(theta), sin(theta)*axis); ... and then 'rotate' by using the above formula, the result is most certainly not a rotation, let alone anything meaningful. I have thouroughly checked my operators to ensure that they were identical to those described in each article. However, in every article and book, there has always been a missing gap of information regarding how to properly create a quaternion for said rotation. I have consulted many articles on this; some say that you accept a vector as a quaternion with 0 real part, others say that you create one through the quaternion exp() function, and the rest say that you create one just as I did above. None of these worked for me. Am I missing a step somewhere? Any help will be greatly appreciated!
Zakwayda
Zakwayda
It's hard to say where the problem is, but here are a few bits of information (all of which you may already know):

1. Typically the vector is represented as a quaternion with w = 0. I think it may also be the case that the equation works the same way regardless of the value of w, i.e. [x y z w] rotates to [x' y' z' w]. I'd have to check on that though. In any case, for constructing the 'v' quaternion, no changes are made to the vector components. It's simply:

[x y z] -> [0 x y z]

2. q is constructed from a unit-length axis n and an angle theta as:

[cos(theta/2), sin(theta/2)n]

You didn't have the /2 in there, although that should just scale your rotation, not throw it off completely.

3. Quaternion multiplication is:

[w1 v1][w2 v2] = [w1w2-v1.v2, w1v2+w2v1+v1Xv2]

4. Quaternion conjugate is:

[w v]* = [w -v]

That should give you everything you need to properly rotate a vector using qpq*. If it still doesn't work, you might try posting your code.
i-photon
i-photon
Thanks! I guess I read so many times through the papars, I didn't even see that angle division. A tremendous DUH on my behalf :P

I'll give it a try.
i-photon
i-photon
It worked fine, thanks for pointing that out!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.