Original Post
Anybody know how to use quaternions to orient a mesh in OpenGL?? It does not make sense to me how 3 imaginary numbers and a real number can represent the orientation of a mesh.
Quote:
Original post by Sneftel
First of all, they aren't three imaginary numbers and a real number. They're four real numbers which are used as a single four-dimensional complex number, just as two real numbers can be used as a single two-dimensional
Quote:
Original post by Sneftel
A "complex number" is a number in complex space (where complex space has 2, 4, or 8 dimensions) that is not a real number. But yeah, it can be thought of as three imaginary numbers and 1 real number. The reason I refer to it as 4 real numbers is to hammer in the point that there are exactly 4 scalar quantities and that quaternions are thus a 4-dimensional space.
Quote:
Original post by someusername
edit:
I'm tired of posting this, but you'll probably need it...
To convert the quaternion to a DCM matrix (orientation) do the following:
Define vectors: localX, localY, localZ to store the object's local axes
localZ = Normalize( quaternion rotation axis {x,y,z} );
localX = cross( localZ, 'unit world up vector' );
localY = cross( localZ, localX );
The orientation matrix will be the product: R*O,
where R is:
[ cos(w) -sin(w) 0 0 ]
[ sin(w) cos(w) 0 0 ]
[ 0 0 1 0 ]
[ 0 0 0 1 ]
and O is:
[ localX.x localY.x localZ.x 0 ]
[ localX.y localY.y localZ.y 0 ]
[ localX.z localY.z localZ.z 0 ]
[ 0 0 0 1 ]
This is the DCM matrix for your object.
If you are using a left-handed system, negate the results of the cross products, and if you work with row-vectors instead of columns, use the transpose of that product.
Btw, have you come across this in physics simulation? I've lately discovered that people often choose this approach, to describe the instantaneous axis of an object's rotation and the angle it has rotated by, with respect to its previous state, when solving for the specific time step.
Quote:
Original post by Sneftel
(where complex space has 2, 4, or 8 dimensions)
Quote:
Original post by someusername
Quaternions are used in rotations, because they can uniquely describe an axis (3-vector) and an amount of rotation around that axis. The only possible way I see, to determine an orientation from a quaternion, is *to make a convention* that the rotation axis should always represent the "look-at" axis of your object (this one is usually the local Z axis), and the remaining scalar part should represent the 'roll angle' of your object around that axis. This is enough information to uniquely describe an orientation in 3d space.
Quote:
Original post by nilkn Quote:
Original post by Sneftel
(where complex space has 2, 4, or 8 dimensions)
Actually, by the Cayley-Dickson construction, you can keep going on and on ad infinitum. But after the sedonions (16-dimensions), things start getting weird (e.g., zero divisors et. al.).
Quote:
Original post by Anonymous Poster Quote:
Original post by Richy2k Quote:
Original post by Sneftel
First of all, they aren't three imaginary numbers and a real number. They're four real numbers which are used as a single four-dimensional complex number, just as two real numbers can be used as a single two-dimensional
Isnt it 3 complex numbers and 1 real number. W(X, Y, Z): W being the Real number?
This person is correct, Sneftel. A quaternion is a number which can be said to be made of 3 imaginary and 1 real part.
This topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform. You can accept analytics or continue with necessary cookies only. Learn more