Sign in to follow this  
armond

What are quarterions in Layman's term?

Recommended Posts

A complex number is an abstract representation of a regular number and has two components.

A complex plane is an abstract representation of a 2D plane and has three components.

A quaternion is an abstract representation of space and has four components, at least that's the thought process believed to be had by hamilton when he invented quaternions.

That's how I was taught them.

EDIT:
Think about quaternions in this light, basing what I said in the first part. A regular complex number must be viewed as *really* just being a single number, even though it has two components (hence complex). But, because it has two components, you can put these on the 'complex plane' where one axis is real, the other axis is imaginary. Then, you can start performing rotations and various other transformations, in terms of the complex and real parts of the number that make up the complex plane. Quaternions are just an extension of this idea, except in 3D.

Share this post


Link to post
Share on other sites
Quaternion: a single rotation about a single axis.
Effectively encodes an axis and an angle about that axis.

Combining rotations composed of quaternions is faster and uses less memory than 3x3 rotation matrices (which encode the same information).

Repeated concatentation of 3x3 rotation matrices results in small errors that cause the matrix to become non-orthogonal (non "orthonormal"), resulting in visual skew/distortion/scale. While basic matrix orthogonalization ("orthonormalization") is simple to code, it can result in additional drift, whereas a quaternion can be trivally normalized (a Vec4 normalization) to prevent drift (useful in physics applications).

Rotating a point by a quaternion is more expensive than using a 3x3 matrix, though for one point (as with transform concatenation), it can be faster. Converting to/from quaternions to/from 3x3 matrices is relatively fast (variants for unit-quaternions are slightly faster).

If rotations must be interpolated, quaternions are the most efficient method (lerp (linear), slerp (spherical linear), squad (spherical cubic), etc.).

Share this post


Link to post
Share on other sites
Since you're asking this on a game development forum, it seems likely that you're interested in quaternions as a way to represent rotations. If that's not the case, you might clarify what sort of information you're looking for. Otherwise...

We can discuss the practical application of quaternion rotations without dealing with the complex number aspect. In this context we can think of a quaternion as a vector-scalar pair (v, w), where v is a 3d vector and w is a scalar. Quaternion multiplication is then defined as:

q1q2 = (w1v2+w2v1+v1Xv2, w1w2-v1.v2)

Where '.' is the dot product. Note that for reasons we won't get into here, it is also sometimes defined as:

q1q2 = (w1v2+w2v1+v2Xv1, w1w2-v1.v2)

With the cross-product terms reversed. The unit-length quaternions have the property that:
p' = q*p*conj(q)
Where p is a vector 'encoded' as a quaternion in the form (p, 0), and conj(q) returns (-qv, qw), rotates p by angle theta about a unit-length axis n when q is of the form:
(sin(theta/2)n, cos(theta/2))
From this property a lot of other things fall out, such as that you can contatenate rotations with quaternions as you can with matrices.

The relative advantages and disadvantages of quaternions vs. matrices, Euler angles, and so on are well documented and can be found in various references on the net and elsewhere. I will take this opportunity to mention the two most common quat myths:

1. Quaternions automatically cure gimbal lock
2. Quaternions are the only way to avoid gimbal lock

Both of which are entirely false. So if you find yourself considering quaternions for one of the above reasons, stop! You don't need them! This is completely IMO, but in general I think it can be better not to use quaternions until you know why you need them and exactly what advantages they can offer you.

Share this post


Link to post
Share on other sites
Yes, I am interested in applying this for game rotation. I actually don't have that strong background in mathematics(as I believe but I could be mistaken). But I believe I can well understood the concepts behind all this.Thank you for your explanations, that added to my knowledge. Is there a tutorial where I could get a visual representation of quarterions in actual game(or even if it's not as long as there is a visual representation)? I believe it could help a lot. Thanks guys! ;)

Share this post


Link to post
Share on other sites
If you're using a skeletal animation system or hierarchical system, chances are you'll use quats to describe joint orientations for frames. Smaller and more efficient than using matrices for each joint.

I definitely implement them (it's not such a lot of code) and use them if required - just saves going back to do it later.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this