arxiv: v1 [cs.ro] 17 Jun 2015

Similar documents
Lesson 3: Linear differential equations of the first order Solve each of the following differential equations by two methods.

2. Second-order Linear Ordinary Differential Equations

Course MA2C02, Hilary Term 2010 Section 4: Vectors and Quaternions

PURE MATHEMATICS AM 27

Course 2BA1: Hilary Term 2007 Section 8: Quaternions and Rotations

NOTES ON LINEAR ALGEBRA CLASS HANDOUT

Linear Algebra. Paul Yiu. 6D: 2-planes in R 4. Department of Mathematics Florida Atlantic University. Fall 2011

Strongly chordal and chordal bipartite graphs are sandwich monotone

Vectors. September 2, 2015

Special Lecture - The Octionions

SECTION v 2 x + v 2 y, (5.1)

Partial Fraction Decomposition Honors Precalculus Mr. Velazquez Rm. 254

LOWELL. MICHIGAN, OCTOBER morning for Owen J. Howard, M last Friday in Blodpett hospital.

(1) Recap of Differential Calculus and Integral Calculus (2) Preview of Calculus in three dimensional space (3) Tools for Calculus 3

Functions and their Graphs

Chapter y. 8. n cd (x y) 14. (2a b) 15. (a) 3(x 2y) = 3x 3(2y) = 3x 6y. 16. (a)

Chapter 3. Reading assignment: In this chapter we will cover Sections dx 1 + a 0(x)y(x) = g(x). (1)

6 Second Order Linear Differential Equations

LOWELL. MICHIGAN. JULY Out For Circus Acts For Lowell Showboat. Charles T. Foo of St. Johns was was T r u m a n P r a t t of Saranac who

Precalculus. Precalculus Higher Mathematics Courses 85

Chapter 2: Linear Independence and Bases

Introduction to Algebraic Geometry. Franz Lemmermeyer

Supplementary Material for MTH 299 Online Edition

Introduction to Linear Algebra, Second Edition, Serge Lange

LOWELL JOURNAL. MUST APOLOGIZE. such communication with the shore as Is m i Boimhle, noewwary and proper for the comfort

The Theory of Second Order Linear Differential Equations 1 Michael C. Sullivan Math Department Southern Illinois University

Introduction to Algebraic and Geometric Topology Week 14

MA Spring 2013 Lecture Topics

PURE MATHEMATICS AM 27

Math 53 Homework 7 Solutions

Department of Mathematics, K.T.H.M. College, Nashik F.Y.B.Sc. Calculus Practical (Academic Year )

BBM402-Lecture 20: LP Duality

Numerical Linear Algebra Chap. 2: Least Squares Problems

Maxima and Minima. (a, b) of R if

2. A die is rolled 3 times, the probability of getting a number larger than the previous number each time is

Techniques of Integration

Linear Algebra 1 Exam 2 Solutions 7/14/3

Linear Algebra (part 1) : Vector Spaces (by Evan Dummit, 2017, v. 1.07) 1.1 The Formal Denition of a Vector Space

7.5 Partial Fractions and Integration

LINEAR SYSTEMS AND MATRICES

Lesson 7.1 Polynomial Degree and Finite Differences

Tennessee s State Mathematics Standards Precalculus

Review session Midterm 1

swapneel/207

Section 1.8/1.9. Linear Transformations

Complex Numbers: Definition: A complex number is a number of the form: z = a + bi where a, b are real numbers and i is a symbol with the property: i

Linear Algebra Homework and Study Guide

2.3 Linear Equations 69

Chapter 6: Rational Expr., Eq., and Functions Lecture notes Math 1010

Linear Algebra. Min Yan

Linear Algebra I. Ronald van Luijk, 2015

Math 20B Supplement. Bill Helton. September 23, 2004

12.5 Equations of Lines and Planes

2326 Problem Sheet 1. Solutions 1. First Order Differential Equations. Question 1: Solve the following, given an explicit solution if possible:

CMU CS 462/662 (INTRO TO COMPUTER GRAPHICS) HOMEWORK 0.0 MATH REVIEW/PREVIEW LINEAR ALGEBRA

Group, Rings, and Fields Rahul Pandharipande. I. Sets Let S be a set. The Cartesian product S S is the set of ordered pairs of elements of S,

Formulas to remember

Clifford Analysis, Homework 1

Complex Numbers. Introduction

Fairfield Public Schools

A Learning Progression for Complex Numbers

APPENDIX : PARTIAL FRACTIONS

7.1 Tangent Planes; Differentials of Maps Between

Math 350 Fall 2011 Notes about inner product spaces. In this notes we state and prove some important properties of inner product spaces.

MATH 167: APPLIED LINEAR ALGEBRA Least-Squares

Linear Algebra- Final Exam Review

Mathematics Standards for High School Precalculus

LINEAR ALGEBRA W W L CHEN

CONTENTS COLLEGE ALGEBRA: DR.YOU

Let X and Y denote two random variables. The joint distribution of these random

THE DEGREE DISTRIBUTION OF RANDOM PLANAR GRAPHS

August 23, 2017 Let us measure everything that is measurable, and make measurable everything that is not yet so. Galileo Galilei. 1.

PARTIAL FRACTION DECOMPOSITION. Mr. Velazquez Honors Precalculus

Partial Fractions. Calculus 2 Lia Vas

SNAP Centre Workshop. Exponents and Radicals

Linear Models Review

SYMBOL NAME DESCRIPTION EXAMPLES. called positive integers) negatives, and 0. represented as a b, where

MATHEMATICS. Higher 2 (Syllabus 9740)

Position and orientation of rigid bodies

w T 1 w T 2. w T n 0 if i j 1 if i = j

8.3 Partial Fraction Decomposition

Ridig Body Motion Homogeneous Transformations

Linear Algebra Primer

Handbook of Ordinary Differential Equations

REAL WORLD SCENARIOS: PART IV {mostly for those wanting 114 or higher} 1. If 4x + y = 110 where 10 < x < 20, what is the least possible value of y?

Demystification of the Geometric Fourier Transforms

MATH Topics in Applied Mathematics Lecture 2-6: Isomorphism. Linear independence (revisited).

Class notes: Approximation

Newtonian Mechanics. Chapter Classical space-time

MATH 221: SOLUTIONS TO SELECTED HOMEWORK PROBLEMS

Worksheet # 2: Higher Order Linear ODEs (SOLUTIONS)

Linear Algebra. 1.1 Introduction to vectors 1.2 Lengths and dot products. January 28th, 2013 Math 301. Monday, January 28, 13

Linear algebra for computational statistics

APPENDIX A. Background Mathematics. A.1 Linear Algebra. Vector algebra. Let x denote the n-dimensional column vector with components x 1 x 2.

COMPOSITE PLATE THEORIES

Math Linear Algebra

SPECTRAL THEORY EVAN JENKINS

av 1 x 2 + 4y 2 + xy + 4z 2 = 16.

Assignment 11 Assigned Mon Sept 27

كلية العلوم قسم الرياضيات المعادالت التفاضلية العادية

Transcription:

SWING-TWIST DECOMPOSITION IN CLIFFORD ALGEBRA PRZEMYS LAW DOBROWOLSKI arxiv:1506.05481v1 [cs.ro] 17 Jun 015 Abstract. The swing-twist decomposition is a standard routine in motion planning for humanoid limbs. In this paper the decomposition formulas are derived and discussed in terms of Clifford algebra. With the decomposition one can express an arbitrary spinor as a product of a twist-free spinor and a swingfree spinor (or vice-versa) in 3-dimensional Euclidean space. It is shown that in the derived decomposition formula the twist factor is a generalized projection of a spinor onto a vector in Clifford algebra. As a practical application of the introduced theory an optimized decomposition algorithm is proposed. It favourably compares to existing swing-twist decomposition implementations. 1. Introduction Swing-twist decomposition of rotations is commonly used in context of humanoid motion planning. Consider movement of an arm reaching some predefined position. In order to displace it properly, a controller calculates twist factor of the corresponding rotation. Having this factor computed, a controller is then able to apply some corrections to the motion so that the arm is not unnaturally twisted during the motion. Swing-twist decomposition is an inherent part of a correction algorithm. It allows one to decompose an arbitrary rotation into a swing part (tilt of a given axis) and a twist part (rotation around a given axis). In this paper the decomposition is derived and discussed in terms of Clifford algebra. Swing-twist decomposition has already been considered for a few decades. Different authors have obtained equivalent formulas, in particular for quaternion algebra. Current literature tends to neglect a deeper consideration on the spin-twist decomposition. There is wide range of publications on humanoid motion planning. Most of these works relate to swing-twist decomposition in some way. In the paper, the most revelant approaches to swing-twist decomposition are quoted and compared. Starting from the recent PhD dissertation by Huyghe ([1], 011), the swing-twist decomposition is introduced in quaterion algebra by a proposed therein projection operator. Unfortunately, the origin of the projection operator is not enough explained. In two previous papers, Baerlocher ([], 001) and Baerlocher, Boulic ([3], 000) investigate joint boundaries for ball-and-socket joints using swing-twist decomposition. Grassia ([4], 1998) discusses features of a swing-twist decomposition in terms of an exponential map. However, the author does not present any related formula for the decomposition. A classic work by Korein ([5], 1984) contains most of the initial results on body positioning and joint motion. Among others the work uses swing-twist decomposition of rotations to constrain movement of an elbow. None of these are generalized to Clifford or geometric algebras which has deeper consequences than previous results. In this paper the swing-twist decomposition 1

PRZEMYS LAW DOBROWOLSKI is derived as an inverse of a formula expressing the set of rotations which move a given initial vector to cover a given terminal one.. Existing and related solutions Swing-twist decomposition splits a given rotation in two parts: a swing part and a twist part. A schematic view of a limb rotating with a ball joint is presented in figure 1. Figure 1. A limb with a ball joint By zero twist reference vector one refers to a base vector with respect to which the swing-twist decomposition is performed. Usually, this is the bone of a rotating limb. There are several existing approaches. These solutions differ in terms of performance, complexity and result exactness..1. Direct method. For quaternions one can make the following argument. Let q H be a quaternion and v be a zero-twist reference vector. In case of twist-afterswing type of decomposition (see section 6) the initial vector becomes the given v vector and the terminal vector is w = qvq. Schematic view is presented in figure. Figure. A direct decomposition of a quaternion Swing quaternion can be calculated with an axis angle representation of the quaternion. Here, the axis is a normalized vector perpendicular to v and w and the angle is equal to the angle between v and w so: n = v w v w cos(α) = v w q s = cos(α/) + sin(α/)(n x i + n y j + n z k)

SWING-TWIST DECOMPOSITION IN CLIFFORD ALGEBRA 3 Twist quaternion is calculated by the following inversion formula: q = q t q s = q t = qq 1 s q t = q(cos(α/) sin(α/)(n x i + n y j + n z k)) In this formulation both trigonometric and inverse trigonometric functions are used. It is a practical disadvantage since it requires computationally expensive functions which can also face some accuracy issues... Huyghe s method. Huyghe uses swing-after-twist decomposition type. First a simplified formula is derived which is a decomposition of an arbitrary quaternion q into a product q = q s q t with respect to a constant Z-axis aligned zero-twist reference vector (called there a twist axis ). With the following coordinates q = w + xi + yj + zk q t = w t + z t k q s = w s + x s i + y s j the author shows using some algebraic transformations that the decomposition is ±w w t = w + z z t = ±z w + z w s = w t w + z t z x s = w t x z t y y s = w t y + z t x It must be noted that some of the results were not rigorously stated. It particular, scenarios when some coefficients are equal to zero are not discussed separately which leads to possible division by zero. In the second part of the thesis, Huyghe derives a generalized formula for swingtwist decomposition. Assume that axis-angle representation of quaternions is Multiplying both quaternions one writes q s = [w s, v s ] = [cos( σ ), u s sin( σ )] q t = [w t, v t ] = [cos( τ ), u t sin( τ )] (1) q = q s q t = [w s w t v t v s, w s v t + w t v s + v s v t ] Huyghe notes that the axes v s and v t are perpendicular so formula (1) simplifies to () q = [w s w t, w s v t + w t v s + v s v t ] Next, the author introduces a new quaternion q p (no origin is provided) which is a projected version of the initial quaternion q onto the twist axis ([1]) q p = [w, (v u t )u t ] = [w s w t, (w s v t u t + w t v s u t + (v s v t ) u t )u t ] = [w s w t, w s u t sin( τ )u t]

4 PRZEMYS LAW DOBROWOLSKI = [w s w t, w s v t ] Normalization of quaternion q p gives q p q p = [w s w t, w s v t ] w s w t + w s v t = w s [w t, v t ] w s w t + v t = q t which in result turns out to be twist quaternion. Note that in the above equation Huyghe does not consider w s = 0 which is a drawback. Remaining swing quaternion is calculated from q s = qq t which completes the decomposition. 3. Preliminaries The presented results relate to Cl 3 := Cl 3,0 (R) - Clifford algebra of 3-dimensional real space. Herein, a spinor is given by s = a + be 1 + ce 3 + de 31 Spin(3) and a vector is given by v = xe 0 + ye 1 + ze. A rotation of a vector is given by Clifford multiplication: v = svs 1 for an arbitrary vector v and a spinor s. In this paper 1 denotes the inverse of a spinor. In case of Spin(3) it is equivalent to conjugation: s 1 = s = a be 1 ce 3 de 31 A spinor can be written as a sum of its scalar and bivector parts: s = [s] 0 + [s] where [s] 0 0 R3 and [s] R3. In several places the Hodge star operator is used. In an orthonormal basis it is defined as (e 1 e e k ) = e k+1 e k+ e n but in this paper it is used only in relation to the bivector part of a spinor. In this case the formula can be simplified to: [s] = e 13 [s] 1 A convenient notation is used for normalized vectors. For a given non-zero vector v 0, the normalization function is defined as: n(v) = v v where v = v v = vv is the length of vector v. Note that it is impossible to define a normalized zero vector. Let s be a spinor and v be a vector in Cl 3. The rotation svs 1 of the vector v by the spinor s gives a rotated vector v = x e 0 + y e 1 + z e which is equal to: x = (a b + c d )x + y(ab + cd) + z(bc ad) (3) y = (a b c + d )y + x(cd ab) + z(bd + ac) z = (a + b c d )z + x(bc + ad) + y(bd ac) This paper if organized as follows: first we obtain the complete set of spinors which do not rotate a given non-zero vector. Next we derive a spinor which rotates R 3

SWING-TWIST DECOMPOSITION IN CLIFFORD ALGEBRA 5 a given initial vector to cover a given terminal vector. By combining these two formulas we derive a formula which represents an arbitrary rotation by initial and terminal vectors (swing factor) together with axis rotation (twist factor). Finally swing-twist representation is inversed for an arbitrary rotation and a unique swingtwist decomposition of a spinor is obtained. In conclusion some applications of the proposed decomposition are presented. 4. The set of spinors which do not rotate a given vector In this section we assume that v is a non-zero vector. The set of all spinors s Spin(3) which do not rotate the given vector v will be called an invariant set of spinors for a given vector. The following theorem will be proved: Proposition 1 (The set of spinors which do not rotate a given vector). Let v be a non-zero vector in Cl 3. The complete set of spinors s such that svs 1 = v is determined by: s = exp(e 13 α n(v)) for all α [0; π). For a given element a Cl 3 exponential of a is defined as: exp(a) := Proof. The proof will use the coordinate expansion of spinor rotation formula and the normalization identity giving the following set of equations: (a b + c d 1)x + y(ab + cd) + z(bc ad) = 0 (a b c + d 1)y + x(cd ab) + z(bd + ac) = 0 (4) (a + b c d 1)z + x(bc + ad) + y(bd ac) = 0 a + b + c + d 1 = 0 The key idea is to extract simple relations from 4 yet avoiding high order equations. Denote Q i as the left side of ith equation of 4. A valid solution (a, b, c, d) must satisfy the following equation: k=0 (5) xq 1 + yq + zq 3 (x + y + z )Q 4 = 0 formula (5) can be expanded: a k k! (a b + c d 1)x + xy(ab + cd) + xz(bc ad) + (a b c + d 1)y + xy(cd ab) + yz(bd + ac) + (a + b c d 1)z + xz(bc + ad) + yz(bd ac) (x + y + z )(a + b + c + d 1) = 0 (a b + c d b c d + 1)x + xycd + xzbc + (a b c + d b c d + 1)y + xycd + yzbd + (a + b c d b c d + 1)z + xzbc + yzbd = 0 (b + d )x + (b + c )y + (c + d )z xycd xzbc yzbd = 0 (bx cz) + (dx cy) + (by dz) = 0 which implies that the three identities must hold: (6) bx = cz, dx = cy, by = dz

6 PRZEMYS LAW DOBROWOLSKI Next, identities (6) are plugged into the first equation of 4 and simplified using the identity a + b + c + d = 1: When x 0 there is (a + c 1)x + yab + ycd + zbc zad = 0 (a + c 1)x + zad + ycd + zbc zad = 0 (a + c 1)x + ycd + zbc = 0 (a + c 1)x + ycd + zbc = 0 (a + c 1)x + yc cy x + z cz x c = 0 (7) (a + c 1)x + y c + z c = 0 c (x + y + z ) = x ( ) c = σx x + y + z for σ { 1, 1}. In the other case, when x = 0 is is easy to observe from (6) that cy = 0, cz = 0 plugging the above to (4): yab zad = 0 (a b c + d 1)y + zbd = 0 (8) (a + b c d 1)z + ybd = 0 a + b + c + d 1 = 0 replace in the second and the third equation of (8) with by = dz: { (a b c + d 1)y + b y = 0 (9) (10) (a + b c d 1)z + d z = 0 { (a + b c + d 1)y = 0 (a + b c + d 1)z = 0 it is impossible that both y = 0 and z = 0 since in this case x = 0 and v 0 by assumption. Hence, from any of the above equations there must be: a + b c + d 1 = 0 subtracting from both sides of this equation the fourth equation of (8) one gets immediately: (11) (1) (a + b c + d 1) (a + b + c + d 1) = c = 0 = c = 0 which is also covered by the general solution (7) thus it can be assumed that (7) is the only solution. Remaining spinor components are derived as follows. When x 0 one writes using identities (6): (13) b = z x σx x + y + z = σz x + y + z

SWING-TWIST DECOMPOSITION IN CLIFFORD ALGEBRA 7 (14) d = y x σx x + y + z = σy x + y + z in the case when x = 0 from (11) there is c = 0. To calculate b and d one rewrites (8): yab zad = 0 (a b + d 1)y + zbd = 0 (15) (a + b d 1)z + ybd = 0 a + b + d 1 = 0 Consider the case y 0 then from (6) there is b = z y d. Plugging this identity into the fourth equation of (15) one obtains: and from b = z y d there is: a 1 + ( z y + 1)d = 0 (a 1)y + (x + y + z )d = 0 d = σy x + y + z b = z y σy x + y + z = σz x + y + z In the case when y = 0 there must be z 0 since v 0. Thus, from (6) there is d = y z b. Plugging this identity into the fourth equation of (15) one obtains: and from b = z y d there is: a 1 + ( y z + 1)b = 0 (a 1)z + (x + y + z )b = 0 b = σz x + y + z d = y z σz x + y + z = σy x + y + z In all cases a general solution to (4) in coordinates is: (16) (17) a [ 1; 1], σ { 1, 1} b = σz x + y + z, c = σx x + y + z, d = σy x + y + z There are two parametrized solutions to the set of equations (4): s =a + σz x + y + z e 1+ σx x + y + z e 3 + σy x + y + z e 31

8 PRZEMYS LAW DOBROWOLSKI s =a + σ x + y + z (ze 1 + xe 3 + ye 31 ) s =a + σ x + y + z e 13(ze 3 + xe 1 + ye ) s =a + σ e 13 v v s =a + σe 13 n(v) Finally, since many of the operations were reductions, all solutions are plugged into the original set of equations to check their validity. It can be seen that: svs 1 = (a + σe 13 n(v))v(a + σe 13 n(v)) 1 = (a + σe 13 n(v))v(a σe 13 n(v)) = (av + σe 13 n(v)v)(a σe 13 n(v)) = (av + σe 13 v )(a σe 13 n(v)) = ava + av( σe 13 n(v)) + (σe 13 v )a+ (σe 13 v )( σe 13 n(v)) = ava + av( σe 13 n(v)) + av(σe 13 n(v))+ σ( σ)e 13 e 13 v n(v) = ava + ( )v = a v + v a v = v which confirms that all the solutions are valid. Now we obtain the following formula: s = a + σe 13 n(v) for a [ 1; 1]. Now it is further simplified by using trigonometric and exponential series converging for all arguments. We substitute a = cos(α) to obtain: a + σe 13 n(v) = cos(α) + sin(α)e 13 n(v) where α [0; π). Then, we express the trigonometry using exponential function. We use series expansions which are valid for all α. Note that ( 1) k = (e 13 e 13 ) k = (e 13 ) k and (n(v)) k = 1. cos(α) + sin(α)e 13 n(v) = = = k=0 k=0 (e 13 ) k (k)! (e 13 ) k (k)! k=0 α k (n(v)) k + e 13 n(v) α k (n(v)) k + (e 13 α n(v)) k = + (k)! k=0 k=0 ( 1) k (k)! αk + e 13 n(v) k=0 k=0 k=0 ( 1) k (k + 1)! αk+1 (e 13 ) k (k + 1)! αk+1 (n(v)) k (e 13 ) k+1 (k + 1)! αk+1 (n(v)) k+1 (e 13 α n(v)) k+1 (k + 1)!

SWING-TWIST DECOMPOSITION IN CLIFFORD ALGEBRA 9 (e 13 α n(v)) k = = exp(e 13 α n(v)) k! k=0 which is precisely the stated general formula. This completes the proof. 5. A spinor which rotates a given vector The following lemma states what is a spinor which rotates a given vector to be equal to a target one. In literature it is sometimes called direct rotation, as in [3]. Schematic view is presented in figure 3. The lemma is required to prove a Figure 3. A direct rotation of AB to AB general theorem about the set of spinors which rotate a given initial vector to a given target vector. We start with the following initial lemma which applies to the Clifford algebra of R. At first the following basic property of Cl is proved: Lemma 1. The external product of two given vectors v and w in Cl can be written as: w v = 1 sgn(v we 1) v w v + w e 1 Proof. Assume that v = xe 1 +ye and w = pe 1 +qe. In special case when w = ±v both sides of the equation are equal to zero therefore the equation holds. In general case w ±v and one can rewrite both sides in coordinates. Left-hand side is equal to: w v = 1 (wv vw) = 1 ((pe 1 + qe )(xe 1 + ye ) (xe 1 + ye )(pe 1 + qe )) = 1 (pye 1 qxe 1 ) = (py qx)e 1 Right-hand side is equal to: 1 sgn(v we 1) v w v + w e 1 = 1 sgn(1 (vw wv)e 1) (v w) (v + w) e 1 = 1 sgn(((xe 1 + ye )(pe 1 + qe ) (pe 1 + qe )(xe 1 + ye ))e 1 ) (v w) (v + w) e 1 = 1 sgn((qxe 1 pye 1 )e 1 ) ((x p) + (y q) )((x + p) + (y + q) )e 1 = 1 sgn(py qx) 4(py qx) e 1 = sgn(py qx) py qx e 1 = (py qx)e 1 Both sides are equal so it completes the proof.

10 PRZEMYS LAW DOBROWOLSKI Lemma. Let v and w be a pair of non-zero vectors of equal length in Cl such that v w. Then there exist a pair of spinors ±s Spin() which rotate v so that the rotated vector is equal to w: then the pair of spinors is equal to: svs 1 = w s = ± n(v + w) n(v) Proof. Let s = a + be 1 Spin() be a spinor and v = xe 1 + ye, w = pe 1 + qe be a pair of given vectors. The equation can be expressed in coordinates with the following set of equations: { (a b )x + aby = p (18) (a b )y abx = q From the assumption it is impossible that both x and y are simultaneously zero. When x 0 we solve the set of equations: The second equation is then simplified: a b = p aby x p aby y abx = q x (p aby)y abx qx = 0 py qx ab = x + y Which is then plugged into the first equation of (18): (a b )x + py qx x + y y = p (a 1)x = p py qxy x + y a = px + py py + qxy x(x + y + 1 = ) x a = ± + y + px + qy x + y px + qy x + y + 1 The same result can be obtained when we consider the other case y 0: a b = q + abx y q + abx x + aby = p y The second equation can be simplified: (q + abx)x + aby py = 0 py qx ab = x + y

SWING-TWIST DECOMPOSITION IN CLIFFORD ALGEBRA 11 Which is then plugged into the second equation of (18): (a b )y (a 1)y = q + py qx x + y x = q pxy qx x + y a = qx + qy + pxy qx y(x + y + 1 = ) x a = ± + y + px + qy (x + y ) px + qy x + y + 1 We obtained one general solution which is correct for all x, y. Now, for each x +y +px+qy σ { 1, 1} of a = σ (x +y ) we have exactly one corresponding solution b. It can be calculated by plugging it into ab = py qx (x +y ) valid for all x, y. When a 0 then: b = py qx a(x + y ) (py qx) (x b = + y ) σ x + y + px + qy(x + y ) py qx b = σ x + y + px + qy (x + y ) (py qx) x b = σ + y px qy (x + y ) (px + qy) (x + y ) (py qx) x b = σ + y px qy (x + y ) (px + qy) (x + y ) (py qx) x b = σ + y px qy x4 + y 4 + x y p x q y pqxy (x + y ) (py qx) x b = σ + y px qy x4 + y 4 + x y (x + y q )x (x + y p )y pqxy 1 (x + y ) py qx b = σ (py qx) x + y px qy (x + y ) note that (py qx)e 1 = w v but it is assumed that v is not parallel to w therefore py qx 0. Since e 1 = 1 the following applies: py qx (py qx) = sgn(v we 1) and b is equal to: b = σ sgn(v we 1 ) x + y px qy (x + y )

1 PRZEMYS LAW DOBROWOLSKI When a = 0 then from b = we know that b = ±1 which is also a special case of the general solution. Finally, we simplify the formula to a coordinate-free solution. For each σ { 1, 1} there is a solution: x s = σ + y + px + qy (x + y + σ sgn(v we 1 ) ) σ s = (x + y ) ( x + y + px + qy+ sgn(v we 1 ) x + y px qye 1 ) s = σ (x + y ) ( 1 (x + y + p + q + (px + qy))+ 1 sgn(v we 1 ) (x + y + p + q (px + qy))e 1 ) σ s = x + y ( x + y + p + q + (px + qy)+ sgn(v we 1 ) x + y + p + q (px + qy)e 1 ) s = σ v ( vv + ww + vw + wv+ sgn(v we 1 ) vv + ww vw wve 1 ) s = σ v ( (v + w) + sgn(v we 1 ) (v w) e 1 ) s = σ v ( v + w + sgn(v we 1) v w e 1 ) x + y px qy (x + y e 1 ) From the assumptions, there is v + w 0 so: σ s = v v + w ( v + w + sgn(v we 1 ) v w v + w e 1 ) Next, the basic identity from lemma 1 is used so the formula can be rewritten with only external product: w v = 1 sgn(v we 1) v w v + w e 1 It reads that the external product is equal to a bivector whose area is equal to the half of the area of the parallelogram spanned by the both vectors and with the sign adjusted to the sign of the external product. Using the above identity, the following further simplifications are possible: σ s = v v + w ( v + w + v w) σ s = (vv + ww + v w + v w) v v + w σ s = (vv + wv) v v + w σ s = (v + w)v v v + w s = ± n(v + w) n(v)

SWING-TWIST DECOMPOSITION IN CLIFFORD ALGEBRA 13 Which is precisely the stated formula. We observe that the same vector formula applies to any Clifford algebra of n- dimensional real space. Thus, we propose the following: Proposition. Let v and w be a pair of non-zero vectors of equal length in Cl n such that v w. Then there exist a pair of spinors each of which rotate v so that it is equal to w: the pair of spinors is equal to: svs 1 = w s = ± n(v + w) n(v) Proof. Instead of the original equation svs 1 = w an equivalent equation will be proved: sv = ws Let v and w are the given vectors. Start with: v v = v v since vv = ww > 0 each element can be multiplied by the scalar vv or ww: vvv wwv = wvv wvv vvv + wvv = wvv + wwv (v + w)vv = w(v + w)v it is assumed that v w so v + w > 0 and both sides can be divided by v + w v : n(v + w) n(v)v = w n(v + w) n(v) To ensure that s is a spinor it is sufficient to check whether it is a direct product of a scalar and a bivector and whether its norm is equal to 1. Indeed: s = n(v + w) n(v) = vv + wv v + w v = v + wv v + w v 0 R 3 R 3 and since s 1 = n( v + w v + w v) 1 = n( v + v w + v w) = n(vv + vw) = n(v) n(v + w) the norm is: ss 1 = n(v + w) n(v) n(v) n(v + w) = n(v + w) n(v) = 1 Which completes the proof. Since the theorem is valid for Cl n it is also valid for Cl 3. In more general conclusion, for any dimension there exists a simple formula giving a pair of spinors rotating a given vector so that it covers another given vector of the same length.

14 PRZEMYS LAW DOBROWOLSKI 6. The set of spinors which rotate a given initial vector to a given target vector There are two ways of defining a swing-twist representation (composition or decomposition): twist q is done before swing p; for a given spinor r we have: s = pq. This is the swing-after-twist representation. twist q is done after swing p; for a given spinor r we have: s = qp. This is the twist-after-swing representation. The swing-after-twist representation is used in [1] while the twist-after-swing representation is usually used in the direct method. Since in practice both conventions are used (the first one is slightly less common) in this paper both decompositions will be presented and proved. The following theorem is a general solution to Clifford product equation: svs 1 = w We prove the following Proposition 3. Let v and w be a pair of non-zero vectors of equal length in Cl 3 such that v w. The set of spinor solutions s Spin(3) to svs 1 = w in the case of swing-after-twist representation is equal to: s = ± n(v + w) n(v) exp(e 13 α n(v)) and in the case of twist-after-swing representation is equal to: s = ± exp(e 13 α n(w)) n(v + w) n(v) Proof. The solution is the set of all possible rotations which swing axis from initial v to terminal w with any possible twist during the movement. Using propositions 1 and one composes swing and twist according to the order used in a given representation. In the case of swing-after-twist representation twist q = exp(e 13 α n(v)) factor (around v axis) is applied at first and only after it, swing factor p = n(v+w) n(v) is applied (swinging the axis from v to w). In the other case of twist-after-swing representation swing p = n(v + w) n(v) is applied first (swinging the axis from v to w) and after that twist factor q = exp(e 13 α n(w)) is applied with respect to the terminal axis w. 7. Swing-twist decomposition of a spinor This is the main result of this paper. In this section the inverse of formulas given in proposition 3 is derived. Given a spinor it is possible to calculate its decomposition into twist and swing factors in respect to a given non-zero vector. Since there are two different swing-twist representations, there are also two swing-twist decompositions for swing-after-twist and twist-after-swing representation respectively. In this section, the initial vector will be called a base vector. Theorem 1 (Swing-twist decomposition of a spinor in swing-after-twist representation). Assume that s Spin(3) is a spinor. For any non-zero base vector v Cl 3 such that svs 1 v there exist a unique up to the sign swing-twist decomposition in swing-after-twist representation s = ±pq

SWING-TWIST DECOMPOSITION IN CLIFFORD ALGEBRA 15 where swing spinor p and twist spinor q are equal to: p = ±s σ v (s) q = ±σ v (s) where σ v (s) : Spin(3) Spin(3) is a function of spinor s: the reversion σ v (s) is equal to: σ b (s) = n(v(v s)) σ v (s) = n(v(v s)) The function σ v (s) will be called a twist projection function. Proof. The proof is divided into several steps. At first the problem is reformulated in coordinates. Then, twist angle is calculated and twist spinor and finally swing spinor. Denote the following: s = a + be 1 + ce 3 + de 31 v = v x e 1 + v y e + v z e 3 w = w x e 1 + w y e + w z e 3 The angle α will be described implicitly by: cos(α) = k sin(α) = l k + l = 1 Vector w exists on the assumption that svs 1 v. What does this assumption require about the base vector and the spinor is explained in the appendix of this paper. At first, the equation is rewritten in coordinates. The swing factor is equal to: p = n(w + v) n(v) = ((w x + v x )e 1 + (w y + v y )e + (w z + v z )e 3 )(v x e 1 + v y e + v z e 3 ) (wx + v x ) + (w y + v y ) + (w z + v z ) v x + v y + v z = ((w x + v x ) + (w y + v y ) + (w z + v z ) ) 1 (v x + v y + v z) 1 [(w x + v x )v x + (w y + v y )v y + (w z + v z )v z + ((w x + v x )v y (w y + v y )v x )e 1 + ((w y + v y )v z (w z + v z )v y )e 3 + ((w z + v z )v x (w x + v x )v z )e 31 ] Twist factor is equal to: l (19) q = cos(α) + e 13 n(v) sin(α) = k + (b z e 1 + b x e 3 + b y e 31 ) vx + vy + vz Combining the above formulas there is: pq = ((w x + v x ) + (w y + v y ) + (w z + v z ) ) 1 (v x + v y + v z) 1 [(w x + v x )v x + (w y + v y )v y + (w z + v z )v z + ((w x + v x )v y (w y + v y )v x )e 1 + ((w y + v y )v z (w z + v z )v y )e 3 + ((w z + v z )v x (w x + v x )v z )e 31 ]

16 PRZEMYS LAW DOBROWOLSKI [k + l (b z e 1 + b x e 3 + b y e 31 )] vx + vy + vz = ((w x + v x ) + (w y + v y ) + (w z + v z ) ) 1 (v x + v y + v z) 1 [k((w x + v x )v x + (w y + v y )v y + (w z + v z )v z )+ (k(w x v y w y v x ) + l vx + vy + vz(w z + v z ))e 1 + (k(w y v z w z v y ) + l vx + vy + vz(w x + v x ))e 3 + (k(w z v x w x v z ) + l vx + vy + vz(w y + v y ))e 31 ] Two spinors are equal if and only if corresponding coefficients are equal. Therefore the following set of equations determines the solution: a = [k((w x + v x )v x + (w y + v y )v y + (w z + v z )v z )] b = [k(w x v y w y v x ) + l vx + vy + vz(w z + v z )] c = [k(w y v z w z v y ) + l vx + vy + vz(w x + v x )] (0) d = [k(w z v x w x v z ) + l vx + vy + vz(w y + v y )] k + l = 1 wx + wy + wz = vx + vy + vz a + b + c + d = 1 Where = ((w x +v x ) +(w y +v y ) +(w z +v z ) ) 1 (v x+v y +v z) 1. By substituting variables in the set of equations (0) it is easy to rise unfavourably the degree of involved polynomials. Thus the following careful operations are performed. First, note that it is easy to obtain variable k from the first equation: (1) a = Observe that: k(w + v) v w + v v w + v = (w + v)(w + v) = ww + vv + wv + vw = (v v + v w) = v (w + v) Using this, one simplifies (1) to: a = From that one obtains the value of k: k(w + v) v k w + v w + v = = k w + v v w + v v v () k = a v w + v The value of k is now put into the set of equations (0) which then can be simplified to: 1 b w + v = a w+v (w xv y w y v x ) + l(w z + v z ) 1 (3) c w + v = a w+v (w yv z w z v y ) + l(w x + v x ) 1 d w + v = a w+v (w zv x w x v z ) + l(w y + v y )

SWING-TWIST DECOMPOSITION IN CLIFFORD ALGEBRA 17 It is a set of three linear equations with three unknowns M[w x, w y, w z ] T = N. The characteristic matrix M is: 1 a w+v v 1 y a w+v v x l 1 M = l a w+v v 1 z a w+v v y 1 a w+v v 1 z l a w+v v x and the vector N is equal to: N = [b w + v lv z, c w + v lv x, d w + v lv y ] T Any known method can be used to compute the determinant of M which is equal to: det(m) = l The case l = 0 needs special care and will be now discussed separately. In this case, from (19) twist factor is equal to: q = k + l (b z e 1 + b x e 3 + b y e 31 ) = k vx + vy + vz Since q is a spinor, its component k must be equal to: k = ±1 which then implies that twist and swing factors are equal to: p = ±s q = ±1 It is a special case of the general formula. It holds for all vector v and spinors s such that α = zπ, z Z. In the case of l 0 there exist exactly one solution to (3). After having the matrix inverted and solution calculated, one gets: w x = [4a (v x + v y + v z)l + w + v l 3 ] 1 [a(bv y dv z ) w + v l+ w + v l (c w + v v x l) + 4a v x ((bv z + v x c + v y d) w + v (v x + v y + v z)l)] w y = [4a (v x + v y + v z)l + w + v l 3 ] 1 [a( bv x + cv z ) w + v l+ w + v l (d w + v v y l) + 4a v y ((bv z + v x c + v y d) w + v (v x + v y + v z)l)] w z = [4a (v x + v y + v z)l + w + v l 3 ] 1 [a(cv y + dv x ) w + v l+ w + v l (b w + v v z l) + 4a v z ((bv z + v x c + v y d) w + v (v x + v y + v z)l)] All three denominators are equal and can be simplified: 4a (v x + v y + v z)l + w + v l 3 = l(4a v + w + v ( 4 v )) = l w + v w + v

18 PRZEMYS LAW DOBROWOLSKI A compact form is achieved with the following simplifications: w x w y w z = 1 l w + v (a bv y dv z cv z bv x dv x cv y w + c w + v v x l v l + w + v l d w + v v y l b w + v v z l + v x 4a v y v z ((bv z + cv x + dv y ) w + v v l)) v x = a v y v z c c d + l w + v d b b v x l v y + 4a v x v x l w + v v y ( w + v v y c d b v l) v z v z Vector [c, d, b] T can be formulated with coefficients of spinor s: [s] = e 13 [s] = e 13 (be 1 + ce 3 + de 31 ) = ce 1 + de + be 3 With this substitution further simplification is possible: w = av [s] + l w + v [s] l v + but form previous equations there is: (4) l = 4 v so after substitution one obtains: v z 4a l w + v v( w + v v [s] v l) w + v w = av [s] + l w + v [s] v + 4a v l w + v v [s] The above formula is useful to compute w + v. Note that one can move v to the left hand side of the equation and compute lengths of both sides. w + v = (av [s] + l w + v [s] + 4a v l w + v v [s] ) = (av [s] ) + (l w + v [s] ) 4a v + ( l w + v v [s] ) 4a v + [(av [s] ) (l w + v [s] ) + (av [s] ) ( l w + v v [s] ) 4a v + (l w + v [s] ) ( l w + v v [s] )] = 4a (b [s] ) + l w + v ( [s] ) + 16a4 v l w + v (v [s] ) + 8a (v [s] ) From the property that (b [s] ) +(b [s] ) = b ( [s] ) the following formula is obtained: w+v = 4a b ( [s] ) +l w+v ( [s] ) +4a (v [s] ) + 16a4 v l w + v (v [s] )

SWING-TWIST DECOMPOSITION IN CLIFFORD ALGEBRA 19 There is: (5) l w + v = (1 4a v ) w + v w + v = w + v 4a v So one can write the following equivalent formula: w + v = 4a b ( [s] ) + ( w + v 4a v )( [s] ) + 4a (v [s] ) + 16a4 v l w + v (v [s] ) = w + v ( [s] ) + 4a (v [s] ) + 16a4 v l w + v (v [s] ) Substituting ( [s] ) = and once again (5) one obtains: ( 4a w + v = w + v ( ) + (v [s] ) ( w + v 4a v ) + 16a 4 v ) l w + v Which can be simplified to: a w + v = (v [s] ) 4a l a ( w + v 4a v ) = 4a (v [s] ) There are two cases. When a 0 the following equation applies: Using the above identity, there is: w + v = 4(v [s] ) + 4a v l w + v = w + v 4a v = 4(v [s] ) + 4a v 4a v l w + v = 4(v [s] ) Modifying the identity (4) there is: l = 4 v w + v w + v 4a v = l w + v w + v 4a v = 4(v [s] ) w + v = 4(v [s] ) + 4a v w + v = (v [s] ) + a v Using the formula () one obtains the value of k: (6) k = a v w + v = a v (v [s] ) + a v = a v (v [s] ) + a v Again from (4) it is possible to calculate l: l = 4 v w + v = 1 4a v 4[(v [s] ) + a v ] = (v [s] ) + a v (v [s] ) + a v a v (v [s] ) + a v = (v [s] ) (v [s] ) + a v It is possible to take the square root and abandon sign. This comes from the fact that when s is a given spinor then the solution represented by variable l must

0 PRZEMYS LAW DOBROWOLSKI include the solution for s as well. In that case the numerator is negated, so also l is a solution automatically. (7) l = In the case when a = 0 from (4) there is: v [s] (v [s] ) + a v l = 1 k = 1 l = 0 The same argumentation as above can be used to select any solution of l = 1. Both cases are special cases of (6) and (7) so it is sufficient to consider only those general solutions. The twist factor equal to: q = k + e 13 n(v)l = = = = a v (v [s] ) + 4a v + e 13 n(v)(v [s] ) (v [s] ) + a v a v + n(v)(v [s]) (v [s] ) + a v = a v + n(v)(v s) n(v)(v [s] 0) (v [s] ) + a v a v + n(v)(v s) a v n(v)(v s) = (v [s] ) + a v (v [s] ) + a v Define a norm of a pinor p = p 0 + p 1 e 1 + p 3 e 3 + p 31 e 31 Pin(3): n(p) := p = p 0 + p 1 e 1 + p 3 e 3 + p 31 e 31 p p p 0 + p 1 + p 3 + Spin(3) p 31 where p = p 0 p 1 e 1 p 3 e 3 p 31 e 31. Using the fact that s = a+e 13 [s] the numerator of twist factor can be written as: (8) n(v)(v s) = n(v)(v (a + e 13 [s] ) = n(v)(va + e 13 v [s] ) = a v + e 13 n(v)v [s] the norm of the numerator of twist factor is equal to: (a v + e13 n(v)v [s] )(a v e 13 n(v)v [s] ) = a v + (e 13 n(v)v [s] ) = a v + (v [s] ) one notices that it is equal to the denominator. In result, it is possible to write simply: q = n(v(v s)) The swing factor is calculated by modifying the original equation: s = pq p = sq 1 by using (8) twist inverse can be easily calculated: q 1 = q = σ v (s) = a v + e 13 n(v)v [s] = a v e 13 n(v)v [s] = a v + e 13 n(v)v [ s] = n(v)(va + e 13 v [ s] ) = n(v)(v (a + e 13 [ s] )) = n(v)(v s)

SWING-TWIST DECOMPOSITION IN CLIFFORD ALGEBRA 1 so p = s σ v (s) where σ v (s) = n(v)(v s). Both swing and twist factors can be negated as a given spinor and its negation define the same rotation: which completes the proof. p = ±s σ v (s) q = ±σ v (s) The following dual theorem can be easily proved with the previous theorem (1): Theorem (Swing-twist decomposition of a spinor in twist-after-swing representation). Assume that s Spin(3) is a spinor. For any non-zero base vector v Cl 3 such that svs 1 v there exist a unique up to the sign swing-twist decomposition in twist-after-swing representation s = ±qp where swing spinor p and twist spinor q are equal to: p = ± σ v (s)s q = ±σ v (s) where σ v (s) is a twist projection function. Proof. Assume that u = s 1. According to theorem there exists a swing-twist decomposition of spinor u in swing-after-twist representation: u = ±pq where p is a swing factor and q is a twist factor of u in respect to the base vector v. Taking inverse of both sides one obtains: u 1 = s = ±q 1 p 1 which is a twist-after-swing decomposition of spinor s. Swing and twist factors can be rewritten as: p 1 = (u σ v (u)) 1 = (s 1 σ v (s 1 )) 1 = σ v (s 1 ) 1 s = σ v (s)s q 1 = σ v (u) 1 = σ v (s 1 ) 1 = σ v (s) which completes the proof. 8. Twist projection function In this section basic properties of the twist projection function are discussed. Intuitively, twist projection function takes a spinor and returns its twist factor in respect to a given vector. In this paper the following definition was assumed σ v (s) := n(v(v s)) This is algebraically equivalent to projecting it onto a vector in the sense of Clifford algebra. This an improvement over the work of Huyghe [1] where the author introduces similar projection operator artificially in quaternion algebra. Twist projection function is a projection due to the following Proposition 4. A twist projection function is a projection.

PRZEMYS LAW DOBROWOLSKI Proof. It is enough to prove that σ v (σ v (s)) = σ v (s) for any vector v and any spinor w: σ v (σ v (s)) = n(v(v n(v(v s)))) = n(v(v a v + e 13 n(v)(v [s] ) )) (v [s] ) + a v = n(v v a v + e 13(v n(v))(v [s] ) (v [s] ) + a v ) = n(v v a v + e 13 v v [s] (v [s] ) + a v ) = n(v ( v v) (a + [s] ) (v [s] ) + a v ) = n( v n(v)(v s) (v [s] ) + a v ) = n(v(v s)) = σ v (s) which completes the proof. 9. Applications In this section an exemplary application of the proposed theoretical results is presented. It is a fast, concise and numerically stable algorithm for calculating swing-twist decomposition of a spinor. 9.1. An efficient algorithm for swing-twist decomposition of a spinor. To propose an efficient method of calculating swing-twist decomposition the following formula is used for twist projection function: σ v (s) = n(v(v s)) = n(v(v (a + e 13 [s] )) = = n(v(va + e 13 v [s] )) = n(a v + e 13 v(v [s] )) If a rotation is represented by a pinor normalization can be omitted. In case of spinor representation normalization is needed and requires square root computation or equivalently requires arithmetic with square root extension. The proposed method uses swing-after-twist representation and is presented in algorithm 1. Algorithm 1 Compute swing-twist decomposition of a spinor s = pq Require: v = xe 1 + ye + ze 3, s = a + be 1 + ce 3 + de 31 Ensure: v 0 u xc + yd + zb n x + y + z m an l m + u n q m l + zu l e 1 + xu l e 3 + yu l e 31 p s q return p, q Because of its simplicity the proposed method favourably compares to existing methods for computing swing-twist decomposition (as presented in section. Appendix A. Which decompositions are impossible When a combination of a spinor and a base vector cannot be decomposed into swing and twist. From theorem 1 or a decomposition is impossible when: svs 1 = v

SWING-TWIST DECOMPOSITION IN CLIFFORD ALGEBRA 3 the above condition can be rewritten in terms of spinor coordinates. Using (3) one writes (a b + c d + 1)x + y(ab + cd) + z(bc ad) = 0 (a b c + d + 1)y + x(cd ab) + z(bd + ac) = 0 (9) (a + b c d + 1)z + x(bc + ad) + y(bd ac) = 0 a + b + c + d 1 = 0 Denote as W i the left side of ith equation of 9. A valid solution (a, b, c, d) must satisfy the following equation: the above formula can be expanded: xw 1 + yw + zw 3 + (x + y + z )W 4 = 0 (a b + c d + 1)x + xy(ab + cd) + xz(bc ad) + (a b c + d + 1)y + xy(cd ab) + yz(bd + ac) + (a + b c d + 1)z + xz(bc + ad) + yz(bd ac) + (x + y + z )(a + b + c + d 1) = 0 (a b + c d + 1 + a + b + c + d 1)x + xycd + xzbc + (a b c + d + 1 + a + b + c + d 1)y + xycd + yzbd + (a + b c d + 1 + a + b + c + d 1)z + xzbc + yzbd = 0 (cx + dy + bz) + a (x + y + z ) = 0 which implies that the two identities must hold: but since v 0 it must be a (x + y + z ) cx + dy + bz = 0 a = 0 v [s] = 0 These conditions define when a spinor can be written as a swing-twist decomposition in respect to a given base vector. References [1] B. Huyghe, Design and Implementation of a Mobile Sensor System for Human Posture Tracking, Ph.D. thesis, Ghent University (011). [] P. Baerlocher, Inverse Kinematics Techniques for the Interactive Posture Control of Articulated Figures, Ph.D. thesis, Swiss Federal Institute of Technology (001). [3] P. Baerlocher, R. Boulic, Parametrization and Range of Motion of the Ball-and-Socket Joint, in: Proceedings of the IFIP TC5/WG5.10 DEFORM 000 Workshop and AVATARS 000 Workshop on Deformable Avatars, DEFORM 00/AVATARS 00, Kluwer, B.V., Deventer, The Netherlands, The Netherlands, 001, pp. 180 190. [4] F. S. Grassia, Practical Parameterization of Rotations Using the Exponential Map, J. Graph. Tools 3 (3) (1998) 9 48. [5] J. Korein, A Geometric Investigation of Reach, The MIT Press, 1985. Faculty of Mathematics and Information Science, Warsaw University of Technology, Poland