Jump to content
  • Advertisement
Sign in to follow this  
Ganoosh_

Multiplying quaternions

This topic is 4629 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

What is the effect of multiplying quaternions? I thought maybe it'd multiply their effects like matrices but it doesn't seem to do that. I know you can use it to reverse a rotation, but other than that what would you use it for? Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
It is similar to multiplying matrices. The rotation R3 which is represented by the result Q3 of multiplying quaternions Q1 and Q2, is the same as the rotation which is represented by the result M3 of multiplying rotation matrices M1 and M2.

Share this post


Link to post
Share on other sites
None of those are valid quaternions. Did you mean the quaternions which correspond to rotations expressed in axis-angle form? If so, no, that's not what it comes out to. That's not how quaternions OR matrices work, because it's not how rotations work.

Share this post


Link to post
Share on other sites
Why aren't they valide quaternions? I mean them to be about an arbitrary axis. At least the first one should be, but I can kinda see how multiplying the 2 wouldn't work out that way.

Share this post


Link to post
Share on other sites
Quote:
Original post by Ganoosh_
Why aren't they valide quaternions? I mean them to be about an arbitrary axis. At least the first one should be, but I can kinda see how multiplying the 2 wouldn't work out that way.
I'm not sure, but it looks like you might be thinking that rotation quaternions are of the form:
[angle in degrees, axis.x, axis.y, axis.z]
Actually, the representation is:
[cos(angle/2), sin(angle/2)*axis.x, sin(angle/2)*axis.y, sin(angle/2)*axis.z]
(With c++ trig functions, the angle must be in radians.) Quaternion multiplication also has a more complex form than you may be assuming.

Check out a good game math book for details, or google for info on the net. (Just watch out for misinformation, as there's about as much incorrect info online about quats as there is correct info. Well, that's probably an exaggeration, but just be sure to compare multiple sources and not believe everything you read.) Also, in general I'd recommend not messing with quats at all until/unless you have a solid handle on rotations in general (i.e. understanding axis-angle, Euler angle, and matrix rotations).

Share this post


Link to post
Share on other sites
Quaternions only represent orientations/rotation when they are unit quaternions. A unit quaternion {w,x,y,z} has w2+x2+y2+z2=1. Otherwise, I suppose, they produce distortions such as scaling or skewing.

The product of three unit quaternions (q2*q1)*v has the effect of rotation q2 following rotation q1, on the quaternion v. v is essentially a 4-vector with w-component==0, and {x,y,z} components equal to the components of the 3-vector you wish to tranform. The fact that the order in which rotations are performed affects the final result, should give you a hint that quaternion multiplication is not commutative.

If you want to rotate by angle w (in radians) around an axis v, you should produce the quaternion {cos(w/2),sin(w/2)*axis.x, sin(w/2)*axis.y, sin(w/2)*axis.z}. I don't remember the multiplication formula by heart. You shouldn't have trouble finding it

Share this post


Link to post
Share on other sites
Quote:
Original post by someusername
The product of three unit quaternions (q2*q1)*v has the effect of rotation q2 following rotation q1, on the quaternion v. v is essentially a 4-vector with w-component==0, and {x,y,z} components equal to the components of the 3-vector you wish to tranform.
I think you may have the quaternion rotation formula wrong (or perhaps I'm misunderstanding your post)...

Share this post


Link to post
Share on other sites
Let me just blatantly advertise this book, since it's so relevant. [smile]

This book is a great resource for learning quaternions (and rotations in general in 2- and 3-dimensional Euclidean spaces). I honestly couldn't recommend it more.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!