HOME

TheInfoList



OR:

Unit Unit may refer to: Arts and entertainment * UNIT, a fictional military organization in the science fiction television series ''Doctor Who'' * Unit of action, a discrete piece of action (or beat) in a theatrical presentation Music * ''Unit'' (a ...
quaternion In mathematics, the quaternion number system extends the complex numbers. Quaternions were first described by the Irish mathematician William Rowan Hamilton in 1843 and applied to mechanics in three-dimensional space. Hamilton defined a quater ...
s, known as ''versors'', provide a convenient
mathematical Mathematics is an area of knowledge that includes the topics of numbers, formulas and related structures, shapes and the spaces in which they are contained, and quantities and their changes. These topics are represented in modern mathematics ...
notation for representing spatial orientations and
rotation Rotation, or spin, is the circular movement of an object around a '' central axis''. A two-dimensional rotating object has only one possible central axis and can rotate in either a clockwise or counterclockwise direction. A three-dimensional ...
s of elements in three dimensional space. Specifically, they encode information about an axis-angle rotation about an arbitrary axis. Rotation and orientation quaternions have applications in
computer graphics Computer graphics deals with generating images with the aid of computers. Today, computer graphics is a core technology in digital photography, film, video games, cell phone and computer displays, and many specialized applications. A great de ...
, Presented at
SIGGRAPH SIGGRAPH (Special Interest Group on Computer Graphics and Interactive Techniques) is an annual conference on computer graphics (CG) organized by the ACM SIGGRAPH, starting in 1974. The main conference is held in North America; SIGGRAPH Asia ...
'85.
computer vision Computer vision is an interdisciplinary scientific field that deals with how computers can gain high-level understanding from digital images or videos. From the perspective of engineering, it seeks to understand and automate tasks that the human ...
,
robotics Robotics is an interdisciplinary branch of computer science and engineering. Robotics involves design, construction, operation, and use of robots. The goal of robotics is to design machines that can help and assist humans. Robotics integrat ...
,
navigation Navigation is a field of study that focuses on the process of monitoring and controlling the movement of a craft or vehicle from one place to another.Bowditch, 2003:799. The field of navigation includes four general categories: land navigation ...
,
molecular dynamics Molecular dynamics (MD) is a computer simulation method for analyzing the physical movements of atoms and molecules. The atoms and molecules are allowed to interact for a fixed period of time, giving a view of the dynamic "evolution" of th ...
,
flight dynamics Flight dynamics in aviation and spacecraft, is the study of the performance, stability, and control of vehicles flying through the air or in outer space. It is concerned with how forces acting on the vehicle determine its velocity and attitude ...
, orbital mechanics of
satellite A satellite or artificial satellite is an object intentionally placed into orbit in outer space. Except for passive satellites, most satellites have an electricity generation system for equipment on board, such as solar panels or radioiso ...
s, and crystallographic texture analysis. When used to represent rotation, unit quaternions are also called rotation quaternions as they represent the
3D rotation group In mechanics and geometry, the 3D rotation group, often denoted SO(3), is the group of all rotations about the origin of three-dimensional Euclidean space \R^3 under the operation of composition. By definition, a rotation about the origin is a tr ...
. When used to represent an orientation (rotation relative to a reference coordinate system), they are called orientation quaternions or attitude quaternions. A spatial rotation around a fixed point of \theta radians about a unit axis (X,Y,Z) that denotes the ''Euler axis'' is given by the quaternion (C, X \, S, Y \, S, Z \, S), where C = \cos(\theta/2) and S=\sin(\theta/2). Compared to rotation matrices, quaternions are more compact, efficient, and numerically stable. Compared to
Euler angles The Euler angles are three angles introduced by Leonhard Euler to describe the orientation of a rigid body with respect to a fixed coordinate system.Novi Commentarii academiae scientiarum Petropolitanae 20, 1776, pp. 189–207 (E478PDF/ref> Th ...
, they are simpler to compose. However, they are not as intuitive and easy to understand and, due to the periodic nature of
sine In mathematics, sine and cosine are trigonometric functions of an angle. The sine and cosine of an acute angle are defined in the context of a right triangle: for the specified angle, its sine is the ratio of the length of the side that is opp ...
and cosine, rotation angles differing precisely by the natural period will be encoded into identical quaternions and recovered angles in
radian The radian, denoted by the symbol rad, is the unit of angle in the International System of Units (SI) and is the standard unit of angular measure used in many areas of mathematics. The unit was formerly an SI supplementary unit (before that ...
s will be limited to ,2\pi/math>.


Using quaternions as rotations

In 3-dimensional space, according to
Euler's rotation theorem In geometry, Euler's rotation theorem states that, in three-dimensional space, any displacement of a rigid body such that a point on the rigid body remains fixed, is equivalent to a single rotation about some axis that runs through the fixed p ...
, any rotation or sequence of rotations of a rigid body or coordinate system about a fixed point is equivalent to a single rotation by a given angle \theta about a fixed axis (called the ''Euler axis'') that runs through the fixed point. The Euler axis is typically represented by a
unit vector In mathematics, a unit vector in a normed vector space is a vector (often a spatial vector) of length 1. A unit vector is often denoted by a lowercase letter with a circumflex, or "hat", as in \hat (pronounced "v-hat"). The term ''direction v ...
  (\hat in the picture). Therefore, any rotation in three dimensions can be represented as a combination of a
vector Vector most often refers to: *Euclidean vector, a quantity with a magnitude and a direction *Vector (epidemiology), an agent that carries and transmits an infectious pathogen into another living organism Vector may also refer to: Mathematic ...
  and a scalar \theta. Quaternions give a simple way to encode this axis–angle representation in four numbers, and can be used to apply (calculate) the corresponding rotation to a
position vector In geometry, a position or position vector, also known as location vector or radius vector, is a Euclidean vector that represents the position of a point ''P'' in space in relation to an arbitrary reference origin ''O''. Usually denoted x, r, or ...
, representing a point relative to the
origin Origin(s) or The Origin may refer to: Arts, entertainment, and media Comics and manga * Origin (comics), ''Origin'' (comics), a Wolverine comic book mini-series published by Marvel Comics in 2002 * The Origin (Buffy comic), ''The Origin'' (Bu ...
in R3.
Euclidean vector In mathematics, physics, and engineering, a Euclidean vector or simply a vector (sometimes called a geometric vector or spatial vector) is a geometric object that has magnitude (or length) and direction. Vectors can be added to other vectors ...
s such as or can be rewritten as or , where , , are unit vectors representing the three Cartesian axes (traditionally , , ), and also obey the multiplication rules of the fundamental quaternion units. Therefore, a rotation of angle \theta around the axis defined by the unit vector : \vec = (u_x, u_y, u_z) = u_x\mathbf + u_y\mathbf + u_z\mathbf can be represented by a quaternion. This can be done using an
extension Extension, extend or extended may refer to: Mathematics Logic or set theory * Axiom of extensionality * Extensible cardinal * Extension (model theory) * Extension (predicate logic), the set of tuples of values that satisfy the predicate * Ext ...
of
Euler's formula Euler's formula, named after Leonhard Euler, is a mathematical formula in complex analysis that establishes the fundamental relationship between the trigonometric functions and the complex exponential function. Euler's formula states that ...
: : \mathbf = e^ = \cos \frac + (u_x\mathbf + u_y\mathbf + u_z\mathbf) \sin \frac It can be shown that the desired rotation can be applied to an ordinary vector \mathbf = (p_x, p_y, p_z) = p_x\mathbf + p_y\mathbf + p_z\mathbf in 3-dimensional space, considered as a quaternion with a real coordinate equal to zero, by evaluating the
conjugation Conjugation or conjugate may refer to: Linguistics *Grammatical conjugation, the modification of a verb from its basic form * Emotive conjugation or Russell's conjugation, the use of loaded language Mathematics *Complex conjugation, the change ...
of  by : : \mathbf = \mathbf \mathbf \mathbf^ using the Hamilton product, where is the new position vector of the point after the rotation. In a programmatic implementation, the conjugation is achieved by constructing a quaternion whose vector part is and real part equals zero, and then performing the quaternion multiplication. The vector part of the resulting quaternion is the desired vector . A geometric fact independent of quaternions is the existence of a two-to-one mapping from physical rotations to rotational transformation matrices. If 0 ⩽ \theta2\pi, a physical rotation about \vec by \theta and a physical rotation about -\vec by 2\pi-\theta both achieve the same final orientation by disjoint paths through intermediate orientations. By inserting those vectors and angles into the formula for above, one finds that if represents the first rotation, represents the second rotation. This is a geometric proof that conjugation by and by must produce the same rotational transformation matrix. That fact is confirmed algebraically by noting that the conjugation is quadratic in , so the sign of cancels, and does not affect the result. (See 2:1 mapping of SU(2) to SO(3)) If both rotations are a half-turn (\theta=\pi), both and will have a real coordinate equal to zero. Otherwise, one will have a positive real part, representing a rotation by an angle less than \pi, and the other will have a negative real part, representing a rotation by an angle greater than \pi. Mathematically, this operation carries the ''set'' of all "pure" quaternions (those with real part equal to zero)—which constitute a 3-dimensional space among the quaternions—into itself, by the desired rotation about the axis ''u'', by the angle θ. (Each real quaternion is carried into itself by this operation. But for the purpose of rotations in 3-dimensional space, we ignore the real quaternions.) The rotation is clockwise if our line of sight points in the same direction as . In this instance, is a unit quaternion and : \mathbf^ = e^ = \cos \frac - (u_x\mathbf + u_y\mathbf + u_z\mathbf) \sin \frac . It follows that conjugation by the product of two quaternions is the composition of conjugations by these quaternions: If and are unit quaternions, then rotation (conjugation) by  is :\mathbf \vec (\mathbf)^ = \mathbf \vec \mathbf^ \mathbf^ = \mathbf (\mathbf \vec \mathbf^) \mathbf^, which is the same as rotating (conjugating) by  and then by . The scalar component of the result is necessarily zero. The quaternion inverse of a rotation is the opposite rotation, since \mathbf^ (\mathbf \vec \mathbf^) \mathbf = \vec. The square of a quaternion rotation is a rotation by twice the angle around the same axis. More generally is a rotation by  times the angle around the same axis as . This can be extended to arbitrary real , allowing for smooth interpolation between spatial orientations; see
Slerp In computer graphics, Slerp is shorthand for spherical linear interpolation, introduced by Ken Shoemake in the context of quaternion interpolation for the purpose of animating 3D rotation. It refers to constant-speed motion along a unit-radius g ...
. Two rotation quaternions can be combined into one equivalent quaternion by the relation: : \mathbf' = \mathbf_2 \mathbf_1 in which corresponds to the rotation followed by the rotation . Thus, an arbitrary number of rotations can be composed together and then applied as a single rotation. (Note that quaternion multiplication is not
commutative In mathematics, a binary operation is commutative if changing the order of the operands does not change the result. It is a fundamental property of many binary operations, and many mathematical proofs depend on it. Most familiar as the name of ...
.)


Example conjugation operation

''Conjugating'' ''by'' refers to the operation . Consider the rotation around the axis \vec = \mathbf + \mathbf + \mathbf, with a rotation angle of 120°, or  
radian The radian, denoted by the symbol rad, is the unit of angle in the International System of Units (SI) and is the standard unit of angular measure used in many areas of mathematics. The unit was formerly an SI supplementary unit (before that ...
s. :\alpha = \frac The length of is , the half angle is (60°) with cosine , () and
sine In mathematics, sine and cosine are trigonometric functions of an angle. The sine and cosine of an acute angle are defined in the context of a right triangle: for the specified angle, its sine is the ratio of the length of the side that is opp ...
, (). We are therefore dealing with a conjugation by the unit quaternion :\begin u &= \cos\frac + \sin\frac\cdot \frac\vec\\ &= \cos \frac + \sin \frac\cdot \frac\vec\\ &= \frac + \frac\cdot \frac\vec\\ &= \frac + \frac\cdot \frac\\ &= \frac \end If is the rotation function, :f(a\mathbf + b\mathbf + c\mathbf) = u (a\mathbf + b\mathbf + c\mathbf) u^ It can be proven that the inverse of a unit quaternion is obtained simply by changing the sign of its imaginary components. As a consequence, :u^ = \dfrac and :f(a\mathbf + b\mathbf + c\mathbf) = \dfrac(a\mathbf + b\mathbf + c\mathbf) \dfrac This can be simplified, using the ordinary rules for quaternion arithmetic, to :f(a\mathbf + b\mathbf + c\mathbf) = c\mathbf + a\mathbf + b\mathbf As expected, the rotation corresponds to keeping a
cube In geometry, a cube is a three-dimensional solid object bounded by six square faces, facets or sides, with three meeting at each vertex. Viewed from a corner it is a hexagon and its net is usually depicted as a cross. The cube is the only ...
held fixed at one point, and rotating it 120° about the long diagonal through the fixed point (observe how the three axes are permuted cyclically).


Quaternion-derived rotation matrix

A quaternion rotation \mathbf = \mathbf \mathbf \mathbf^ (with \mathbf = q_r + q_i \mathbf + q_j \mathbf + q_k \mathbf) can be algebraically manipulated into a matrix rotation \mathbf = \mathbf, where \mathbf is the
rotation matrix In linear algebra, a rotation matrix is a transformation matrix that is used to perform a rotation in Euclidean space. For example, using the convention below, the matrix :R = \begin \cos \theta & -\sin \theta \\ \sin \theta & \cos \theta \ ...
given by: : \mathbf = \begin 1 - 2s (q_j^2 + q_k^2) & 2s (q_i q_j - q_k q_r) & 2s (q_i q_k + q_j q_r) \\ 2s (q_i q_j + q_k q_r) & 1 - 2s (q_i^2 + q_k^2) & 2s (q_j q_k - q_i q_r) \\ 2s (q_i q_k - q_j q_r) & 2s (q_j q_k + q_i q_r) & 1 - 2s (q_i^2 + q_j^2) \end Here s = \, q\, ^ and if is a unit quaternion, s = 1^ = 1. This can be obtained by using
vector calculus Vector calculus, or vector analysis, is concerned with differentiation and integration of vector fields, primarily in 3-dimensional Euclidean space \mathbb^3. The term "vector calculus" is sometimes used as a synonym for the broader subjec ...
and
linear algebra Linear algebra is the branch of mathematics concerning linear equations such as: :a_1x_1+\cdots +a_nx_n=b, linear maps such as: :(x_1, \ldots, x_n) \mapsto a_1x_1+\cdots +a_nx_n, and their representations in vector spaces and through matrice ...
if we express \mathbf p and \mathbf q as scalar and vector parts and use the formula for the multiplication operation in the equation \mathbf = \mathbf \mathbf \mathbf^. If we write \mathbf p as \left(0,\ \mathbf p\right), \mathbf p' as \left(0,\ \mathbf p'\right) and \mathbf q as \left(q_r,\ \mathbf v\right), where \mathbf v = \left(q_i, q_j, q_k\right), our equation turns into \left(0,\ \mathbf p'\right) = \left(q_r,\ \mathbf v\right) \left(0,\ \mathbf p\right) s\left(q_r,\ -\mathbf v\right). By using the formula for multiplication of two quaternions that are expressed as scalar and vector parts, :\left(r_1,\ \vec_1\right) \left(r_2,\ \vec_2\right) = \left(r_1 r_2 - \vec_1\cdot\vec_2,\ r_1\vec_2 + r_2\vec_1 + \vec_1\times\vec_2\right), this equation can be rewritten as :\begin (0,\ \mathbf p') = &((q_r,\ \mathbf v) (0,\ \mathbf p)) s(q_r,\ -\mathbf v) \\ = &(q_r 0 - \mathbf v \cdot \mathbf p,\ q_r\mathbf p + 0\mathbf v + \mathbf v \times \mathbf p)s(q_r,\ -\mathbf v) \\ = &s(-\mathbf v \cdot \mathbf p,\ q_r\mathbf p + \mathbf v \times \mathbf p)(q_r,\ -\mathbf v) \\ = &s(-\mathbf v \cdot \mathbf p q_r - (q_r\mathbf p + \mathbf v \times \mathbf p)\cdot(-\mathbf v),\ (-\mathbf v \cdot \mathbf p)(-\mathbf v) + q_r(q_r\mathbf p + \mathbf v \times \mathbf p) + (q_r\mathbf p + \mathbf v \times \mathbf p)\times(-\mathbf v)) \\ = &s\left(-\mathbf v \cdot \mathbf p q_r + q_r\mathbf v \cdot \mathbf p,\ \mathbf v\left(\mathbf v \cdot \mathbf p\right) + q_r^2\mathbf p + q_r\mathbf v \times \mathbf p + \mathbf v \times \left(q_r \mathbf p + \mathbf v \times \mathbf p\right)\right) \\ = &\left(0,\ s\left(\mathbf v \otimes \mathbf v + q_r^2\mathbf + 2 q_r mathbf v + mathbf v^2\right) \mathbf p\right), \end where \otimes denotes the
outer product In linear algebra, the outer product of two coordinate vectors is a matrix. If the two vectors have dimensions ''n'' and ''m'', then their outer product is an ''n'' × ''m'' matrix. More generally, given two tensors (multidimensional arrays of nu ...
, \mathbf is the
identity matrix In linear algebra, the identity matrix of size n is the n\times n square matrix with ones on the main diagonal and zeros elsewhere. Terminology and notation The identity matrix is often denoted by I_n, or simply by I if the size is immaterial or ...
and mathbf v is the transformation matrix that when multiplied from the right with a vector \mathbf u gives the
cross product In mathematics, the cross product or vector product (occasionally directed area product, to emphasize its geometric significance) is a binary operation on two vectors in a three-dimensional oriented Euclidean vector space (named here E), and ...
\mathbf v \times \mathbf u. Since \mathbf p' = \mathbf\mathbf p, we can identify \mathbf as s\left(\mathbf v \otimes \mathbf v + q_r^2\mathbf + 2 q_r mathbf v + mathbf v^2\right), which upon expansion should result in the expression written in matrix form above.


Recovering the axis-angle representation

The expression \mathbf \mathbf \mathbf^ rotates any vector quaternion \mathbf around an axis given by the vector \mathbf by the angle \theta, where \mathbf and \theta depends on the quaternion \mathbf = q_r + q_i \mathbf + q_j \mathbf + q_k \mathbf. \mathbf and \theta can be found from the following equations: :\begin (a_x, a_y, a_z) = &\frac \\ pt \theta = 2 \operatorname &\left(\sqrt,\, q_r \right), \end where \operatorname is the two-argument arctangent. Care should be taken when the quaternion approaches a scalar, since due to degeneracy the axis of an identity rotation is not well-defined.


The composition of spatial rotations

A benefit of the quaternion formulation of the composition of two rotations ''R''B and ''R''A is that it yields directly the
rotation axis Rotation around a fixed axis is a special case of rotational motion. The fixed-axis hypothesis excludes the possibility of an axis changing its orientation and cannot describe such phenomena as wobbling or precession. According to Euler's r ...
and angle of the composite rotation ''R''C = ''R''B''R''A. Let the quaternion associated with a spatial rotation ''R'' be constructed from its
rotation axis Rotation around a fixed axis is a special case of rotational motion. The fixed-axis hypothesis excludes the possibility of an axis changing its orientation and cannot describe such phenomena as wobbling or precession. According to Euler's r ...
S with the rotation angle \varphi around this axis. The associated quaternion is given by S = \cos\frac + \mathbf\sin\frac. Then the composition of the rotation ''R''B with ''R''A is the rotation ''R''C = ''R''B''R''A with rotation axis and angle defined by the product of the quaternions A = \cos\frac + \mathbf\sin\frac \quad \text \quad B = \cos\frac + \mathbf\sin\frac, that is C = \cos\frac + \mathbf\sin\frac = \left(\cos\frac + \mathbf \sin\frac\right) \left(\cos\frac + \mathbf\sin\frac\right). Expand this product to obtain \cos\frac + \mathbf\sin\frac = \left( \cos\frac \cos\frac - \mathbf \cdot \mathbf \sin\frac \sin\frac\right) + \left(\mathbf \sin\frac \cos\frac + \mathbf \sin\frac \cos\frac + \mathbf \times \mathbf \sin\frac \sin\frac \right). Divide both sides of this equation by the identity, which is the law of cosines on a sphere, \cos\frac = \cos\frac \cos\frac - \mathbf \cdot \mathbf \sin\frac \sin\frac, and compute \mathbf \tan\frac = \frac. This is Rodrigues' formula for the axis of a composite rotation defined in terms of the axes of the two rotations. He derived this formula in 1840 (see page 408). The three rotation axes A, B, and C form a spherical triangle and the dihedral angles between the planes formed by the sides of this triangle are defined by the rotation angles. Hamilton
William Rowan Hamilton Sir William Rowan Hamilton Doctor of Law, LL.D, Doctor of Civil Law, DCL, Royal Irish Academy, MRIA, Royal Astronomical Society#Fellow, FRAS (3/4 August 1805 – 2 September 1865) was an Irish mathematician, astronomer, and physicist. He was the ...
(1844 to 1850
On quaternions or a new system of imaginaries in algebra
Philosophical Magazine The ''Philosophical Magazine'' is one of the oldest scientific journals published in English. It was established by Alexander Tilloch in 1798;John Burnett"Tilloch, Alexander (1759–1825)" Oxford Dictionary of National Biography, Oxford Univer ...
, link to David R. Wilkins collection at
Trinity College, Dublin , name_Latin = Collegium Sanctae et Individuae Trinitatis Reginae Elizabethae juxta Dublin , motto = ''Perpetuis futuris temporibus duraturam'' (Latin) , motto_lang = la , motto_English = It will last i ...
presented the component form of these equations showing that the quaternion product computes the third vertex of a spherical triangle from two given vertices and their associated arc-lengths, which is also defines an algebra for points in
Elliptic geometry Elliptic geometry is an example of a geometry in which Euclid's parallel postulate does not hold. Instead, as in spherical geometry, there are no parallel lines since any two lines must intersect. However, unlike in spherical geometry, two lines ...
.


Axis–angle composition

The normalized rotation axis, removing the \cos\frac from the expanded product, leaves the vector which is the rotation axis, times some constant. Care should be taken normalizing the axis vector when \gamma is 0 or k 2\pi where the vector is near 0; which is identity, or 0 rotation around any axis. \begin \gamma &= 2\cos^\left(\cos\frac \cos\frac - \mathbf \cdot \mathbf \sin\frac \sin\frac\right) \\ \mathbf &= \mathbf \sin\frac \cos\frac + \mathbf \sin\frac \cos\frac + \mathbf \times \mathbf \sin\frac \sin\frac \end Or with angle addition trigonometric substitutions... \begin \gamma &= 2 \cos^ \left(\left(1 - \mathbf \cdot \mathbf\right) \cos\frac + \left(1 + \mathbf\cdot \mathbf\right) \cos\frac\right) \\ \mathbf &= \left(\sin\frac + \sin\frac\right) \mathbf + \left(\sin\frac - \sin\frac\right) \mathbf + \left(\cos\frac - \cos\frac\right) \mathbf \times \mathbf \end finally normalizing the rotation axis: \frac or \frac.


Differentiation with respect to the rotation quaternion

The rotated quaternion needs to be differentiated with respect to the rotating quaternion , when the rotation is estimated from numerical optimization. The estimation of rotation angle is an essential procedure in 3D object registration or camera calibration. For unitary and pure imaginary , that is for a rotation in 3D space, the derivatives of the rotated quaternion can be represented using matrix calculus notation as :\begin \frac \equiv \left frac,\frac,\frac,\frac \right= \left \mathbf-(\mathbf)^*,(\mathbf)^*-\mathbf,(\mathbf)^*-\mathbf,(\mathbf)^*-\mathbf \right \end A derivation can be found in.


Background


Quaternions

The
complex numbers In mathematics, a complex number is an element of a number system that extends the real numbers with a specific element denoted , called the imaginary unit and satisfying the equation i^= -1; every complex number can be expressed in the form ...
can be defined by introducing an abstract symbol which satisfies the usual rules of algebra and additionally the rule . This is sufficient to reproduce all of the rules of complex number arithmetic: for example: : (a+b\mathbf)(c+d\mathbf) = ac + ad\mathbf + b\mathbfc + b\mathbfd\mathbf = ac + ad\mathbf + bc\mathbf + bd\mathbf^2 = (ac - bd) + (bc + ad) \mathbf. In the same way the quaternions can be defined by introducing abstract symbols , , which satisfy the rules and the usual algebraic rules ''except'' the commutative law of multiplication (a familiar example of such a noncommutative multiplication is
matrix multiplication In mathematics, particularly in linear algebra, matrix multiplication is a binary operation that produces a matrix from two matrices. For matrix multiplication, the number of columns in the first matrix must be equal to the number of rows in the s ...
). From this all of the rules of quaternion arithmetic follow, such as the rules on multiplication of quaternion basis elements. Using these rules, one can show that: : \begin &(a + b\mathbf + c\mathbf + d\mathbf) (e + f\mathbf + g\mathbf + h\mathbf) = \\ &(ae - bf - cg - dh) + (af + be + ch - dg) \mathbf + (ag - bh + ce + df) \mathbf + (ah + bg - cf + de) \mathbf. \end The imaginary part b\mathbf + c\mathbf + d\mathbf of a quaternion behaves like a vector \vec = (b,c,d) in three-dimensional
vector space In mathematics and physics, a vector space (also called a linear space) is a set whose elements, often called '' vectors'', may be added together and multiplied ("scaled") by numbers called ''scalars''. Scalars are often real numbers, but can ...
, and the real part behaves like a scalar in . When quaternions are used in geometry, it is more convenient to define them as a scalar plus a vector: : a + b\mathbf + c\mathbf + d\mathbf = a + \vec. Some might find it strange to add a ''number'' to a ''vector'', as they are objects of very different natures, or to ''multiply'' two vectors together, as this operation is usually undefined. However, if one remembers that it is a mere notation for the real and imaginary parts of a quaternion, it becomes more legitimate. In other words, the correct reasoning is the addition of two quaternions, one with zero vector/imaginary part, and another one with zero scalar/real part: :q_1 = s + \vec = \left(s, \vec\right) + \left(0, \vec\right). We can express quaternion multiplication in the modern language of vector
cross A cross is a geometrical figure consisting of two intersecting lines or bars, usually perpendicular to each other. The lines usually run vertically and horizontally. A cross of oblique lines, in the shape of the Latin letter X, is termed a s ...
and
dot product In mathematics, the dot product or scalar productThe term ''scalar product'' means literally "product with a scalar as a result". It is also used sometimes for other symmetric bilinear forms, for example in a pseudo-Euclidean space. is an alg ...
s (which were actually inspired by the quaternions in the first place). When multiplying the vector/imaginary parts, in place of the rules we have the quaternion multiplication rule: : \vec \vec = - \vec \cdot \vec + \vec \times \vec, where: * \vec \vec is the resulting quaternion, * \vec \times \vec is vector cross product (a vector), * \vec \cdot \vec is vector scalar product (a scalar). Quaternion multiplication is noncommutative (because of the cross product, which anti-commutes), while scalar–scalar and scalar–vector multiplications commute. From these rules it follows immediately that ( see details): :q_1 q_2 = \left(s + \vec\right) \left(t + \vec\right) = \left(s t - \vec \cdot \vec\right) + \left(s \vec + t \vec + \vec \times \vec\right). The (left and right) multiplicative inverse or reciprocal of a nonzero quaternion is given by the conjugate-to-norm ratio ( see details): :q_1^ = \left(s + \vec\right)^ = \frac = \frac, as can be verified by direct calculation (note the similarity to the multiplicative inverse of complex numbers).


Rotation identity

Let \vec be a unit vector (the rotation axis) and let q = \cos \frac + \vec \sin \frac. Our goal is to show that :\vec = q \vec q^ = \left( \cos \frac + \vec \sin \frac \right) \, \vec \, \left( \cos \frac - \vec \sin \frac \right) yields the vector \vec rotated by an angle \alpha around the axis \vec. Expanding out (and bearing in mind that \vec\vec = \vec \times \vec - \vec \cdot \vec), we have :\begin \vec' &= \vec \cos^2 \frac + \left(\vec\vec - \vec\vec\right) \sin \frac \cos \frac - \vec\vec\vec \sin^2 \frac \\ pt&= \vec \cos^2 \frac + 2 \left(\vec \times \vec\right) \sin \frac \cos \frac - \left(\left(\vec \times \vec\right) - \left(\vec \cdot \vec\right)\right)\vec \sin^2 \frac \\ pt&= \vec \cos^2 \frac + 2 \left(\vec \times \vec\right) \sin \frac \cos \frac - \left(\left(\vec \times \vec\right)\vec - \left(\vec \cdot \vec\right)\vec\right) \sin^2 \frac \\ pt&= \vec \cos^2 \frac + 2 \left(\vec \times \vec\right) \sin \frac \cos \frac - \left(\left(\left(\vec \times \vec\right) \times \vec - \left(\vec \times \vec\right) \cdot \vec\right) - \left(\vec \cdot \vec\right)\vec\right) \sin^2 \frac \\ pt&= \vec \cos^2 \frac + 2 \left(\vec \times \vec\right) \sin \frac \cos \frac - \left(\left(\vec - \left(\vec \cdot \vec\right)\vec\right) - 0 - \left(\vec \cdot \vec\right)\vec\right) \sin^2 \frac \\ pt&= \vec \cos^2 \frac + 2 \left(\vec \times \vec\right) \sin \frac \cos \frac - \left(\vec - 2 \vec \left(\vec \cdot \vec\right)\right) \sin^2 \frac \\ pt&= \vec \cos^2 \frac + 2 \left(\vec \times \vec\right) \sin \frac \cos \frac - \vec\sin^2 \frac + 2 \vec \left(\vec \cdot \vec\right) \sin^2 \frac \\ pt&= \vec \left(\cos^2 \frac - \sin^2 \frac\right) + \left(\vec \times \vec\right) \left(2 \sin \frac \cos \frac\right) + \vec \left(\vec \cdot \vec\right) \left(2 \sin^2 \frac\right) \\ pt\end Using trigonometric identities: :\begin \vec' &= \vec \left(\cos^2\frac - \sin^2 \frac\right) + \left(\vec \times \vec\right) \left(2 \sin \frac \cos \frac\right) + \vec \left(\vec \cdot \vec\right) \left(2 \sin^2 \frac\right) \\ pt&= \vec \cos \alpha + \left(\vec \times \vec\right) \sin \alpha + \vec \left(\vec \cdot \vec\right) \left(1 - \cos \alpha\right) \\ pt&= \vec \cos \alpha + \left(\vec \times \vec\right) \sin \alpha + \vec \left(\vec \cdot \vec\right) - \vec \left(\vec \cdot \vec\right)\cos \alpha \\ pt&= \left(\vec - \vec \left(\vec \cdot \vec\right)\right) \cos \alpha + \left(\vec \times \vec\right) \sin \alpha + \vec \left(\vec \cdot \vec\right) \\ pt&= \vec_\bot \cos \alpha + \left(\vec \times \vec\right) \sin \alpha + \vec_ \end where \vec_ and \vec_ are the components of (perpendicular and parallel to respectively). This is the formula of a rotation by \alpha around the axis.


Quaternion rotation operations

A very formal explanation of the properties used in this section is given by Altman.


The hypersphere of rotations


Visualizing the space of rotations

Unit quaternions represent the
group A group is a number of persons or things that are located, gathered, or classed together. Groups of people * Cultural group, a group whose members share the same cultural identity * Ethnic group, a group whose members share the same ethnic ide ...
of Euclidean rotations in
three dimensions Three-dimensional space (also: 3D space, 3-space or, rarely, tri-dimensional space) is a geometric setting in which three values (called '' parameters'') are required to determine the position of an element (i.e., point). This is the inform ...
in a very straightforward way. The correspondence between rotations and quaternions can be understood by first visualizing the space of rotations itself. In order to visualize the space of rotations, it helps to consider a simpler case. Any rotation in three dimensions can be described by a rotation by some
angle In Euclidean geometry, an angle is the figure formed by two rays, called the '' sides'' of the angle, sharing a common endpoint, called the ''vertex'' of the angle. Angles formed by two rays lie in the plane that contains the rays. Angles ...
about some axis; for our purposes, we will use an axis ''vector'' to establish
handedness In human biology, handedness is an individual's preferential use of one hand, known as the dominant hand, due to it being stronger, faster or more dextrous. The other hand, comparatively often the weaker, less dextrous or simply less subject ...
for our angle. Consider the special case in which the axis of rotation lies in the ''xy'' plane. We can then specify the axis of one of these rotations by a point on a circle through which the vector crosses, and we can select the radius of the circle to denote the
angle of rotation In mathematics, the angle of rotation is a measurement of the amount, of namely angle, that a figure is rotated about a fixed point, often the center of a circle. A clockwise rotation is considered a negative rotation, so that, for instanc ...
. Similarly, a rotation whose axis of rotation lies in the ''xy'' plane can be described as a point on a sphere of ''fixed'' radius in ''three'' dimensions. Beginning at the north pole of a sphere in three-dimensional space, we specify the point at the north pole to be the identity rotation (a zero angle rotation). Just as in the case of the identity rotation, no axis of rotation is defined, and the angle of rotation (zero) is irrelevant. A rotation having a very small rotation angle can be specified by a slice through the sphere parallel to the ''xy'' plane and very near the north pole. The circle defined by this slice will be very small, corresponding to the small angle of the rotation. As the rotation angles become larger, the slice moves in the negative ''z'' direction, and the circles become larger until the equator of the sphere is reached, which will correspond to a rotation angle of 180 degrees. Continuing southward, the radii of the circles now become smaller (corresponding to the absolute value of the angle of the rotation considered as a negative number). Finally, as the south pole is reached, the circles shrink once more to the identity rotation, which is also specified as the point at the south pole. Notice that a number of characteristics of such rotations and their representations can be seen by this visualization. The space of rotations is continuous, each rotation has a neighborhood of rotations which are nearly the same, and this neighborhood becomes flat as the neighborhood shrinks. Also, each rotation is actually represented by two antipodal points on the sphere, which are at opposite ends of a line through the center of the sphere. This reflects the fact that each rotation can be represented as a rotation about some axis, or, equivalently, as a negative rotation about an axis pointing in the opposite direction (a so-called double cover). The "latitude" of a circle representing a particular rotation angle will be half of the angle represented by that rotation, since as the point is moved from the north to south pole, the latitude ranges from zero to 180 degrees, while the angle of rotation ranges from 0 to 360 degrees. (the "longitude" of a point then represents a particular axis of rotation.) Note however that this set of rotations is not closed under composition. Two successive rotations with axes in the ''xy'' plane will not necessarily give a rotation whose axis lies in the ''xy'' plane, and thus cannot be represented as a point on the sphere. This will not be the case with a general rotation in 3-space, in which rotations do form a closed set under composition. This visualization can be extended to a general rotation in 3-dimensional space. The identity rotation is a point, and a small angle of rotation about some axis can be represented as a point on a sphere with a small radius. As the angle of rotation grows, the sphere grows, until the angle of rotation reaches 180 degrees, at which point the sphere begins to shrink, becoming a point as the angle approaches 360 degrees (or zero degrees from the negative direction). This set of expanding and contracting spheres represents a hypersphere in four dimensional space (a 3-sphere). Just as in the simpler example above, each rotation represented as a point on the hypersphere is matched by its antipodal point on that hypersphere. The "latitude" on the hypersphere will be half of the corresponding angle of rotation, and the neighborhood of any point will become "flatter" (i.e. be represented by a 3-D Euclidean space of points) as the neighborhood shrinks. This behavior is matched by the set of unit quaternions: A general quaternion represents a point in a four dimensional space, but constraining it to have unit magnitude yields a three-dimensional space equivalent to the surface of a hypersphere. The magnitude of the unit quaternion will be unity, corresponding to a hypersphere of unit radius. The vector part of a unit quaternion represents the radius of the 2-sphere corresponding to the axis of rotation, and its magnitude is the cosine of half the angle of rotation. Each rotation is represented by two unit quaternions of opposite sign, and, as in the space of rotations in three dimensions, the quaternion product of two unit quaternions will yield a unit quaternion. Also, the space of unit quaternions is "flat" in any infinitesimal neighborhood of a given unit quaternion.


Parameterizing the space of rotations

We can parameterize the surface of a sphere with two coordinates, such as latitude and longitude. But latitude and longitude are ill-behaved ( degenerate) at the north and south poles, though the poles are not intrinsically different from any other points on the sphere. At the poles (latitudes +90° and −90°), the longitude becomes meaningless. It can be shown that no two-parameter coordinate system can avoid such degeneracy. We can avoid such problems by embedding the sphere in three-dimensional space and parameterizing it with three Cartesian coordinates , placing the north pole at , the south pole at , and the equator at , . Points on the sphere satisfy the constraint , so we still have just two
degrees of freedom Degrees of freedom (often abbreviated df or DOF) refers to the number of independent variables or parameters of a thermodynamic system. In various scientific fields, the word "freedom" is used to describe the limits to which physical movement or ...
though there are three coordinates. A point on the sphere represents a rotation in the ordinary space around the horizontal axis directed by the vector by an angle \alpha= 2 \cos^ w = 2 \sin^ \sqrt. In the same way the hyperspherical space of 3D rotations can be parameterized by three angles (
Euler angles The Euler angles are three angles introduced by Leonhard Euler to describe the orientation of a rigid body with respect to a fixed coordinate system.Novi Commentarii academiae scientiarum Petropolitanae 20, 1776, pp. 189–207 (E478PDF/ref> Th ...
), but any such parameterization is degenerate at some points on the hypersphere, leading to the problem of gimbal lock. We can avoid this by using four Euclidean coordinates , with . The point represents a rotation around the axis directed by the vector by an angle \alpha = 2 \cos^ w = 2 \sin^ \sqrt.


Explaining quaternions' properties with rotations


Non-commutativity

The multiplication of quaternions is
non-commutative In mathematics, a binary operation is commutative if changing the order of the operands does not change the result. It is a fundamental property of many binary operations, and many mathematical proofs depend on it. Most familiar as the name of ...
. This fact explains how the formula can work at all, having by definition. Since the multiplication of unit quaternions corresponds to the composition of three-dimensional rotations, this property can be made intuitive by showing that three-dimensional rotations are not commutative in general. Set two books next to each other. Rotate one of them 90 degrees clockwise around the ''z'' axis, then flip it 180 degrees around the ''x'' axis. Take the other book, flip it 180° around ''x'' axis first, and 90° clockwise around ''z'' later. The two books do not end up parallel. This shows that, in general, the composition of two different rotations around two distinct spatial axes will not commute.


Orientation

The vector cross product, used to define the axis–angle representation, does confer an orientation ("handedness") to space: in a three-dimensional vector space, the three vectors in the equation will always form a right-handed set (or a left-handed set, depending on how the cross product is defined), thus fixing an orientation in the vector space. Alternatively, the dependence on orientation is expressed in referring to such that specifies a rotation as to '' axial vectors''. In quaternionic formalism the choice of an orientation of the space corresponds to order of multiplication: but . If one reverses the orientation, then the formula above becomes , i.e., a unit is replaced with the conjugate quaternion – the same behaviour as of axial vectors.


Alternative conventions

It is reported that the existence and continued usage of an alternative quaternion convention in the aerospace and, to a lesser extent, robotics community is incurring a ''significant and ongoing cost''. This alternative convention is proposed by Shuster M.D. in and departs from tradition by reversing the definition for multiplying quaternion basis elements such that under Shuster's convention, \mathbf \mathbf = -\mathbf whereas Hamilton's definition is \mathbf\mathbf = \mathbf. This convention is also referred to as "JPL convention" for its use in some parts of NASA's
Jet Propulsion Laboratory The Jet Propulsion Laboratory (JPL) is a Federally funded research and development centers, federally funded research and development center and NASA field center in the City of La Cañada Flintridge, California, La Cañada Flintridge, California ...
. Under Shuster's convention, the formula for multiplying two quaternions is altered such that :\left(r_1,\ \vec_1\right) \left(r_2,\ \vec_2\right) = \left(r_1 r_2 - \vec_1\cdot\vec_2,\ r_1\vec_2 + r_2\vec_1 \mathbin \vec_1\times\vec_2\right), \qquad \text The formula for rotating a vector by a quaternion is altered to be :\begin \mathbf p'_\text = &(\mathbf v \otimes \mathbf v + q_r^2\mathbf \mathbin 2 q_r mathbf v + mathbf v^2) \mathbf p & \text \\ = &\ (\mathbf \mathbin 2 q_r mathbf v + 2 mathbf v^2) \mathbf p & \end To identify the changes under Shuster's convention, see that the sign before the cross product is flipped from plus to minus. Finally, the formula for converting a quaternion to a rotation matrix is altered to be :\begin \mathbf_ &= \mathbf \mathbin 2 q_r mathbf v + 2 mathbf v^2 \qquad \text \\ &= \begin 1 - 2s (q_j^2 + q_k^2) & 2 (q_i q_j + q_k q_r) & 2 (q_i q_k - q_j q_r) \\ 2 (q_i q_j - q_k q_r) & 1 - 2s (q_i^2 + q_k^2) & 2 (q_j q_k + q_i q_r) \\ 2 (q_i q_k + q_j q_r) & 2 (q_j q_k - q_i q_r) & 1 - 2s (q_i^2 + q_j^2) \end \end which is exactly the
transpose In linear algebra, the transpose of a matrix is an operator which flips a matrix over its diagonal; that is, it switches the row and column indices of the matrix by producing another matrix, often denoted by (among other notations). The tr ...
of the rotation matrix converted under the traditional convention.


Software applications by convention used

The table below groups applications by their adherence to either quaternion convention: While use of either convention does not impact the capability or correctness of applications thus created, the authors of argued that the Shuster convention should be abandoned because it departs from the much older quaternion multiplication convention by Hamilton and may never be adopted by the mathematical or theoretical physics areas.


Comparison with other representations of rotations


Advantages of quaternions

The representation of a rotation as a quaternion (4 numbers) is more compact than the representation as an
orthogonal matrix In linear algebra, an orthogonal matrix, or orthonormal matrix, is a real square matrix whose columns and rows are orthonormal vectors. One way to express this is Q^\mathrm Q = Q Q^\mathrm = I, where is the transpose of and is the identity m ...
(9 numbers). Furthermore, for a given axis and angle, one can easily construct the corresponding quaternion, and conversely, for a given quaternion one can easily read off the axis and the angle. Both of these are much harder with matrices or
Euler angles The Euler angles are three angles introduced by Leonhard Euler to describe the orientation of a rigid body with respect to a fixed coordinate system.Novi Commentarii academiae scientiarum Petropolitanae 20, 1776, pp. 189–207 (E478PDF/ref> Th ...
. In
video game Video games, also known as computer games, are electronic games that involves interaction with a user interface or input device such as a joystick, controller, keyboard, or motion sensing device to generate visual feedback. This feedba ...
s and other applications, one is often interested in "smooth rotations", meaning that the scene should slowly rotate and not in a single step. This can be accomplished by choosing a
curve In mathematics, a curve (also called a curved line in older texts) is an object similar to a line, but that does not have to be straight. Intuitively, a curve may be thought of as the trace left by a moving point. This is the definition that ...
such as the
spherical linear interpolation In computer graphics, Slerp is shorthand for spherical linear interpolation, introduced by Ken Shoemake in the context of quaternion interpolation for the purpose of animating 3D rotation. It refers to constant-speed motion along a unit-radius g ...
in the quaternions, with one endpoint being the identity transformation 1 (or some other initial rotation) and the other being the intended final rotation. This is more problematic with other representations of rotations. When composing several rotations on a computer, rounding errors necessarily accumulate. A quaternion that is slightly off still represents a rotation after being normalized: a matrix that is slightly off may not be
orthogonal In mathematics, orthogonality is the generalization of the geometric notion of '' perpendicularity''. By extension, orthogonality is also used to refer to the separation of specific features of a system. The term also has specialized meanings in ...
any more and is harder to convert back to a proper orthogonal matrix. Quaternions also avoid a phenomenon called gimbal lock which can result when, for example in pitch/yaw/roll rotational systems, the pitch is rotated 90° up or down, so that yaw and roll then correspond to the same motion, and a degree of freedom of rotation is lost. In a
gimbal A gimbal is a pivoted support that permits rotation of an object about an axis. A set of three gimbals, one mounted on the other with orthogonal pivot axes, may be used to allow an object mounted on the innermost gimbal to remain independent of ...
-based aerospace
inertial navigation system An inertial navigation system (INS) is a navigation device that uses motion sensors ( accelerometers), rotation sensors ( gyroscopes) and a computer to continuously calculate by dead reckoning the position, the orientation, and the velocity ...
, for instance, this could have disastrous results if the aircraft is in a steep dive or ascent.


Conversion to and from the matrix representation


From a quaternion to an orthogonal matrix

The
orthogonal matrix In linear algebra, an orthogonal matrix, or orthonormal matrix, is a real square matrix whose columns and rows are orthonormal vectors. One way to express this is Q^\mathrm Q = Q Q^\mathrm = I, where is the transpose of and is the identity m ...
corresponding to a rotation by the unit quaternion (with ) when post-multiplying with a column vector is given by :R = \begin a^2 + b^2 - c^2 - d^2 & 2bc - 2ad & 2bd + 2ac \\ 2bc + 2ad & a^2 - b^2 + c^2 - d^2 & 2cd - 2ab \\ 2bd - 2ac & 2cd+2ab & a^2 -b^2 -c^2 + d^2 \\ \end. This rotation matrix is used on vector as w_\text = R \cdot w. The quaternion representation of this rotation is given by: :\begin 0\\ w_\text \end = z \begin 0 \\ w\end z^*, where z^* is the conjugate of the quaternion z , given by \mathbf^* = a - b\mathbf - c\mathbf - d\mathbf Also, quaternion multiplication is defined as (assuming ''a'' and ''b'' are quaternions, like ''z'' above): ab = \left(a_0 b_0 - \vec \cdot \vec; a_0 \vec + b_0 \vec + \vec \times \vec\right) where the order ''a'', ''b'' is important since the cross product of two vectors is not commutative. A more efficient calculation in which the quaternion does not need to be unit normalized is given by :R = \begin 1 - cc - dd & bc - ad & bd + ac \\ bc + ad & 1 - bb - dd & cd - ab \\ bd - ac & cd + ab & 1 - bb - cc \\ \end, where the following intermediate quantities have been defined: :\begin & \ \ s = 2/(a \cdot a + b \cdot b + c \cdot c + d \cdot d), \\ & \begin bs = b \cdot s, & cs = c \cdot s, & ds = d \cdot s, \\ ab = a \cdot bs, & ac = a \cdot cs, & ad = a \cdot ds, \\ bb = b \cdot bs, & bc = b \cdot cs, & bd = b \cdot ds, \\ cc = c \cdot cs, & cd = c \cdot ds, & dd = d \cdot ds . \\ \end \end


From an orthogonal matrix to a quaternion

One must be careful when converting a rotation matrix to a quaternion, as several straightforward methods tend to be unstable when the trace (sum of the diagonal elements) of the rotation matrix is zero or very small. For a stable method of converting an orthogonal matrix to a quaternion, see the Rotation matrix#Quaternion.


Fitting quaternions

The above section described how to recover a quaternion from a 3 × 3
rotation matrix In linear algebra, a rotation matrix is a transformation matrix that is used to perform a rotation in Euclidean space. For example, using the convention below, the matrix :R = \begin \cos \theta & -\sin \theta \\ \sin \theta & \cos \theta \ ...
. Suppose, however, that we have some matrix that is not a pure rotation—due to
round-off error A roundoff error, also called rounding error, is the difference between the result produced by a given algorithm using exact arithmetic and the result produced by the same algorithm using finite-precision, rounded arithmetic. Rounding errors are d ...
s, for example—and we wish to find the quaternion that most accurately represents . In that case we construct a symmetric 4 × 4 matrix : K = \frac \begin Q_-Q_-Q_ & Q_+Q_ & Q_+Q_ & Q_-Q_ \\ Q_+Q_ & Q_-Q_-Q_ & Q_+Q_ & Q_-Q_ \\ Q_+Q_ & Q_+Q_ & Q_-Q_-Q_ & Q_-Q_ \\ Q_-Q_ & Q_-Q_ & Q_-Q_ & Q_+Q_+Q_ \end , and find the
eigenvector In linear algebra, an eigenvector () or characteristic vector of a linear transformation is a nonzero vector that changes at most by a scalar factor when that linear transformation is applied to it. The corresponding eigenvalue, often denoted ...
corresponding to the largest eigenvalue (that value will be 1 if and only if is a pure rotation). The quaternion so obtained will correspond to the rotation closest to the original matrix .


Performance comparisons

This section discusses the performance implications of using quaternions versus other methods (axis/angle or rotation matrices) to perform rotations in 3D.


Results

Only three of the quaternion components are independent, as a rotation is represented by a unit quaternion. For further calculation one usually needs all four elements, so all calculations would suffer additional expense from recovering the fourth component. Likewise, angle–axis can be stored in a three-component vector by multiplying the unit direction by the angle (or a function thereof), but this comes at additional computational cost when using it for calculations. * Quaternions can be implicitly converted to a rotation-like matrix (12 multiplications and 12 additions/subtractions), which levels the following vectors rotating cost with the rotation matrix method.


Used methods

There are three basic approaches to rotating a vector : # Compute the matrix product of a 3 × 3
rotation matrix In linear algebra, a rotation matrix is a transformation matrix that is used to perform a rotation in Euclidean space. For example, using the convention below, the matrix :R = \begin \cos \theta & -\sin \theta \\ \sin \theta & \cos \theta \ ...
and the original 3 × 1
column A column or pillar in architecture and structural engineering is a structural element that transmits, through compression (physical), compression, the weight of the structure above to other structural elements below. In other words, a column i ...
matrix representing . This requires 3 × (3 multiplications + 2 additions) = 9 multiplications and 6 additions, the most efficient method for rotating a vector. # A rotation can be represented by a unit-length quaternion with scalar (real) part and vector (imaginary) part . The rotation can be applied to a 3D vector via the formula \vec_\text=\vec + 2\vec \times (\vec \times \vec + w \vec). This requires only 15 multiplications and 15 additions to evaluate (or 18 multiplications and 12 additions if the factor of 2 is done via multiplication.) This formula, originally thought to be used with axis/angle notation (Rodrigues' formula), can also be applied to quaternion notation. This yields the same result as the less efficient but more compact formula of quaternion multiplication \vec_\text = q \vec q^. # Use the angle/axis formula to convert an angle/axis to a
rotation matrix In linear algebra, a rotation matrix is a transformation matrix that is used to perform a rotation in Euclidean space. For example, using the convention below, the matrix :R = \begin \cos \theta & -\sin \theta \\ \sin \theta & \cos \theta \ ...
then multiplying with a vector, or, similarly, use a formula to convert quaternion notation to a rotation matrix, then multiplying with a vector. Converting the angle/axis to costs 12 multiplications, 2 function calls (sin, cos), and 10 additions/subtractions; from item 1, rotating using adds an additional 9 multiplications and 6 additions for a total of 21 multiplications, 16 add/subtractions, and 2 function calls (sin, cos). Converting a quaternion to costs 12 multiplications and 12 additions/subtractions; from item 1, rotating using adds an additional 9 multiplications and 6 additions for a total of 21 multiplications and 18 additions/subtractions.


Pairs of unit quaternions as rotations in 4D space

A pair of unit quaternions and can represent any rotation in 4D space. Given a four-dimensional vector , and assuming that it is a quaternion, we can rotate the vector like this: :f\left(\vec\right) = \mathbf_ \vec \mathbf_ = \begin a_&-b_&-c_&-d_\\ b_&a_&-d_&c_\\ c_&d_&a_&-b_\\ d_&-c_&b_&a_ \end \beginw\\x\\y\\z\end \begin a_&-b_&-c_&-d_\\ b_&a_&d_&-c_\\ c_&-d_&a_&b_\\ d_&c_&-b_&a_ \end. The pair of matrices represents a rotation of ℝ4. Note that since (\mathbf_ \vec) \mathbf_ = \mathbf_ (\vec \mathbf_), the two matrices must commute. Therefore, there are two commuting
subgroup In group theory, a branch of mathematics, given a group ''G'' under a binary operation ∗, a subset ''H'' of ''G'' is called a subgroup of ''G'' if ''H'' also forms a group under the operation ∗. More precisely, ''H'' is a subgroup ...
s of the group of four dimensional rotations. Arbitrary four-dimensional rotations have 6 degrees of freedom; each matrix represents 3 of those 6 degrees of freedom. Since the generators of the four-dimensional rotations can be represented by pairs of quaternions (as follows), all four-dimensional rotations can also be represented. :\begin \mathbf_ \vec \mathbf_ &= \begin 1 &-dt_&-dt_&-dt_\\ dt_&1 &-dt_&-dt_\\ dt_& dt_&1 &-dt_\\ dt_& dt_& dt_&1 \end \begin w\\ x\\ y\\ z \end \\ pt \mathbf_ &= 1+i+j+k \\ pt \mathbf_ &= 1+i+j+k \end


See also

* Anti-twister mechanism *
Binary polyhedral group In geometry, a point group in three dimensions is an isometry group in three dimensions that leaves the origin fixed, or correspondingly, an isometry group of a sphere. It is a subgroup of the orthogonal group O(3), the group of all isometries ...
* Biquaternion * Charts on SO(3) *
Clifford algebra In mathematics, a Clifford algebra is an algebra generated by a vector space with a quadratic form, and is a unital associative algebra. As -algebras, they generalize the real numbers, complex numbers, quaternions and several other hyperco ...
s *
Conversion between quaternions and Euler angles Spatial rotations in three dimensions can be parametrized using both Euler angles and unit quaternions. This article explains how to convert between the two representations. Actually this simple use of "quaternions" was first presented by Euler ...
*
Covering space A covering of a topological space X is a continuous map \pi : E \rightarrow X with special properties. Definition Let X be a topological space. A covering of X is a continuous map : \pi : E \rightarrow X such that there exists a discrete spa ...
* Dual quaternion * Dual-complex number *
Elliptic geometry Elliptic geometry is an example of a geometry in which Euclid's parallel postulate does not hold. Instead, as in spherical geometry, there are no parallel lines since any two lines must intersect. However, unlike in spherical geometry, two lines ...
* Rotation formalisms in three dimensions *
Rotation (mathematics) Rotation in mathematics is a concept originating in geometry. Any rotation is a motion of a certain space that preserves at least one point. It can describe, for example, the motion of a rigid body around a fixed point. Rotation can have sig ...
*
Spin group In mathematics the spin group Spin(''n'') page 15 is the double cover of the special orthogonal group , such that there exists a short exact sequence of Lie groups (when ) :1 \to \mathrm_2 \to \operatorname(n) \to \operatorname(n) \to 1. As a ...
*
Slerp In computer graphics, Slerp is shorthand for spherical linear interpolation, introduced by Ken Shoemake in the context of quaternion interpolation for the purpose of animating 3D rotation. It refers to constant-speed motion along a unit-radius g ...
, spherical linear interpolation *
Olinde Rodrigues Benjamin Olinde Rodrigues (6 October 1795 – 17 December 1851), more commonly known as Olinde Rodrigues, was a French banker, mathematician, and social reformer. In mathematics Rodrigues is remembered for Rodrigues' rotation formula for vectors ...
*
William Rowan Hamilton Sir William Rowan Hamilton Doctor of Law, LL.D, Doctor of Civil Law, DCL, Royal Irish Academy, MRIA, Royal Astronomical Society#Fellow, FRAS (3/4 August 1805 – 2 September 1865) was an Irish mathematician, astronomer, and physicist. He was the ...


References


Further reading

* * *


External links and resources

* * on
Rosetta Code Rosetta Code is a wiki-based programming website with implementations of common algorithms and solutions to various programming problems in many different programming languages. It is named for the Rosetta Stone, which has the same text inscri ...
* * * * * * * *{{cite web, url=https://eater.net/quaternions , title= Visual representation of quaternion rotation Quaternions Rotation in three dimensions Rigid bodies mechanics 3D computer graphics