# Multiplying quaternions

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

## 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 on other sites
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 on other sites
So would Q(60, 1.0, 1.0, 0.0) be the same as Q1(60, 1.0, 0.0, 0.0) * Q2(60, 0.0, 1.0, 0.0)?

##### 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 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 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 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 on other sites
Quote:
 Original post by someusernameThe 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 on other sites
I've seen this being mentioned -in articles about quaternions- quite often. To be honest, I've never tried it directly. You may be right

##### 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.

1. 1
2. 2
3. 3
Rutin
20
4. 4
5. 5
khawk
14

• 9
• 11
• 11
• 23
• 12
• ### Forum Statistics

• Total Topics
633655
• Total Posts
3013175
×