Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Quaternions vs Axis + angle

I have been trying to find the difference between the 2 but to no luck minus this

The primary diff erence between the two representations is that a quaternion’s axis of rotation is scaled by the sine of the half angle of rotation, and instead of storing the angle in the fourth component of the vector, we store the cosine of the half angle.

I have no idea what

sine of the half angle of rotation

or

cosine of the half angle

means?

like image 474
Chris Condy Avatar asked Feb 23 '12 16:02

Chris Condy


People also ask

Are quaternions axis angle?

Unit quaternions, known as versors, provide a convenient mathematical notation for representing spatial orientations and rotations of elements in three dimensional space. Specifically, they encode information about an axis-angle rotation about an arbitrary axis.

Are quaternions better than Euler angles?

Quaternions are absolutely more accurate. There is a problem called Gimbal lock which was found in Euler angles. It happens when two axis align together. On the other hand quaternions are more flexible and solved this problem as it is more axis oriented.

What is the benefit of using quaternions instead of Eulerian angles?

For rotations, quaternions are superior to using Euler angles. The reason is that quaternions avoid a problem known as gimbal lock. That happens if two of the three rotational axes happen to align.


2 Answers

Quaternios and Axis-angle are both 4D representations of 3D rotations/orientations and both have pro's and cons.

Axis-angle: represents the rotation by its angle a and the rotation axis n. For example, a rotation of 180 degrees around the Y-Axis would be represented as a = 180, n= {0,1,0}. The representation is very intuitive, but for actually applying the rotation, another representation is required, such as a quaternion or rotation matrix.

Quaternion: represents a rotation by a 4D vector. Requires more math and is less intuitive, but is a much more powerful representation. Quaternions are easily interpolated (blending) and it is easy to apply them on 3D point. These formula's can easily be found on the web. Given a rotation of a radians about a normalized axis n, the quaternion 4D vector will be {cos a/2, (sin a/2) n_x, (sin a/2) n_y, (sin a/2) n_z}. That's where the sine and cosine of the half angle come from.

like image 104
Ben Avatar answered Sep 29 '22 17:09

Ben


It means that if you, for example, want to make a 180deg rotation around the Z axis (0,0,1), then the quaternion's real part will be cos(180deg/2)=0, and its imaginary part will be sin(180deg/2)*(0,0,1)=(0,0,1). That's q=0+0i+0j+1k. 90-degree rotation will give you q=cos(90deg/2)+sin(90deg/2)*(0i+0j+1k)=sqrt(2)/2+0i+0j+sqrt(2)/2*k, and so on.

OTOH, if you're asking what sine and cosine are, check if your languange provides sin() and cos() functions (their arguments will probably be in radians, though), and check out http://en.wikipedia.org/wiki/Sine.

like image 25
vpozdyayev Avatar answered Sep 29 '22 16:09

vpozdyayev