q = q₀ + q₁.i + q₂.j + q₃.kwhere i,j,k are all square roots of -1 AND all different. i,j,k obey the following rules:
i*i = j*j = k*k = ijk = -1 i*j = k j*i=-k j*k = i k*j=-i k*i = j i*k=-jLars H: Note that quaternion multiplication is not commutative. In the non-real part, it is actually anti-commutative: j*i=-i*j, k*j=-j*k, i*k=-k*i.GWM Using these rules 2 quaternions can be multiplied to make a new quaternion which obeys the same rules. Thus the product of 2 quaternions results in another quaternion - it is a closed system of 'numbers'. If we want to visualise a quaternion, consider i,j,k to be the X,Y,Z axes of space and the q₁,q₂,q₃ is a position in space (or a vector) and q₀ a magnitude associated with that position.Note that the products of i with j, j with k etc are similar to the right hand rule for cross product of 2 vectors. Thus if a quaternion relates in some way to a physical field, then the product of quaternions can represent such effects as gyroscopic precession, spin precession in atoms etc.Lars H: The physical usefulness of quaternions is highly debatable. In the late 19th century they were indeed used for calculations in electromagnetism, but mostly because the properties of the vector cross product were seen as too queer for it to be a proper mathematical operation. As the vector formalism was simpler and more to the point, it won the battle for dominance. The only lasting impression the quaternions made is the use of i,j,k for basis vectors in 3-dimensional space.GWM Nonetheless, if you have flown in a commercial airliner in the last 20 years or so its gyro compass data was processed into the position of your aircraft using a quaternion. Quaternions are used in calculation of Pauli spin matrices (particle physics). That is an awful lot of quaternions actually in use. Although not used as much as vector forms, Quaternions should be part of the armoury for dealing with vectors, and they represent another aspect of maths that real & complex numbers are not the only valid mathematical systems. In visual simulation (and games) many matrices (eg to rotate a persons simulated arm) are constructed from Quaternions as the interpolation of a quaternion is easier and smoother than interpolating Euler angles.An important class of quaternions is a normalised or unit quaternion (one where q₀²+q₁²+q₂²+q₃² equals 1); the product of 2 unit quaternions is still a unit quaternion. If the q₀ parameter is regarded as a rotation about the vector (q₁,q₂,q₃) then the product quaternion is equivalent to the total rotation produced by applying the rotation of the first quaternion to an object rotated by the second quaternion. Thus quaternions relate strongly to rotation matrices. They have the advantage over Euler Angles that they do not have singularities and are a more linear rate of change when used to represent the attitude of a vehicle. (Imagine an aeroplane suddenly turning nose upward; as the nose goes through vertical the direction of flight of your aircraft changes from due North to due South in zero seconds, a problem for integrating Euler angles).Non-unit quaternions can be used to express the distortion of time and space expressed in Einstein's Relativistic relations.MS Hey, memories ...The configuration space (space of positions) of a rigid body in 3D is a 6-dimensional manifold. It cannot be covered by a single coordinate map, there are always singularities if you use only 6 coordinates (position of the center of mass and Euler angles, for instance).Motion simulations thus require either code to deal with the singular positions (and the loss of accuracy near them), or else the use of redudant coordinates with constraints. The cheapest is to use the cartesian coordinates of the center of mass, and a unit quaternion for the attitude.The state space of the body (position and velocity, or position and momentum depending on the type of equations used) can then be described by a vector in R^13 subject to one constraint:
- cartesian coordinates of center of mass
- unit quaternion for attitude (constraint: norm is 1)
- cartesian components of velocity of center of mass
- cartesian components of angular velocity
WHD: IIRC, OpenGL uses something it calls quaternions to represent points in three space: (i,j,k,s) where s (corresponding to q₀ in the above) is a scale factor, i.e., (i,j,k,s) represents the same point as (i/s, j/s, k/s, 1). Apparently this makes doing many kinds of transformation easier.MKG: I think OpenGL calls this "homogeneous coordinates" and this representation can be used to represent points at infinity in 3D space. The equations used for homogeneous coordinates, however, are quite different from the quaternion equations so I doubt that you can mix and match them directly.GWM correct - Quaternions are different (I dont think Opengl calls them quaternions though they do use 4 numbers- give a reference if they do, we'll get them sorted-). The homogeneous coordinates are useful for (i) transforms with rotation & translation (turn & position) and (ii) for perspective correction of coordinates from 'real world' to screen. If the word quaternion appears in OpenGL specification it is probably wrong. A general 4*4 matrix, operating on a 4 vector looks like this:
[r r r 0] [r r r 0] [r r r 0] [x y z 1].gwm Operate on [abc1] and you get:
[r r r 0] *[a]=R*(a,b,c) + (x,y,z) [r r r 0] [b] [r r r 0] [c] [x y z 1] [1]ie the 4*4 matrix describes rotation & movement in 1 operation. OpenGL (and D3D) graphics cards are optimised to perform this sort of 4*4 matrix operations. Good domestic graphics cards do 10-100 million of these operations per second.Mixing a quaternion set of values with a homogeneous coordinate would produce as useful a number as multiplying the price of potatoes (in £/kg) by the exchange rate of Saudi riyals to the dollar.DKF: Those matrix ops are discussed more at Affine transforms on a canvas.
AM See also the Math package by Martin Russell - Mathematically oriented extensionsGWM - gives the basic quaternion transforms and quaternion mathematics. Quaternions are nothing if you misuse them, just 4 numbers. I hope this short article will either:
- Start you thinking how to use quaternions OR
- Help you realise that you don't need quaternions.