GWM Quaternions are a generalised complex number which have had a lot of use in scientific analysis of 3 dimensional space, navigation and guidance systems for rockets etc. Invented (or discovered?) by Sir W Hamilton on his way to a meeting, he stopped at the side of a bridge in Dublin and scratched the equation into the stone. The bridge is now known as Hamilton's Bridge or Brougham Bridge. (See http://math.ucr.edu/home/baez/octonions/node24.html for some pictures of the bridge.)
A relative of Robert Graves (writer of I Claudius and other well known books) relates in his autobiography that one of his realtives (John Thomas Graves) assisted Hamilton with the quaternion; mathematicians (eg http://math.ucr.edu/home/baez/week152.html ) relate his work to octonions which are an extended quaternion. Octonions are created by replacing the 4 real components of the quaternion with 4 complex numbers, ie 8 real numbers....
Quaternions can be thought of as rotations, and consist of 4 real components. http://mathworld.wolfram.com/Quaternion.html
For comparison with Complex Numbers, they can be written:
q = q₀ + q₁.i + q₂.j + q₃.k
where 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=-j
Lars 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:
For a suitable choice of coordinate systems (absolute for position and center of mass velocity, principal axes of inertia for angular velocity), the equations of motion come out with interesting properties for numerical simulations. This also forms the basis of a very nice description for multibody systems (systems of rigid bodies with constraints, i.e., mechanisms. Think robotics, for instance.)
Note: The equivalent description in 2D would be using a vector in R^7: cartesian position of center of mass, a unit complex number to describe the angle, cartesian components of the velocity of the center of mass, and angular velocity. Does not make so much sense in 2D though, as the configuration space can be covered singularity-free in a single chart.
If there is interest, I may expand on this sometime ... involves rummaging my psychological attic, plenty of cobwebs there :)
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 extensions
GWM - 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: