# quaternions help

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

## Recommended Posts

hi, I'm currently trying to load and animate a mesh, there are three animation keys - scale(vector), translate(vector), and rotate(quaternion). I'm having trouble understanding what a quaternion actually represents, I've been reading up on complex numbers and understand how they work, basically representing a real number with an imaginary i where i = sqrt(-1). I read somewhere that a quaternion can be thought of as a 3d vector and a rotation value(euler(i think?)) in 3d space, is this true or is it more complex?

##### Share on other sites
Geometrically, you can think of a quaternion as a vector and an angle of rotation around that vector. However, these values are not stored directly in the quaternion.

If you have a vector v = (x, y, z) and an angle A, and you want to construct a quaternion (qw, qx, qy, qz) that represents a rotation by A degrees around v, you would do this:

qw = cos(A/2)
qx = sin(A/2) * x
qy = sin(A/2) * y
qz = sin(A/2) * z

##### Share on other sites
Quote:
 Original post by staticVoid2I read somewhere that a quaternion can be thought of as a 3d vector and a rotation value(euler(i think?)) in 3d space, is this true or is it more complex?

I would not try to interpret anything from the values of a quaternion; trust me, it will not work in general but produces headache. E.g. think of a rotation of 180° around any axis; the equivalent quaternion is [ 1 0 0 0 ]T. If you interpret that geometrically then it appears as a rotation around a vanished axis. So don't do it.

A quaternion, to be exact a _unit_ quaternion, is just another representation of rotation. Keep them as a mathematical tool, and that's it.

There is a concrete axis/angle representation for rotations as well. Those representation defines a plane (yes, mathematically there is no _axis_ of rotation but a _plane_ of rotation, and the plane is given by its normal what is often named the "axis"; that's the reason why rotation works also in 2D) and a single angle denoting how far the rotation goes. That angle has nothing to do with Euler angles. However, the axis/angle rotation can easily and exactly be interpreted in geometrical terms. And it is very easily converted to quaternion and vice versa (see e.g. Gage64's post above). The formulas of the conversion misleads one to think of quaternions geometrically, but, as said, I urge you not to do so.

1. 1
Rutin
65
2. 2
3. 3
4. 4
5. 5

• 16
• 10
• 29
• 20
• 9
• ### Forum Statistics

• Total Topics
633415
• Total Posts
3011766
• ### Who's Online (See full list)

There are no registered users currently online

×