This article needs editing tocomply with Wikipedia'sManual of Style. In particular, it has problems withMOS:FORMULA - avoid mixing <math>...</math> and{{math}} in the same expression. Please helpimprove the content.(July 2025) (Learn how and when to remove this message) |
Inlinear algebra, arotation matrix is atransformation matrix that is used to perform arotation inEuclidean space. For example, using the convention below, the matrix
rotates points in thexy plane counterclockwise through an angleθ about the origin of a two-dimensionalCartesian coordinate system. To perform the rotation on a plane point with standard coordinatesv = (x,y), it should be written as acolumn vector, andmultiplied by the matrixR:
Ifx andy are the coordinates of the endpoint of a vector with the lengthr and the angle with respect to thex-axis, so that and, then the above equations become thetrigonometric summation angle formulae:Indeed, these are the trigonometric summation angle formulae in matrix form. One way to understand this is to say we have a vector at an angle 30° from thex-axis, and we wish to rotate that angle by a further 45°. We simply need to compute the vector endpoint coordinates at 75°.
The examples in this article apply toactive rotations of vectorscounterclockwise in aright-handed coordinate system (y counterclockwise fromx) bypre-multiplication (the rotation matrixR applied on the left of the column vectorv to be rotated). If any one of these is changed (such as rotating axes instead of vectors, apassive transformation), then theinverse of the example matrix should be used, which coincides with itstranspose.
Since matrix multiplication has no effect on thezero vector (the coordinates of the origin), rotation matrices describe rotations about the origin. Rotation matrices provide an algebraic description of such rotations, and are used extensively for computations ingeometry,physics, andcomputer graphics. In some literature, the termrotation is generalized to includeimproper rotations, characterized by orthogonal matrices with adeterminant of −1 (instead of +1). An improper rotation combines aproper rotation withreflections (which invertorientation). In other cases, where reflections are not being considered, the labelproper may be dropped. The latter convention is followed in this article.
Rotation matrices aresquare matrices, withreal entries. More specifically, they can be characterized asorthogonal matrices withdeterminant 1; that is, a square matrixR is a rotation matrix if and only ifRT =R−1 anddetR = 1. Theset of all orthogonal matrices of sizen with determinant +1 is arepresentation of agroup known as thespecial orthogonal groupSO(n), one example of which is therotation group SO(3). The set of all orthogonal matrices of sizen with determinant +1 or −1 is a representation of the (general)orthogonal groupO(n).

In two dimensions, the standard rotation matrix has the following form:
This rotatescolumn vectors by means of the followingmatrix multiplication,
Thus, the new coordinates(x′,y′) of a point(x,y) after rotation are
For example, when the vector (initially aligned with thex-axis of theCartesian coordinate system)is rotated by an angleθ, its new coordinates are
and when the vector (initially aligned with they-axis of the coordinate system)is rotated by an angleθ, its new coordinates are
The direction of vector rotation is counterclockwise ifθ is positive (e.g. 90°), and clockwise ifθ is negative (e.g. −90°) for. Thus the clockwise rotation matrix is found as (by replacingθ with-θ and using the trigonometric symmetry of and)
An alternative convention uses rotating axes (instead of rotating a vector),[1] and the above matrices also represent a rotation of theaxes clockwise through an angleθ.
The two-dimensional case is the only non-trivial case where the rotation matrices group is commutative; it does not matter in which order rotations are multiply performed. For the 3-dimensional case, for example, a different order of multiple rotations gives a different result. (E.g., rotating a cell phone alongz-axis theny-axis is not equal to rotations along they-axis thenz-axis.)

If a standardright-handedCartesian coordinate system is used, with thex-axis to the right and they-axis up, the rotationR(θ) is counterclockwise. If a left-handed Cartesian coordinate system is used, withx directed to the right buty directed down,R(θ) is clockwise. Such non-standard orientations are rarely used in mathematics but are common in2D computer graphics, which often have the origin in the top left corner and they-axis down the screen or page.[2]
Seebelow for other alternative conventions which may change the sense of the rotation produced by a rotation matrix.
Matricesare 2D rotation matrices corresponding to counter-clockwise rotations of respective angles of 0°, 90°, 180°, and 270°.
The matrices of the shape form aring, since their set is closed under addition and multiplication.Since(where is theidentity matrix), the map(where corresponds to) is aring isomorphism from this ring to thefield of thecomplex numbers (incidentally, this shows that this ring is a field). Under this isomorphism, the rotation matricescorrespond to thecircle of theunit complex numbers, the complex numbers of modulus1, since. As a result, the following equality holds,where the first equality isEuler's formula, the matrixcorresponds to 1, and the matrix corresponds to theimaginary unit.
If one identifies with through thelinear isomorphism, where and, the action of a matrix on a vector corresponds to multiplication on the complex number byx +iy. In other words, a vector rotation corresponds to multiplication on a complex number (corresponding to the vector being rotated) by a complex number of modulus1 (corresponding to the rotation matrix).
A basic 3D rotation (also called elemental rotation) is a rotation about one of the axes of a coordinate system. The following three basic rotation matrices rotate vectors by an angleθ about thex-,y-, orz-axis, in three dimensions, using theright-hand rule—which codifies their alternating signs.[3] Notice that the right-hand rule only works when multiplying. The same matrices can also represent a clockwise rotation of the axes keeping the vectors unchanged.[nb 1]
Forcolumn vectors, each of these basic vector rotations appears counterclockwise when the axis about which they occur points toward the observer, the coordinate system is right-handed, and the angleθ is positive.Rz, for instance, would rotate toward they-axis a vector aligned with thex-axis, as can easily be checked by operating withRz on the vector(1,0,0):
This is similar to the rotation produced by the above-mentioned two-dimensional rotation matrix. Seebelow for alternative conventions which may apparently or actually invert the sense of the rotation produced by these matrices.
Other 3D rotation matrices can be obtained from these three usingmatrix multiplication. For example, the product
represents a rotation whoseyaw, pitch, and roll angles areα,β andγ, respectively. More formally, it is anintrinsic rotation whoseTait–Bryan angles areα,β,γ, about axesz,y,x, respectively.Similarly, the productrepresents anextrinsic rotation whose (improper)Euler angles areα,β,γ, about axesx,y,z.
These matrices produce the desired effect only if they are used to premultiplycolumn vectors, and (since in general matrix multiplication is notcommutative) only if they are applied in the specified order (seeAmbiguities for more details). The order of rotation operations is from right to left; the matrix adjacent to the column vector is the first to be applied, and then the one to the left.[4]
Every rotation in three dimensions is defined by itsaxis (a vector along this axis is unchanged by the rotation), and itsangle — the amount of rotation about that axis (Euler rotation theorem).
There are several methods to compute the axis and angle from a rotation matrix (see alsoaxis–angle representation). Here, we only describe the method based on the computation of theeigenvectors andeigenvalues of the rotation matrix. It is also possible to use thetrace of the rotation matrix.

Given a3 × 3 rotation matrixR, a vectoru parallel to the rotation axis must satisfysince the rotation ofu around the rotation axis must result inu. The equation above may be solved foru which is unique up to a scalar factor unlessR is theidentity matrixI.
Further, the equation may be rewrittenwhich shows thatu lies in thenull space ofR −I.
This means precisely that thatu is aneigenvector ofR corresponding to theeigenvalueλ = 1. Every rotation matrix must have this eigenvalue, the other two eigenvalues beingcomplex conjugates of each other. It follows that a general rotation matrix in three dimensions has, up to a multiplicative constant, only one real eigenvector.
One way to determine the rotation axis is by showing that:[5]
Since(R −RT) is askew-symmetric matrix, we can chooseu such thatThe matrix–vector product becomes across product of a vector with itself, ensuring that the result is zero:
Therefore, ifthenThe magnitude ofu computed this way is‖u‖ = 2 sinθ, whereθ is the angle of rotation.
Thisdoes not work ifR is symmetric. Above, ifR −RT is zero, then all subsequent steps are invalid. In this case, the angle of rotation is 0° or 180° and any nonzero column ofI +R is an eigenvector ofR with eigenvalue 1 becauseR(I +R) =R +R2 =R +RRT =I +R.[6]
To find the angle of a rotation, once the axis of the rotation is known, select a vectorv perpendicular to the axis. Then the angle of the rotation is the angle betweenv andRv.
A more direct method, however, is to simply calculate thetrace: the sum of the diagonal elements of the rotation matrix. Care should be taken to select the right sign for the angleθ to match the chosen axis:
from which follows that the angle's absolute value is
For the rotation axis, you can get the correct angle[7] from
where
The matrix of a proper rotationR by angleθ around the axisu = (ux,uy,uz), aunit vector withu2
x +u2
y +u2
z = 1, is given by:[8][9][10][11]
A derivation of this matrix from first principles can be found in section 9.2 here.[12] The basic idea to derive this matrix is dividing the problem into few known simple steps.
This can be written more concisely as[13]where[u]× is thecross product matrix ofu; the expressionu ⊗u is theouter product, andI is theidentity matrix. Alternatively, the matrix entries are:
whereεjkl is theLevi-Civita symbol withε123 = 1. This is a matrix form ofRodrigues' rotation formula, (or the equivalent, differently parametrizedEuler–Rodrigues formula) with[nb 2]
In the rotation of a vectorx around the axisu by an angleθ can be written as:
or equivalently:
This can also be written intensor notation as:[14]
If the 3D space is right-handed andθ > 0, this rotation will be counterclockwise whenu points towards the observer (Right-hand rule). Explicitly, with a right-handed orthonormal basis,
Note the strikingmerely apparent differences to theequivalent Lie-algebraic formulationbelow.
For anyn-dimensional rotation matrixR acting on
A rotation is termed proper ifdetR = 1, andimproper (or a roto-reflection) ifdetR = –1. For even dimensionsn = 2k, theneigenvaluesλ of a proper rotation occur as pairs ofcomplex conjugates which are roots of unity:λ =e±iθj forj = 1, ...,k, which is real only forλ = ±1. Therefore, there may be no vectors fixed by the rotation (λ = 1), and thus no axis of rotation. Any fixed eigenvectors occur in pairs, and the axis of rotation is an even-dimensional subspace.
For odd dimensionsn = 2k + 1, a proper rotationR will have an odd number of eigenvalues, with at least oneλ = 1 and the axis of rotation will be an odd dimensional subspace. Proof:
HereI is the identity matrix, and we usedet(RT) = det(R) = 1, as well as(−1)n = −1 sincen is odd. Therefore,det(R –I) = 0, meaning there is a nonzero vectorv with(R – I)v = 0, that isRv =v, a fixed eigenvector. There may also be pairs of fixed eigenvectors in the even-dimensional subspace orthogonal tov, so the total dimension of fixed eigenvectors is odd.
For example, in2-spacen = 2, a rotation by angleθ has eigenvaluesλ =eiθ andλ =e−iθ, so there is no axis of rotation except whenθ = 0, the case of the null rotation. In3-spacen = 3, the axis of a non-null proper rotation is always a unique line, and a rotation around this axis by angleθ has eigenvaluesλ = 1,eiθ,e−iθ. In4-spacen = 4, the four eigenvalues are of the forme±iθ,e±iφ. The null rotation hasθ =φ = 0. The case ofθ = 0,φ ≠ 0 is called asimple rotation, with two unit eigenvalues forming anaxis plane, and a two-dimensional rotation orthogonal to the axis plane. Otherwise, there is no axis plane. The case ofθ =φ is called anisoclinic rotation, having eigenvaluese±iθ repeated twice, so every vector is rotated through an angleθ.
The trace of a rotation matrix is equal to the sum of its eigenvalues. Forn = 2, a rotation by angleθ has trace2 cosθ. Forn = 3, a rotation around any axis by angleθ has trace1 + 2 cosθ. Forn = 4, and the trace is2(cosθ + cosφ), which becomes4 cosθ for an isoclinic rotation.
|
|
InEuclidean geometry, a rotation is an example of anisometry, a transformation that moves points without changing the distances between them. Rotations are distinguished from other isometries by two additional properties: they leave (at least) one point fixed, and they leave "handedness" unchanged. In contrast, atranslation moves every point, areflection exchanges left- and right-handed ordering, aglide reflection does both, and animproper rotation combines a change in handedness with a normal rotation.
If a fixed point is taken as the origin of aCartesian coordinate system, then every point can be given coordinates as a displacement from the origin. Thus one may work with thevector space of displacements instead of the points themselves. Now suppose(p1, ...,pn) are the coordinates of the vectorp from the originO to pointP. Choose anorthonormal basis for our coordinates; then the squared distance toP, byPythagoras, iswhich can be computed using the matrix multiplication
A geometric rotation transforms lines to lines, and preserves ratios of distances between points. From these properties it can be shown that a rotation is alinear transformation of the vectors, and thus can be written inmatrix form,Qp. The fact that a rotation preserves, not just ratios, but distances themselves, is stated asorBecause this equation holds for all vectors,p, one concludes that every rotation matrix,Q, satisfies theorthogonality condition,Rotations preserve handedness because they cannot change the ordering of the axes, which implies thespecial matrix condition,Equally important, it can be shown that any matrix satisfying these two conditions acts as a rotation.
The inverse of a rotation matrix is its transpose, which is also a rotation matrix:The product of two rotation matrices is a rotation matrix:Forn > 2, multiplication ofn ×n rotation matrices is generally notcommutative.Noting that anyidentity matrix is a rotation matrix, and that matrix multiplication isassociative, we may summarize all these properties by saying that then ×n rotation matrices form agroup, which forn > 2 isnon-abelian, called aspecial orthogonal group, and denoted bySO(n),SO(n,R),SOn, orSOn(R), the group ofn ×n rotation matrices is isomorphic to the group of rotations in ann-dimensional space. This means that multiplication of rotation matrices corresponds to composition of rotations, applied in left-to-right order of their corresponding matrices.

The interpretation of a rotation matrix can be subject to many ambiguities.
In most cases the effect of the ambiguity is equivalent to the effect of a rotation matrixinversion (for these orthogonal matrices equivalently matrixtranspose).
Consider the3 × 3 rotation matrixIfQ acts in a certain direction,v, purely as a scaling by a factorλ, then we haveso thatThusλ is a root of thecharacteristic polynomial forQ,Two features are noteworthy. First, one of the roots (oreigenvalues) is 1, which tells us that some direction is unaffected by the matrix. For rotations in three dimensions, this is theaxis of the rotation (a concept that has no meaning in any other dimension). Second, the other two roots are a pair of complex conjugates, whose product is 1 (the constant term of the quadratic), and whose sum is2 cosθ (the negated linear term). This factorization is of interest for3 × 3 rotation matrices because the same thing occurs for all of them. (As special cases, for a null rotation the "complex conjugates" are both 1, and for a 180° rotation they are both −1.) Furthermore, a similar factorization holds for anyn ×n rotation matrix. If the dimension,n, is odd, there will be a "dangling" eigenvalue of 1; and for any dimension the rest of the polynomial factors into quadratic terms like the one here (with the two special cases noted). We are guaranteed that the characteristic polynomial will have degreen and thusn eigenvalues. And since a rotation matrix commutes with its transpose, it is anormal matrix, so can be diagonalized. We conclude that every rotation matrix, when expressed in a suitable coordinate system, partitions into independent rotations of two-dimensional subspaces, at mostn/2 of them.
The sum of the entries on themain diagonal of a matrix is called thetrace; it does not change if we reorient the coordinate system, and always equals the sum of the eigenvalues. This has the convenient implication for2 × 2 and3 × 3 rotation matrices that the trace reveals theangle of rotation,θ, in the two-dimensional space (or subspace). For a2 × 2 matrix the trace is2 cosθ, and for a3 × 3 matrix it is1 + 2 cosθ. In the three-dimensional case, the subspace consists of all vectors perpendicular to the rotation axis (the invariant direction, with eigenvalue 1). Thus we can extract from any3 × 3 rotation matrix a rotation axis and an angle, and these completely determine the rotation.
The constraints on a2 × 2 rotation matrix imply that it must have the formwitha2 +b2 = 1. Therefore, we may seta = cosθ andb = sinθ, for some angleθ. To solve forθ it is not enough to look ata alone orb alone; we must consider both together to place the angle in the correctquadrant, using atwo-argument arctangent function.
Now consider the first column of a3 × 3 rotation matrix,Althougha2 +b2 will probably not equal 1, but some valuer2 < 1, we can use a slight variation of the previous computation to find a so-calledGivens rotation that transforms the column tozeroingb. This acts on the subspace spanned by thex- andy-axes. We can then repeat the process for thexz-subspace to zeroc. Acting on the full matrix, these two rotations produce the schematic formShifting attention to the second column, a Givens rotation of theyz-subspace can now zero thez value. This brings the full matrix to the formwhich is an identity matrix. Thus we have decomposedQ as
Ann ×n rotation matrix will have(n − 1) + (n − 2) + ⋯ + 2 + 1, orentries below the diagonal to zero. We can zero them by extending the same idea of stepping through the columns with a series of rotations in a fixed sequence of planes. We conclude that the set ofn ×n rotation matrices, each of which hasn2 entries, can be parameterized by1/2n(n − 1) angles.
| xzxw | xzyw | xyxw | xyzw |
| yxyw | yxzw | yzyw | yzxw |
| zyzw | zyxw | zxzw | zxyw |
| xzxb | yzxb | xyxb | zyxb |
| yxyb | zxyb | yzyb | xzyb |
| zyzb | xyzb | zxzb | yxzb |
In three dimensions this restates in matrix form an observation made byEuler, so mathematicians call the ordered sequence of three anglesEuler angles. However, the situation is somewhat more complicated than we have so far indicated. Despite the small dimension, we actually have considerable freedom in the sequence of axis pairs we use; and we also have some freedom in the choice of angles. Thus we find many different conventions employed when three-dimensional rotations are parameterized for physics, or medicine, or chemistry, or other disciplines. When we include the option of world axes or body axes, 24 different sequences are possible. And while some disciplines call any sequence Euler angles, others give different names (Cardano, Tait–Bryan,roll-pitch-yaw) to different sequences.
One reason for the large number of options is that, as noted previously, rotations in three dimensions (and higher) do not commute. If we reverse a given sequence of rotations, we get a different outcome. This also implies that we cannot compose two rotations by adding their corresponding angles. Thus Euler angles are notvectors, despite a similarity in appearance as a triplet of numbers.
A3 × 3 rotation matrix such as
suggests a2 × 2 rotation matrix,
is embedded in the upper left corner:
This is no illusion; not just one, but many, copies ofn-dimensional rotations are found within(n + 1)-dimensional rotations, assubgroups. Each embedding leaves one direction fixed, which in the case of3 × 3 matrices is the rotation axis. For example, we have
fixing thex-axis, they-axis, and thez-axis, respectively. The rotation axis need not be a coordinate axis; ifu = (x,y,z) is a unit vector in the desired direction, then
wherecθ = cosθ,sθ = sinθ, is a rotation by angleθ leaving axisu fixed.
A direction in(n + 1)-dimensional space will be a unit magnitude vector, which we may consider a point on a generalized sphere,Sn. Thus it is natural to describe the rotation groupSO(n + 1) as combiningSO(n) andSn. A suitable formalism is thefiber bundle,
where for every direction in the base space,Sn, the fiber over it in the total space,SO(n + 1), is a copy of the fiber space,SO(n), namely the rotations that keep that direction fixed.
Thus we can build ann ×n rotation matrix by starting with a2 × 2 matrix, aiming its fixed axis onS2 (the ordinary sphere in three-dimensional space), aiming the resulting rotation onS3, and so on up throughSn−1. A point onSn can be selected usingn numbers, so we again have1/2n(n − 1) numbers to describe anyn ×n rotation matrix.
In fact, we can view the sequential angle decomposition, discussed previously, as reversing this process. The composition ofn − 1 Givens rotations brings the first column (and row) to(1, 0, ..., 0), so that the remainder of the matrix is a rotation matrix of dimension one less, embedded so as to leave(1, 0, ..., 0) fixed.
When ann ×n rotation matrixQ, does not include a −1 eigenvalue, thus none of the planar rotations which it comprises are 180° rotations, thenQ +I is aninvertible matrix. Most rotation matrices fit this description, and for them it can be shown that(Q −I)(Q +I)−1 is askew-symmetric matrix,A. ThusAT = −A; and since the diagonal is necessarily zero, and since the upper triangle determines the lower one,A contains1/2n(n − 1) independent numbers.
Conveniently,I −A is invertible wheneverA is skew-symmetric; thus we can recover the original matrix using theCayley transform,which maps any skew-symmetric matrixA to a rotation matrix. In fact, aside from the noted exceptions, we can produce any rotation matrix in this way. Although in practical applications we can hardly afford to ignore 180° rotations, the Cayley transform is still a potentially useful tool, giving a parameterization of most rotation matrices without trigonometric functions.
In three dimensions, for example, we have (Cayley 1846)
If we condense the skew entries into a vector,(x,y,z), then we produce a 90° rotation around thex-axis for (1, 0, 0), around they-axis for (0, 1, 0), and around thez-axis for (0, 0, 1). The 180° rotations are just out of reach; for, in the limit asx → ∞,(x, 0, 0) does approach a 180° rotation around thex axis, and similarly for other directions.
For the 2D case, a rotation matrix can be decomposed into threeshear matrices (Paeth 1986):
This is useful, for instance, in computer graphics, since shears can be implemented with fewer multiplication instructions than rotating a bitmap directly. On modern computers, this may not matter, but it can be relevant for very old or low-end microprocessors.
A rotation can also be written as two shears and asqueeze mapping (an area preservingscaling) (Daubechies & Sweldens 1998):
Below follow some basic facts about the role of the collection ofall rotation matrices of a fixed dimension (here mostly 3) in mathematics and particularly in physics whererotational symmetry is arequirement of every truly fundamental law (due to the assumption ofisotropy of space), and where the same symmetry, when present, is asimplifying property of many problems of less fundamental nature. Examples abound inclassical mechanics andquantum mechanics. Knowledge of the part of the solutions pertaining to this symmetry applies (with qualifications) toall such problems and it can be factored out of a specific problem at hand, thus reducing its complexity. A prime example – in mathematics and physics – would be the theory ofspherical harmonics. Their role in the group theory of the rotation groups is that of being arepresentation space for the entire set of finite-dimensionalirreducible representations of the rotation group SO(3). For this topic, seeRotation group SO(3) § Spherical harmonics.
The main articles listed in each subsection are referred to for more detail.
Then ×n rotation matrices for eachn form agroup, thespecial orthogonal group,SO(n). Thisalgebraic structure is coupled with atopological structure inherited from in such a way that the operations of multiplication and taking the inverse areanalytic functions of the matrix entries. ThusSO(n) is for eachn aLie group. It iscompact andconnected, but notsimply connected. It is also asemi-simple group, in fact asimple group with the exception SO(4).[15] The relevance of this is that all theorems and all machinery from the theory ofanalytic manifolds (analytic manifolds are in particularsmooth manifolds) apply and the well-developed representation theory of compact semi-simple groups is ready for use.
The Lie algebraso(n) ofSO(n) is given byand is the space of skew-symmetric matrices of dimensionn, seeclassical group, whereo(n) is the Lie algebra ofO(n), theorthogonal group. For reference, the most common basis forso(3) is
Connecting the Lie algebra to the Lie group is theexponential map, which is defined using the standardmatrix exponential series foreA[16] For anyskew-symmetric matrixA,exp(A) is always a rotation matrix.[nb 3]
An important practical example is the3 × 3 case. Inrotation group SO(3), it is shown that one can identify everyA ∈so(3) with an Euler vectorω =θu, whereu = (x,y,z) is a unit magnitude vector.
By the properties of the identification,u is in the null space ofA. Thus,u is left invariant byexp(A) and is hence a rotation axis.
According toRodrigues' rotation formula on matrix form, one obtains,
where
This is the matrix for a rotation around axisu by the angleθ. For full detail, seeexponential map SO(3).
The BCH formula provides an explicit expression forZ = log(eXeY) in terms of a series expansion of nested commutators ofX andY.[17] This general expansion unfolds as[nb 4]
In the3 × 3 case, the general infinite expansion has a compact form,[18]for suitable trigonometric function coefficients, detailed in theBaker–Campbell–Hausdorff formula for SO(3).
As a group identity, the above holds forall faithful representations, including the doublet (spinor representation), which is simpler. The same explicit formula thus follows straightforwardly through Pauli matrices; see the2 × 2 derivation for SU(2). For the generaln ×n case, one might use Ref.[19]
The Lie group ofn ×n rotation matrices,SO(n), is notsimply connected, so Lie theory tells us it is a homomorphic image of auniversal covering group. Often the covering group, which in this case is called thespin group denoted bySpin(n), is simpler and more natural to work with.[20]
In the case of planar rotations, SO(2) is topologically acircle,S1. Its universal covering group, Spin(2), is isomorphic to thereal line,R, under addition. Whenever angles of arbitrary magnitude are used one is taking advantage of the convenience of the universal cover. Every2 × 2 rotation matrix is produced by a countable infinity of angles, separated by integer multiples of 2π. Correspondingly, thefundamental group ofSO(2) is isomorphic to the integers,Z.
In the case of spatial rotations,SO(3) is topologically equivalent to three-dimensionalreal projective space,RP3. Its universal covering group, Spin(3), is isomorphic to the3-sphere,S3. Every3 × 3 rotation matrix is produced by two opposite points on the sphere. Correspondingly, thefundamental group of SO(3) is isomorphic to the two-element group,Z2.
We can also describe Spin(3) as isomorphic toquaternions of unit norm under multiplication, or to certain4 × 4 real matrices, or to2 × 2 complexspecial unitary matrices, namely SU(2). The covering maps for the first and the last case are given byand
For a detailed account of theSU(2)-covering and the quaternionic covering, seespin group SO(3).
Many features of these cases are the same for higher dimensions. The coverings are all two-to-one, withSO(n),n > 2, having fundamental groupZ2. The natural setting for these groups is within aClifford algebra. One type of action of the rotations is produced by a kind of "sandwich", denoted byqvq∗. More importantly in applications to physics, the corresponding spin representation of the Lie algebra sits inside the Clifford algebra. It can be exponentiated in the usual way to give rise to a2-valued representation, also known asprojective representation of the rotation group. This is the case with SO(3) and SU(2), where the2-valued representation can be viewed as an "inverse" of the covering map. By properties of covering maps, the inverse can be chosen ono-to-one as a local section, but not globally.
The matrices in the Lie algebra are not themselves rotations; the skew-symmetric matrices are derivatives, proportional differences of rotations. An actual "differential rotation", orinfinitesimal rotation matrix has the formwheredθ is vanishingly small andA ∈so(n), for instance withA =Lx,
The computation rules are as usual except that infinitesimals of second order are routinely dropped. With these rules, these matrices do not satisfy all the same properties as ordinary finite rotation matrices under the usual treatment of infinitesimals.[21] It turns out thatthe order in which infinitesimal rotations are applied is irrelevant. To see this exemplified, consultinfinitesimal rotations SO(3).
We have seen the existence of several decompositions that apply in any dimension, namely independent planes, sequential angles, and nested dimensions. In all these cases we can either decompose a matrix or construct one. We have also given special attention to3 × 3 rotation matrices, and these warrant further attention, in both directions (Stuelpnagel 1964).
Given the unit quaternionq =w +xi +yj +zk, the equivalent pre-multiplied (to be used with column vectors)3 × 3 rotation matrix is[22]
Now everyquaternion component appears multiplied by two in a term of degree two, and if all such terms are zero what is left is an identity matrix. This leads to an efficient, robust conversion from any quaternion – whether unit or non-unit – to a3 × 3 rotation matrix. Given:we can calculate
Freed from the demand for a unit quaternion, we find that nonzero quaternions act ashomogeneous coordinates for3 × 3 rotation matrices. The Cayley transform, discussed earlier, is obtained by scaling the quaternion so that itsw component is 1. For a 180° rotation around any axis,w will be zero, which explains the Cayley limitation.
The sum of the entries along the main diagonal (thetrace), plus one, equals4 − 4(x2 +y2 +z2), which is4w2. Thus we can write the trace itself as2w2 + 2w2 − 1; and from the previous version of the matrix we see that the diagonal entries themselves have the same form:2x2 + 2w2 − 1,2y2 + 2w2 − 1, and2z2 + 2w2 − 1. So we can easily compare the magnitudes of all four quaternion components using the matrix diagonal. We can, in fact, obtain all four magnitudes using sums and square roots, and choose consistent signs using the skew-symmetric part of the off-diagonal entries:
Alternatively, use a single square root and division
This is numerically stable so long as the trace,t, is not negative; otherwise, we risk dividing by (nearly) zero. In that case, supposeQxx is the largest diagonal entry, sox will have the largest magnitude (the other cases are derived by cyclic permutation); then the following is safe.
If the matrix contains significant error, such as accumulated numerical error, we may construct a symmetric4 × 4 matrix,and find theeigenvector,(x,y,z,w), of its largest magnitude eigenvalue. (IfQ is truly a rotation matrix, that value will be 1.) The quaternion so obtained will correspond to the rotation matrix closest to the given matrix (Bar-Itzhack 2000) (Note: formulation of the cited article is post-multiplied, works with row vectors).
If then ×n matrixM is nonsingular, its columns are linearly independent vectors; thus theGram–Schmidt process can adjust them to be an orthonormal basis. Stated in terms ofnumerical linear algebra, we convertM to an orthogonal matrix,Q, usingQR decomposition. However, we often prefer aQ closest toM, which this method does not accomplish. For that, the tool we want is thepolar decomposition (Fan & Hoffman 1955;Higham 1989).
To measure closeness, we may use anymatrix norm invariant under orthogonal transformations. A convenient choice is theFrobenius norm,‖Q −M‖F, squared, which is the sum of the squares of the element differences. Writing this in terms of thetrace,Tr, our goal is,
Though written in matrix terms, theobjective function is just a quadratic polynomial. We can minimize it in the usual way, by finding where its derivative is zero. For a3 × 3 matrix, the orthogonality constraint implies six scalar equalities that the entries ofQ must satisfy. To incorporate the constraint(s), we may employ a standard technique,Lagrange multipliers, assembled as a symmetric matrix,Y. Thus our method is:
Consider a2 × 2 example. Including constraints, we seek to minimize
Taking the derivative with respect toQxx,Qxy,Qyx,Qyy in turn, we assemble a matrix.
In general, we obtain the equationso thatwhereQ is orthogonal andS is symmetric. To ensure a minimum, theY matrix (and henceS) must be positive definite. Linear algebra callsQS thepolar decomposition ofM, withS the positive square root ofS2 =MTM.
WhenM isnon-singular, theQ andS factors of the polar decomposition are uniquely determined. However, the determinant ofS is positive becauseS is positive definite, soQ inherits the sign of the determinant ofM. That is,Q is only guaranteed to be orthogonal, not a rotation matrix. This is unavoidable; anM with negative determinant has no uniquely defined closest rotation matrix.
To efficiently construct a rotation matrixQ from an angleθ and a unit axisu, we can take advantage of symmetry and skew-symmetry within the entries. Ifx,y, andz are the components of the unit vector representing the axis, and
then
Determining an axis and angle, like determining a quaternion, is only possible up to the sign; that is,(u,θ) and(−u, −θ) correspond to the same rotation matrix, just likeq and−q. Additionally, axis–angle extraction presents additional difficulties. The angle can be restricted to be from 0° to 180°, but angles are formally ambiguous by multiples of 360°. When the angle is zero, the axis is undefined. When the angle is 180°, the matrix becomes symmetric, which has implications in extracting the axis. Near multiples of 180°, care is needed to avoid numerical problems: in extracting the angle, atwo-argument arctangent withatan2(sinθ, cosθ) equal toθ avoids the insensitivity of arccos; and in computing the axis magnitude in order to force unit magnitude, a brute-force approach can lose accuracy through underflow (Moler & Morrison 1983).
A partial approach is as follows:
Thex-,y-, andz-components of the axis would then be divided byr. A fully robust approach will use a different algorithm whent, thetrace of the matrixQ, is negative, as with quaternion extraction. Whenr is zero because the angle is zero, an axis must be provided from some source other than the matrix.
Complexity of conversion escalates withEuler angles (used here in the broad sense). The first difficulty is to establish which of the twenty-four variations of Cartesian axis order we will use. Suppose the three angles areθ1,θ2,θ3; physics and chemistry may interpret these aswhile aircraft dynamics may useOne systematic approach begins with choosing the rightmost axis. Among allpermutations of(x,y,z), only two place that axis first; one is an even permutation and the other odd. Choosing parity thus establishes the middle axis. That leaves two choices for the left-most axis, either duplicating the first or not. These three choices gives us3 × 2 × 2 = 12 variations; we double that to 24 by choosing static or rotating axes.
This is enough to construct a matrix from angles, but triples differing in many ways can give the same rotation matrix. For example, suppose we use thezyz convention above; then we have the following equivalent pairs:
| (90°, | 45°, | −105°) | ≡ | (−270°, | −315°, | 255°) | multiples of 360° |
| (72°, | 0°, | 0°) | ≡ | (40°, | 0°, | 32°) | singular alignment |
| (45°, | 60°, | −30°) | ≡ | (−135°, | −60°, | 150°) | bistable flip |
Angles for any order can be found using a concise common routine (Herter & Lott 1993;Shoemake 1994).
The problem of singular alignment, the mathematical analog of physicalgimbal lock, occurs when the middle rotation aligns the axes of the first and last rotations. It afflicts every axis order at either even or odd multiples of 90°. These singularities are not characteristic of the rotation matrix as such, and only occur with the usage of Euler angles.
The singularities are avoided when considering and manipulating the rotation matrix as orthonormal row vectors (in 3D applications often named the right-vector, up-vector and out-vector) instead of as angles. The singularities are also avoided when working with quaternions.
In some instances it is interesting to describe a rotation by specifying how a vector is mapped into another through the shortest path (smallest angle). In this completely describes the associated rotation matrix. In general, givenx,y ∈n, the matrixbelongs toSO(n + 1) and mapsx toy.[23]
Inmaterials science, the four-dimensionalstiffness and compliancetensors are often simplified to a two-dimensional matrix usingVoigt notation. When applying a rotational transform through angle in this notation, the rotation matrix is given by[24]
This is particularly useful incomposite laminate design, where plies are often rotated by a certain angle to bring the properties of the laminate closer toisotropic.
We sometimes need to generate a uniformly distributed random rotation matrix. It seems intuitively clear in two dimensions that this means the rotation angle is uniformly distributed between 0 and 2π. That intuition is correct, but does not carry over to higher dimensions. For example, if we decompose3 × 3 rotation matrices in axis–angle form, the angle shouldnot be uniformly distributed; the probability that (the magnitude of) the angle is at mostθ should be1/π(θ − sinθ), for0 ≤θ ≤ π.
SinceSO(n) is a connected and locally compact Lie group, we have a simple standard criterion for uniformity, namely that the distribution be unchanged when composed with any arbitrary rotation (a Lie group "translation"). This definition corresponds to what is calledHaar measure.León, Massé & Rivest (2006) show how to use the Cayley transform to generate and test matrices according to this criterion.
We can also generate a uniform distribution in any dimension using thesubgroup algorithm ofDiaconis & Shahshahani (1987). This recursively exploits the nested dimensions group structure ofSO(n), as follows. Generate a uniform angle and construct a2 × 2 rotation matrix. To step fromn ton + 1, generate a vectorv uniformly distributed on then-sphereSn, embed then ×n matrix in the next larger size with last column(0, ..., 0, 1), and rotate the larger matrix so the last column becomesv.
As usual, we have special alternatives for the3 × 3 case. Each of these methods begins with three independent random scalars uniformly distributed on the unit interval.Arvo (1992) takes advantage of the odd dimension to change aHouseholder reflection to a rotation by negation, and uses that to aim the axis of a uniform planar rotation.
Another method uses unit quaternions. Multiplication of rotation matrices is homomorphic to multiplication of quaternions, and multiplication by a unit quaternion rotates the unit sphere. Since the homomorphism is a localisometry, we immediately conclude that to produce a uniform distribution on SO(3) we may use a uniform distribution onS3. In practice: create a four-element vector where each element is a sampling of a normal distribution. Normalize its length and you have a uniformly sampled random unit quaternion which represents a uniformly sampled random rotation. Note that the aforementioned only applies to rotations in dimension 3. For a generalised idea of quaternions, one should look intoRotors.
Euler angles can also be used, though not with each angle uniformly distributed (Murnaghan 1962;Miles 1965).
For the axis–angle form, the axis is uniformly distributed over the unit sphere of directions,S2, while the angle has the nonuniform distribution over[0,π] noted previously (Miles 1965).
{{citation}}:ISBN / Date incompatibility (help)