STEM 隨筆︰古典力學︰運動學【二.四D】

由於維基百科『軸角表示』詞條之

Rotating a vector

Rodrigues’ rotation formula, named after Olinde Rodrigues, is an efficient algorithm for rotating a Euclidean vector, given a rotation axis and an angle of rotation. In other words, Rodrigues’ formula provides an algorithm to compute the exponential map from \displaystyle {\mathfrak {so}} (3) to SO(3) without computing the full matrix exponential.

If v is a vector in 3 and e is a unit vector rooted at the origin describing an axis of rotation about which v is rotated by an angle θ, Rodrigues’ rotation formula to obtain the rotated vector is

\displaystyle \mathbf {v} _{\mathrm {rot} }=(\cos \theta )\mathbf {v} +(\sin \theta )(\mathbf {e} \times \mathbf {v} )+(1-\cos \theta )(\mathbf {e} \cdot \mathbf {v} )\mathbf {e} \,.

For the rotation of a single vector it may be more efficient than converting e and θ into a rotation matrix to rotate the vector.

Relationship to other representations

There are several ways to represent a rotation. It is useful to understand how different representations relate to one another, and how to convert between them. Here the unit vector is denoted ω instead of e.

Exponential map from so{\mathfrak {so}}(3) to SO(3)

The exponential map effects a transformation from the axis-angle representation of rotations to rotation matrices,

\displaystyle \exp \colon {\mathfrak {so}}(3)\to \mathrm {SO} (3)\,.

Essentially, by using a Taylor expansion one derives a closed-form relation between these two representations. Given a unit vector ω ∈  \displaystyle {\mathfrak {so}} (3) = ℝ3 representing the unit rotation axis, and an angle, θ ∈ ℝ, an equivalent rotation matrix R is given as follows, where Kis the cross product matrix of ω, that is, Kv = ω × v for all vectors v ∈ ℝ3,
\displaystyle R=\exp(\theta \mathbf {K} )=\sum _{k=0}^{\infty }{\frac {(\theta \mathbf {K} )^{k}}{k!}}=I+\theta \mathbf {K} +{\frac {1}{2!}}(\theta \mathbf {K} )^{2}+{\frac {1}{3!}}(\theta \mathbf {K} )^{3}+\cdots
Because K is skew-symmetric, and the sum of the squares of its above-diagonal entries is 1, the characteristic polynomial P(t) of K is P(t) = det(KtI) = −(t3 + t). Since, by the Cayley–Hamilton theorem, P(K) = 0, this implies that
\displaystyle \mathbf {K} ^{3}=-\mathbf {K} \,.
As a result, K4 = –K2, K5 = K, K6 = K2, K7 = –K.

This cyclic pattern continues indefinitely, and so all higher powers of K can be expressed in terms of K and K2. Thus, from the above equation, it follows that

\displaystyle R=I+\left(\theta -{\frac {\theta ^{3}}{3!}}+{\frac {\theta ^{5}}{5!}}-\cdots \right)\mathbf {K} +\left({\frac {\theta ^{2}}{2!}}-{\frac {\theta ^{4}}{4!}}+{\frac {\theta ^{6}}{6!}}-\cdots \right)\mathbf {K} ^{2}\,,

that is,
\displaystyle R=I+(\sin \theta )\mathbf {K} +(1-\cos \theta )\mathbf {K} ^{2}\,.
This is a Lie-algebraic derivation, in contrast to the geometric one in the article Rodrigues’ rotation formula.[1]

Due to the existence of the above-mentioned exponential map, the unit vector ω representing the rotation axis, and the angle θ are sometimes called the exponential coordinates of the rotation matrix R.

Log map from SO(3) to so{\mathfrak {so}}(3)

Let K continue to denote the 3 × 3 matrix that effects the cross product with the rotation axis ω: K(v) = ω × v for all vectors v in what follows.

To retrieve the axis–angle representation of a rotation matrix, calculate the angle of rotation from the trace of the rotation matrix

\displaystyle \theta =\arccos \left({\frac {\operatorname {Tr} (R)-1}{2}}\right)

and then use that to find the normalized axis,
\displaystyle {\boldsymbol {\omega }}={\frac {1}{2\sin \theta }}{\begin{bmatrix}R(3,2)-R(2,3)\\R(1,3)-R(3,1)\\R(2,1)-R(1,2)\end{bmatrix}}~.
Note also that the Matrix logarithm of the rotation matrix R is
\displaystyle \log R={\begin{cases}0&{\text{if }}\theta =0\\{\dfrac {\theta }{2\sin \theta }}\left(R-R^{\mathsf {T}}\right)&{\text{if }}\theta \neq 0{\text{ and }}\theta \in (-\pi ,\pi )\end{cases}}
An exception occurs when R has eigenvalues equal to −1. In this case, the log is not unique. However, even in the case where θ = π the Frobenius norm of the log is
\displaystyle \|\log(R)\|_{\mathrm {F} }={\sqrt {2}}|\theta |\,.
Given rotation matrices A and B,
\displaystyle d_{g}(A,B):=\left\|\log \left(A^{\mathsf {T}}B\right)\right\|_{\mathrm {F} }
is the geodesic distance on the 3D manifold of rotation matrices.

For small rotations, the above computation of θ may be numerically imprecise as the derivative of arccos goes to infinity as θ → 0. In that case, the off-axis terms will actually provide better information about θ since, for small angles, RI + θK. (This is because these are the first two terms of the Taylor series for exp(θK).)

This formulation also has numerical problems at θ = π, where the off-axis terms do not give information about the rotation axis (which is still defined up to a sign ambiguity). In that case, we must reconsider the above formula.

\displaystyle R=I+\mathbf {K} \sin \theta +\mathbf {K} ^{2}(1-\cos \theta )

At θ = π, we have
\displaystyle R=I+2\mathbf {K} ^{2}=I+2({\boldsymbol {\omega }}\otimes {\boldsymbol {\omega }}-I)=2{\boldsymbol {\omega }}\otimes {\boldsymbol {\omega }}-I
and so let
\displaystyle B:={\boldsymbol {\omega }}\otimes {\boldsymbol {\omega }}={\frac {1}{2}}(R+I)\,,
so the diagonal terms of B are the squares of the elements of ω and the signs (up to sign ambiguity) can be determined from the signs of the off-axis terms of B.

 

文本已將計算法及特殊情況解釋的十分清楚,此處不過拾遺而已。

通常旋轉軸 \vec{e} \ \parallel \ \vec{\omega} 可藉

\displaystyle \mathbf {R} =\mathbf {I} +(\sin \theta )\mathbf {K} +(1-\cos \theta )\mathbf {K} ^{2}

\displaystyle \mathbf {R}^T =\mathbf {I} -(\sin \theta )\mathbf {K} +(1-\cos \theta )\mathbf {K} ^{2}

\displaystyle \therefore \mathbf{R} - \mathbf {R}^T = 2 (\sin \theta )\mathbf {K}

得出

\displaystyle \mathbf {E} = \frac{1}{2} (\mathbf{R} - \mathbf {R}^T) ,如果 \sin \theta \neq 0

再者因為矩陣『跡』

Trace (linear algebra)

In linear algebra, the trace of an n-by-n square matrix A is defined to be the sum of the elements on the main diagonal (the diagonal from the upper left to the lower right) of A, i.e.,

\displaystyle \operatorname {tr} (A)=\sum _{i=1}^{n}a_{ii}=a_{11}+a_{22}+\dots +a_{nn}

where aii denotes the entry on the ith row and ith column of A. The trace of a matrix is the sum of the (complex) eigenvalues, and it is invariant with respect to a change of basis. This characterization can be used to define the trace of a linear operator in general. Note that the trace is only defined for a square matrix (i.e., n × n).

The trace (often abbreviated to “tr”) is related to the derivative of the determinant (see Jacobi’s formula).

The following three properties:

\displaystyle {\begin{aligned}\operatorname {tr} (A+B)&=\operatorname {tr} (A)+\operatorname {tr} (B)\\\operatorname {tr} (cA)&=c\cdot \operatorname {tr} (A)\\\operatorname {tr} (AB)&=\operatorname {tr} (BA)\end{aligned}} ,

characterize the trace completely in the sense that follows. Let f be a linear functional on the space of square matrices satisfying f(x y) = f(y x). Then f and tr are proportional.[2]

The trace is similarity-invariant, which means that A and P−1AP have the same trace. This is because

\displaystyle \operatorname {tr} \left(P^{-1}AP\right)=\operatorname {tr} \left(P^{-1}(AP)\right)=\operatorname {tr} \left((AP)P^{-1}\right)=\operatorname {tr} \left(A\left(PP^{-1}\right)\right)=\operatorname {tr} (A) .

If A is symmetric and B is antisymmetric, then

\displaystyle \operatorname {tr} (AB)=0 .

The trace of the identity matrix is the dimension of the space; this leads to generalizations of dimension using trace. The trace of an idempotent matrix A (for which A2 = A) is the rank of A. The trace of a nilpotent matrix is zero.

More generally, if f(x) = (xλ1)d1···(xλk)dk is the characteristic polynomial of a matrix A, then

\displaystyle \operatorname {tr} (A)=d_{1}\lambda _{1}+\cdots +d_{k}\lambda _{k} .

When both A and B are n-by-n, the trace of the (ring-theoretic) commutator of A and B vanishes: tr([AB]) = 0; one can state this as “the trace is a map of Lie algebras \displaystyle gl_{n}\to k from operators to scalars”, as the commutator of scalars is trivial (it is an abelian Lie algebra). In particular, using similarity invariance, it follows that the identity matrix is never similar to the commutator of any pair of matrices.

Conversely, any square matrix with zero trace is a linear combinations of the commutators of pairs of matrices.[3] Moreover, any square matrix with zero trace is unitarily equivalent to a square matrix with diagonal consisting of all zeros.

The trace of any power of a nilpotent matrix is zero. When the characteristic of the base field is zero, the converse also holds: if \displaystyle \operatorname {tr} \left(x^{k}\right)=0 for all \displaystyle kk, then \displaystyle x is nilpotent.

The trace of a Hermitian matrix is real, because the elements on the diagonal are real.

The trace of a projection matrix is the dimension of the target space.

\displaystyle {\begin{aligned}P_{X}&=X\left(X^{\mathrm {T} }X\right)^{-1}X^{\mathrm {T} }\\\Rightarrow \operatorname {tr} \left(P_{X}\right)&=\operatorname {rank} \left(X\right)\end{aligned}} .

Note that \displaystyle P_{X}P_{X}is idempotent, and more generally the trace of any idempotent matrix equals its rank.

 

之性質,自可想像某一旋轉 P 將之變換到 x \ or \ y \ or \ z 軸之一︰

Basic rotations

A basic 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 the x-, y-, or z-axis, in three dimensions, using the right-hand rule—which codifies their alternating signs. (The same matrices can also represent a clockwise rotation of the axes.[nb 1])

\displaystyle {\begin{alignedat}{1}R_{x}(\theta )&={\begin{bmatrix}1&0&0\\0&\cos \theta &-\sin \theta \\[3pt]0&\sin \theta &\cos \theta \\[3pt]\end{bmatrix}}\\[6pt]R_{y}(\theta )&={\begin{bmatrix}\cos \theta &0&\sin \theta \\[3pt]0&1&0\\[3pt]-\sin \theta &0&\cos \theta \\\end{bmatrix}}\\[6pt]R_{z}(\theta )&={\begin{bmatrix}\cos \theta &-\sin \theta &0\\[3pt]\sin \theta &\cos \theta &0\\[3pt]0&0&1\\\end{bmatrix}}\end{alignedat}}

此時『跡』是 \displaystyle 2 \cos \theta + 1 ,終將之轉回 P^{-1} ,故得

\displaystyle \theta =\arccos \left({\frac {\operatorname {Tr} (R)-1}{2}}\right) 矣。

其餘自能玩轉深入呦◎