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?
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With