# Quaternion, why divide angle by 2?

## Recommended Posts

I'm trying to understand why the formula for creating a quaternion from an axis angle representation divides theta by 2:

$$cos(\theta / 2), \hat{v}sin(\theta/2)$$

As far as i understand this is because quaternions do double cover? IE a quat represents 720 degrees of rotation, not just 360? But that doesn't make much sense to me, since cos(45) = cos(45+360) = cos(405). Like any input to cos is going to yield the same output.

So yeah, i don't get this, why is the angle divided by 2?

Edited by mathematical

##### Share on other sites

I'm no expert, but you can also think about reflection: To rotate a vector, you can reflect it over the plane which is at half of the total angle between initial and resulting directions.

For me thinking about reflection worked to understand how rotating a vector works geometrically, by looking at the involved cross product(s) and it's angular properties. Although historically quaternions came up before cross product math, the latter is better for visualization and geometrical understanding - at least for me.

But i still do not well understand how rotating an orientation works (quat multiplication). And i don't know any guy who really does  I've tried to reinvent this with cross products as well, which worked but had a few math operations more and became too complex to get into my head already.

##### Share on other sites

In your example, the normal of the plane were reflecting about is the axis of rotation?

##### Share on other sites
7 minutes ago, mathematical said:

In your example, the normal of the plane were reflecting about is the axis of rotation?

the plane normal would be tangent to the axis of rotation, but we're likely confused of each other - let's use some numbers:

vec a (1,0,0);

vec b (0,1,0); // a rotated by 90 degrees

axis of rotation: (0,0,1)

reflection plane normal: (0.7, 0.7, 0), which is a rotated by 90/2 degrees

(forgive any sign errors of mine)

So, i've already forgotten what i once knew in detail, but if you use this common code to rotate vector by quat:

vec temp = cross(q.xyz, initialVector) * 2;

rotatedVector = initialVector + q.w * temp + cross(q.xyz, temp);

... and you take some time to visualize all those vectors, you can see how it works by reflection.

##### Share on other sites

You can sort of find an explanation here.

##### Share on other sites
6 hours ago, mathematical said:

As far as i understand this is because quaternions do double cover? IE a quat represents 720 degrees of rotation,

A quaternion is a 4D object. So we use it to calculate a 4D rotation that looks good in 3D but is the inverse in 4D. The dividing corrects it in the forth dimension.

It's easier to understand when you visually see it. Think of what happens to a 2D rotation, when viewed from the side:

See from the side it looks like the same rotation. If a person in 1D viewed a 2D rotation they would only see the ball move up and down, never seeing the rotation.

The same thing happens to us when we view a 4D rotation, we can only see the 3D part and the result looks like the same rotation, but in the forth dimension the two rotations are not the same and so mathematically they are not the same.

So by dividing theta by 2 we convert the 4D rotation, back into the rotation we want it to be, to agree with our 3D view of it.

I was lucky and found a video that shows the 3D rotation of a quaternion. It looks well made. It even uses projection to help visualize the rotation.

##### Share on other sites

There is a theorem (classification of compact Lie Groups) that says there is only one associative, multiplicative structure on the 3-sphere (up to an isomorphism). It's generated by 1, i, j, k such that

i^2=j^2=k^2 = i*j*k = -1

So your question is can we have i, j and k represent rotations by 90 degrees instead of 180? Let's assume that they represent 90 degrees, then -1 = i^2 represents a rotation by 180 degrees.

But you can convince yourself that i*j*k is not a rotation by 180! So this is not possible. In fact the equations i^2=j^2=k^2 = i*j*k = -1  only hold if i, j and k represent rotations by 180:

if Rx(a), Ry(a) and Rz(a) are rotations by angle a around x, y, z respectively, then we must have:

Rx(a)^2 = Rx(a)*Ry(a)*Rz(a)

Multiplying by the inverse of Rx(a) on the left:

Rx(a) = Ry(a)*Rz(a)

If you write this equation in terms of elementary rotation matrices containing sin(a) and cos(a), you will find the solutions are: a = 0, 180, 360...

But obviously a = 0, 360,.. are the trivial solution (where each quaternion is a rotation by 0 angle). So it must be that a = 180.

##### Share on other sites

This is a bit more confusing than i expected it to be.

@Scouting Ninja If i'm getting your example correct, you have two angles on the circle ~135 and ~225. When projected onto a 1D line, both angles look the same, even tough they are not. In this example, if we where to divide the angle by 2 it would effectively eliminate the bottom hemisphere of the circle, mapping 135 to 67.5 and 225 to 112.5. This would make it so all 360 degrees are mapped to the upper hemisphere of the circle, meaning if we where to project it onto a straight line, every value would be visible. Did i get that right? Expanding that to quaternions would make a lot of sense.

@JoeJ I'm still working trough visualizing the numbers you provided, will probably have some question later.

@Maciej Mizerski That's a bit above my head. I was not aware that i,j,k represented rotations of 180. I'm not sure how eliminating the divide by 2 would cause them to be 90 instead of 180... What i think i get from your explanation is that when dividing theta / 2, then sin(180/2) = 1, so at 180 degrees i = 1, I'm not really grasping the significance of this....

I've read a few sources that explain the need to divide by 2 as a result of conjugation, so multiplying a vector would be $$qpq^{-1}$$, that is q needs to rotate p half way, then q-1 needs to go the other half. One of the most intuitive explanations i heard about this is that we're not just rotating on one plane, rather both the real and vector parts of the quaternion rotate the vector. So you want to rotate half way, then invert the quat and rotate the other half. Inverting will undo one of the planes that we're rotating on, putting the vector back on a 3D plane.... I'm going to write some code tomorow to try and visualize both qp and (qp)q', see if i can maybe make sense of that.

##### Share on other sites
1 hour ago, mathematical said:

i'm﻿﻿ ﻿﻿getting﻿ your example correct, you﻿ have two angles on the circle ~135 and ~225.

Yes, sorry I should have mentioned that I was only expanding on the answers above. They where correct, we divide by 2 to mirror the rotation around a hyperplane.

You could achieve the same static result using -1*theta. The problem is that your rotation animation will look like it is imploding, literally rotating within itself and disappearing.

So the theta/2 rotates in on two other axis, 90 degrees on one and 90 degrees on the other; like a Rubik's cube. This is what a hyperplane is, we make a 3D rotation by manipulating 4D.

In 3D space we see a smooth left/right hand 180 degree rotation. While in 4D it is 90degree on one axis and 90 degree on the other.

Quaternion is one of the common Euclidean Hyperplane types. Divided into two hemispheres. +1 and -1 hemispheres.

I hope this helps a little. I recommend working your way up from 1D.

##### Share on other sites
12 hours ago, mathematical said:

@Maciej Mizerski That's a bit above my head. I was not aware that i,j,k represented rotations of 180. I'm not sure how eliminating the divide by 2 would cause them to be 90 instead of 180... What i think i get from your explanation is that when dividing theta / 2, then sin(180/2) = 1, so at 180 degrees i = 1, I'm not really grasping the significance of this....

There is a function that takes a quaternion and makes a rotation matrix out of it. This function sends:

• the quaternion i to the rotation Rx(180)
• the quaternion j to the rotation Ry(180)
• the quaternion k to the rotation Rz(180)

More generally this function (call it M) works like this:

• M( cos( t ) + i * sin( t )  ) = Rx( 2 * t )
• M( cos( t ) + j * sin( t )  ) = Ry( 2 * t )
• M( cos( t ) + k * sin( t )  ) = Rz( 2 * t )

Your question is why we have a "2" in the Rx( 2 * t ) (or rather your question is why the "inverse" of M has a division by 2). In my previous answer I attempted to demonstrate that you can't have anything else than 2 (like you said it is indeed a double cover).

In other words one is forced to have this "2" factor because otherwise the multiplication on the quaternions would not be compatible with the multiplication on the rotation matrices. By "compatible" I mean M(q*p) = M(q)*M(p) for two quaternions q and p.

Edited by Maciej Mizerski

## Create an account

Register a new account

1. 1
Rutin
36
2. 2
3. 3
4. 4
5. 5

• 11
• 10
• 13
• 98
• 11
• ### Forum Statistics

• Total Topics
632974
• Total Posts
3009654
• ### Who's Online (See full list)

There are no registered users currently online

×