9
A Note on Averaging Rotations W. Dan Curtis’, Adam L. Janin’, and Karel Zikan’ Abstract Computing average rotations is a fundamental sensor-jksion problem. In Virtual Reality, the problem naturally arises in connection with position sensing. We derive two methods for additive averaging of rotations. One of these methods, based on quarternions, is limited to averages of 3-dimensional rotations, but the other method, based on singular value decomposition, works in any euclidean space. Section 1 Introduction Computing average rotations is a fundamental sensor-fusion problem. In Virtual Reality, the problem arises in connection with position sensing, for instance, when the orientation of a person (or an object) needs to be determined. All physical sensors are somewhat inaccurate and some are also subject to “noise”. The inaccuracy of sensors results in incorrect alignment of images, the “noise” produces image jitter. The effects of both problems can be reduced by averaging data from different sensors, or by (weighted) averaging of data from a single sensor over time. Let us consider two general rotations given by 72 x n matrices U1 and IJ2. It is not immediately obvious how to average them. We need to find a rotation matrix U that best resembles both Ul and U2. The matrix $([Il + U2) does not represent a rotation, nor does any multiple of this matrix. Averaging Euler’s angles also does not work-we get different answers for different Cartesian coordinate systems. We show in this paper that a sensible average of the two rotations is given by U, = Xl; where SDY = lil + IJ2 (1) is a singular value decomposition (SVD) of U1 + [I,. The matrix IT, is the projection of U1 + U? onto the space of rotation matrices, that is, U, maximizes the inner product (UI + ~ 2 , = trace[(tTl + [12)[~’]. (2) Boeing Computer Services, Research and Technology, P.O. Box 24346, M/S 7L-21, Seattle, WA 98124-0346 0-7803-1363-1193 $3.00 8 1993 EEE 377

[IEEE IEEE Virtual Reality Annual International Symposium - Seattle, WA, USA (18-22 Sept. 1993)] Proceedings of IEEE Virtual Reality Annual International Symposium - A note on averaging

  • Upload
    k

  • View
    216

  • Download
    3

Embed Size (px)

Citation preview

Page 1: [IEEE IEEE Virtual Reality Annual International Symposium - Seattle, WA, USA (18-22 Sept. 1993)] Proceedings of IEEE Virtual Reality Annual International Symposium - A note on averaging

A Note on Averaging Rotations

W. Dan Curtis’, Adam L. Janin’, and Karel Zikan’

Abstract Computing average rotations is a fundamental sensor-jksion problem. In Virtual Reality, the problem naturally arises in connection with position sensing. We derive two methods for additive averaging of rotations. One of these methods, based on quarternions, is limited to averages of 3-dimensional rotations, but the other method, based on singular value decomposition, works in any euclidean space.

Section 1 Introduction Computing average rotations is a fundamental sensor-fusion problem. In Virtual Reality, the problem arises in connection with position sensing, for instance, when the orientation of a person (or an object) needs to be determined. All physical sensors are somewhat inaccurate and some are also subject to “noise”. The inaccuracy of sensors results in incorrect alignment of images, the “noise” produces image jitter. The effects of both problems can be reduced by averaging data from different sensors, or by (weighted) averaging of data from a single sensor over time.

Let us consider two general rotations given by 72 x n matrices U1 and I J2 . It is not immediately obvious how to average them. We need to find a rotation matrix U that best resembles both Ul and U2. The matrix $ ( [ I l + U 2 ) does not represent a rotation, nor does any multiple of this matrix. Averaging Euler’s angles also does not work-we get different answers for different Cartesian coordinate systems.

We show in this paper that a sensible average of the two rotations is given by

U, = Xl; where S D Y = l i l + IJ2 (1) is a singular value decomposition (SVD) of U1 + [I,. The matrix IT, is the projection of U1 + U? onto the space of rotation matrices, that is, U, maximizes the inner product

( U I + ~ 2 , = trace[(tTl + [12)[~’] . (2) Boeing Computer Services, Research and Technology, P.O. Box 24346, M/S 7L-21, Seattle, WA 98124-0346

0-7803-1363-1193 $3.00 8 1993 EEE 377

Page 2: [IEEE IEEE Virtual Reality Annual International Symposium - Seattle, WA, USA (18-22 Sept. 1993)] Proceedings of IEEE Virtual Reality Annual International Symposium - A note on averaging

More importantly, U, solves the minimization problem for the average square penalty

(3) min J [II(Ul - U)dI2 + I l ( U 2 - WI2]W U 1141=1

for displacement between the 171, U2, and U rotations of the unit sphere. In other words, U, minimizes (the square of) the efects of the difference between the rotations.

We also show that for 3-dimensional rotations, where rotations can be ex- pressed in terms of quaternions, we can average rotations by adding and scaling quaternions. We show that if qj is the quaternion corresponding to the rotation Uj (where j = 172), then the optimization problems (2) and (3) are solved by the rotation corresponding to the quaternion qa given by

where A = llql + q2IIandp = 1 1 ~ 1 - q a l l .

We thus have the choice of two computational procedures for averaging two rotations in three dimensions; we can either work directly with the rotation matrices, or we can work with the quaternions. The quaternion method may be preferred over the direct method on the computational grounds, particularly if the quaternions are readily available. The quaternion-based approach need be used with an utmost care, however. If we average three or more rotations, or if we seek a weighted average of two rotations, the quaternion approach can become extraordinarily complex. In general, the naive approach of simply averaging and normalizing the quaternions will not produce the desired answer. We therefore advise the exclusive use of the SVD-based approach, save in the simple two rotation case. An easy generalization of our derivation shows that if X D Y is a singular value decomposition of ,iujlJ,, then IT, = gives the minimum of

378

Page 3: [IEEE IEEE Virtual Reality Annual International Symposium - Seattle, WA, USA (18-22 Sept. 1993)] Proceedings of IEEE Virtual Reality Annual International Symposium - A note on averaging

Section 2 The SVD Approach We define the n x n rotation Ua to be the average of two other n x n rotations, U1 and U2, if and only if U, solves the optimization problem (3). Using the uniform distribution of points on unit sphere, (3) is, up to a scaling, the definition of

E”{ Il(U1 - U)# + Il(U2 - U)xlI”. (6)

The roots of the SVD approach to averaging rotations go back to the so-called Orthogonal Procrustes Problem of Green [2] and Shonemann [3]. Let I I - I I F denote the Frobenius matrix norm, that is, l[All$ = trace(AAT).

Lemma 2.1 (Green and Schonemann) Given two 17 x A: matrices A and B, the problem

mill [ [ A - U B I I p (7) I 1

is solved when U = S E I , where

x DY

is an SVD of ABT.

Proof of this result can be found, for instance, in Golub and Van Loan [ 11.

We now state and prove the main result.

Theorem 2.2 The average of the rotations IJ1 and IT, is the rotation U , = X Y , where X D Y is a SVD of rJ l + IJ,. Proof: Clearly, U,, solves (7) iff it also solves

We note that IIA-UBII?, = IIAlI?,+ IlBll; -2(A,UB) , where (A,UB) denotes the inner product of matrices, that is, trace(ABTUT). Ignoring the constant terms and rearranging the inner product in obvious ways, we see that (7) is also equivalent to

379

-

Page 4: [IEEE IEEE Virtual Reality Annual International Symposium - Seattle, WA, USA (18-22 Sept. 1993)] Proceedings of IEEE Virtual Reality Annual International Symposium - A note on averaging

Let us now consider the effects of the rotations U1 and U2 on any set of n orthonormal vectors vi. These can be arranged into an orthogonal matrix V, and we can verify by a direct computation that

n

Il(UlV, u 2 ~ ) - (UV, U~T) I I$ = I l ( U 1 - U)tJjl12 + I I ( U ~ - ~ ) v j l l ~ . (9) j=1

Since uniform sampling of orthogonal matrices V produces n sets of points {vj}, each uniformly sampled from the unit sphere, (9) implies that

The upshot of (10) is that it suffices to minimize El/ { I I (U1 V, U 2 V ) - U( V, V ) I 1 2 } to find U,.

By setting A = (U1 V, U 2 V ) and B = (V, V ) we see that, in this special case, (8) becomes

ma.x (U1 + U?, U ) , (11) U

since the term VVT = I can be dropped. By the Orthogonal Procrustes Problem, the maximum of (11 ) is achieved when U, = XI'. But note that (11) is independent of V ! The expected value

is thus minimized by the rotation [J,. QED

Section 3 The Quaternion Approach The set of quaternions of unit length is just the 3-sphere in R4,

Using quaternion multiplication, S3 becomes a Lie group and there is a two-fold covering projection

Page 5: [IEEE IEEE Virtual Reality Annual International Symposium - Seattle, WA, USA (18-22 Sept. 1993)] Proceedings of IEEE Virtual Reality Annual International Symposium - A note on averaging

given by

for all v E R3, where

'11 = [ ;] ,

T projects onto the last three components of a quaternion, and ij = (a, -p) is the conjugate of the quaternion q = ( a , p ) . (Note that the conjugate is the multiplicative inverse for q S3 .)

Before proving the next theorem, we consider two lemmas from linear algebra which will be useful in the proof of the theorem. For any matrix A, let SA denote the sum of the singular values of A .

Lemma 3.1 Let A be an n x 11. matrix. Then

with equality if and only if A is symmetric and (positive or negative) semi-definite. Proof: Construct an SVD for A

A = U D V T ,

where, as usual, I/ and V are orthogonal and D = diag(a1,. . . ,a,) with the diagonal entries non-negative and in non-increasing order. Suppose ai > 0 for 1 5 i 5 T and = 0 for i > 1'. If u 1 , . . . , U,, and 111.. . . ,on are the column vectors of U and 11' respectively, then

r

A = atu,~>T. /= l

Then we have r I

trace(^) = C a,trace(u,u,T) = a,u:ot. i=1

Therfore we have 1=1

r

i= 1 i = l

38 1

Page 6: [IEEE IEEE Virtual Reality Annual International Symposium - Seattle, WA, USA (18-22 Sept. 1993)] Proceedings of IEEE Virtual Reality Annual International Symposium - A note on averaging

which proves the asserted inequality. We note from these calculations that trace(A) = SA exactly when UTU; = 1 1 U ; 1 1 1 1 2); 1 1 for i = 1,. . . , r. But this latter condition holds iff U ; and v; are in the same direction for i = 1,. . . , r and since these are unit vectors (the matrices are orthogonal) we see 21; = vj for i = 1,. . . , r . Therefore, we actually have

T

A = aitl;tLT,

i=l

so that A is a symmetric, positive semi-definite matrix. A similar argument shows that trace(A) = -SA iff ui = -27; for i = 1, . . . , r , in which case

r T :I = - c T t l l f l l , ,

1 = 1

so that A is symmetric, negative semi-definite. QED

Lemma 3.2 Let A be an 1 1 x 11 matrix. Then there is an orthogonal matrix Q such that the matrix AQ is symmetric, positive semi-definite. For such a Q , if lr is any orthogonal matrix, then

trace( A I - ) 5 trace(AQ)

with equality iff AY is symmetric, positive semi-definite. Proof: Obtain an SVD for A so that A = l l D I r T : then let Q =

.-IC) = [:D[I?’

iT. We lave

which is symmetric, positive semi-definite. For an arbitrary orthogonal matrix E’, note that A and AI’- have the same singular values since A I 7 = lJD’I,”I’ gives an SVD for AY. Thus we have

Note that equality holds iff trace( -41 - ) = SAI- which, as shown in the proof of Lemma 3.1, is true iff ‘41- is symmetric, positive semi-definite. QED

Thus, given rotations lTl, [I,, and r i , , the condition that l1, maximize (2) is equivalent to the condition that the matrix ( ( T I + l1i)lr? is symmetric, positive semi-definite. We now prove

382

Page 7: [IEEE IEEE Virtual Reality Annual International Symposium - Seattle, WA, USA (18-22 Sept. 1993)] Proceedings of IEEE Virtual Reality Annual International Symposium - A note on averaging

Theorem 3.3 Let q1 # -q2 be unit quaternions with corresponding rotations U1 and U2. Then the unit quaternion

corresponds to a rotation U , maximizing (2 ) if and only if

Proof: Let q be any unit quaternion, with corresponding rotation U. The mapping p defined above, is a group homomorphism, so the rotations corresponding to qlq , qaq, and qoq are, respectively, lrlU, &U, and UclU. But

( U l U + U2U)(UaU)T = ( U 1 + U2)UF,

SO qa corresponds to the average of U1 and U, if and only if qa,q corresponds to the average of U1U and U2U. If we choose q = (I] we see it is sufficient to prove the theorem in the case ql = 1 and Ul = I. This simplifies the calculations below. Thus we have p(q2) = lT2 and p(qa) = [ fa , , where

and we will show:

(i) The matrix A = (I + &)U? is symmetric; (ii) A is positive semi-definite if and only if (1, (12) 2 0.

To show (i) let 'U c R3 and let U = (0, v ) ~ be the corresponding quaternion. Then

AV = + U2UTv

= r ( Q a t 1 q a + ~3C1,11(1aQ2)

1 (13) = -N A 2

= y ( ( 1 + @ 2 ) u ( l + y') + ( q 2 + 1 ) 4 @ 2 + 1))

+ @2)'1(1 + q 2 ) + q 2 ( l + q ? ) 1 1 ( 1 + q"q2) 1

while (14) T 1 A v = ,r((l + qz) l i (1 + @ 2 ) + (Qz + 1 ) ~ ( 4 2 + 1)). x-

383

Page 8: [IEEE IEEE Virtual Reality Annual International Symposium - Seattle, WA, USA (18-22 Sept. 1993)] Proceedings of IEEE Virtual Reality Annual International Symposium - A note on averaging

so that symmetry holds. To prove (ii) let q:! = (a, P ) ~ and compute (AV, v) for an arbitrary v e R3.

Here we ignore the positive factor X - l which appears in the above equations. Thus, using notation as above, we show that

(15) if and only if

a = ( 1 , ~ ) 2 0. After some quaternion algebra (and using the assumption that q:! is a unit quater- nion so that CY’ + lp1’ = l), the inequality (15) becomes

(16) This holds for all v t R3 if and only if + a? 2 0 and (since a) + (pI3 = 1) -1 5 a 5 1. These conditions hold iff 0 5 a 5 1 or a = -1. But if c1 = -1 then p = 0 so that q 2 = -1, contrary to our assumption that ql # - q 2 . Thus we conclude that (15) holds iff 0 5 CI 5 1, as asserted. QED

( ~ ( ( 1 + q 2 ) u ( l + q l ) + ( (12 + l ) u ( q ? + l ) ) , v ) 2 0, for all 17 E R3

( p . v)? + (a + 2 ) v . v 2 0.

Section 4 Conclusions and Future Work We have given a definition of the average of two rotations and shown how the singular value decomposition can be used to compute it. Since quaternions are often used to handle rotation problems in 3-space, we show that the average of two rotations corresponds to the (normalized) arithmetic mean of the unit quaternions associated to the two rotations, provided that the inner product of the quaternions is non-negative. The last condition is required because of the fact that the quaternion associated to a given rotation is determined only up to sign. Thus, if we have two quaternions representing two rotations and if the inner product of the quaternions is negative, we must reverse the sign on one of them before averaging.

Other matters remain to be settled: computing averages of more than two rotations and computing various weighted averages may be important for applica- tions. Computing a weighted average of two rotations can be done using the SVD technique, as well as via quaternions. The two methods do not agree, however, and we would like to better understand the differences. Computing averages of more than two rotations can be done via the SVD method. The conditions for obtaining the corresponding averages in terms of quaternions may be more com- plicated-should we try to make all dot products of pairs of the quaternions be positive? (This is not always possible.)

384

-~

Page 9: [IEEE IEEE Virtual Reality Annual International Symposium - Seattle, WA, USA (18-22 Sept. 1993)] Proceedings of IEEE Virtual Reality Annual International Symposium - A note on averaging

Bibliography

[l] G. H. Golub and C. F. Van Loan. Matrix Computations. Johns Hopkins

[2] B. Green. The orthogonal approximation of an oblique structure in factor

[3] P. Schonemann. A generalized solution of the orthogonal procrustes problem.

University Press, 1983.

analysis. Psychometrika 17, 1952.

Psychometrika 31, 1966.

385