10 3D rotations and quaternions Steve Marschner CS5625 Spring 2019
Parameterizing rotations • Euler angles – rotate around x, then y, then z – nice and simple R ( θ x , θ y , θ z ) = R z ( θ z ) R y ( θ y ) R x ( θ x ) • Axis/angle – specify axis to rotate around, is a frame F ˆ then angle by which to rotate a matrix with a as its first column. a R x ( θ ) F − 1 R (ˆ a , θ ) = F ˆ ˆ a • Unit quaternions θ = k a k – A 4D representation (like 3D unit vectors for 2D sphere) – Good choice for interpolating rotations ˆ a
Problems • Euler angles – gimbal lock (saw this before) – some rotations have many representations • Axis/angle – multiple representations for identity rotation – even with combined rotation angle, making small changes near 180 degree rotations requires larger changes to parameters • These resemble the problems with polar coordinates on the sphere – as with choosing poles, choosing the reference orientation for an object changes how the representation works
Rodrigues’ rotation formula R ( a , θ ) x = (cos θ ) x + (sin θ )( a × x ) + (1 − cos θ )( a · x ) a a + (1 − cos θ ) aa T R ( a , θ ) = (cos θ ) I + (sin θ )˜ [Leonard McMillan]
What is a rotation? • Think of the set of possible orientations of a 3D object – you get from one orientation to another by rotating – if we agree on some starting orientation, rotations and orientations are pretty much the same thing • It is a smoothly connected three-dimensional space – how can you tell? For any orientation, I can make a small rotation around any axis (pick axis = 2D, pick angle = 1D) • This set is a subset of linear transformations called SO(3) – O for orthogonal, S for “special” (determinant +1), 3 for 3D
Calculating with rotations • Representing rotations with numbers requires a function R n → SO (3) f : I • The situation is analogous to representing directions in 3-space – there we are dealing with the set S 2 , the two-dimensional sphere (I mean the sphere is a 2D surface) – like SO(3) it is very symmetric; no directions are specially distinguished
Analogy: spherical coordinates • We can use latitude and longitude to parameterize the 2- sphere (aka. directions in 3D), but with some annoyances – the poles are special, and are represented many times – if you are at the pole, going East does nothing – near the pole you have to change longitude a lot to get anywhere – traveling along straight lines in (latitude, longitude) leads to some pretty weird paths on the globe you are standing one mile from the pole, facing towards it; to get to the point 2 miles ahead of you the map tells you to turn right and walk 3.14 miles along a latitude line… – Conclusion: use unit vectors instead
Analogy: unit vectors • When we want to represent directions we use unit vectors: points that are literally on the unit sphere in R 3 – now no points are special – every point has a unique representation – equal sized changes in coordinates are equal sized changes in direction • Down side: one too many coordinates – have to maintain normalization – but normalize() is a simple and easy operation
<latexit sha1_base64="SW2bvSypz/EWEHrDQbRBHoIB3uA=">ACQHicbVBNTxsxEJ2lI+0QCg3uFhESD2U7G4SiVyqInEBiQNIBJCSNPI6s2Biexfbi4hWSPwarvAb+Bf8g97aXjnhbGhVKCN59PxmnsfzolRwY4PgwZt4N/l+anpmtvTh49z8Qnx06FJMs2wxRKR6OIGhRcYctyK/A41UhlJPAoGmyN6kcXqA1P1IEdptiV9ETxmDNqHdUrL/PvNfKVnBV5UGR+NnB5PeyVK0E1KIL8D8JnUPn2C4rY6y16851+wjKJyjJBjWmHQWq/xALPVTen2nIm8KrUyQymlA3oCbYdVFSi6ebFKldkzTF9EifaHWVJwf6ryKk0Zigj1ympPTWvayPyrVo7s3Gzm3OVZhYVGw+KM0FsQka+kD7XyKwYOkCZ5u6vhJ1STZl17pU6hTD3W8bdfKOlv8sjTfXQt3gpY58rJrI+m6u5pfrF+4pt03hYKNWazbqZAzq4R/Q/OvgYa0a1qvBfqOyuTO2EmZgBVbhM4SwAZuwDXvQAgbXcAO3cOfdez+8n97vceuE96xZghfhPT4BbGKtjQ=</latexit> Complex numbers to quaternions • Rather than one imaginary unit i , there are three such symbols i , j , and k , with the properties i 2 = j 2 = k 2 = ijk = − 1 • Multiplication of these units acts like the cross product ij = k ji = − k jk = i kj = − i ki = j ik = − j • Combining multiples of i , j , k with a scalar gives the general form of a quaternion: R 4 } H = { a + bi + cj + dk | ( a, b, c, d ) ∈ I
Complex numbers to quaternions • Like complex numbers, quaternions have conjugates and magnitudes q = a + bi + cj + dk q = a � bi � cj � dk ¯ a 2 + b 2 + c 2 + d 2 = k ( a, b, c, d ) k 1 p 2 = | q | = ( q ¯ q ) • Also like complex numbers, quaternions have reciprocals of the form q − 1 = 1 q = ¯ q | q |
Quaternion Properties • Associative q 1 ( q 2 q 3 ) = q 1 q 2 q 3 = ( q 1 q 2 ) q 3 • Not commutative q 1 q 2 6⌘ q 2 q 1 • Magnitudes multiply | q 1 q 2 | = | q 1 | | q 2 |
Unit quaternions • The set of unit-magnitude quaternions is called the “unit quaternions” S 3 = { q ∈ H | | q | = 1 } – as a subset of 4D space, it is the unit 3-sphere – multiplying unit quaternions produces more unit quaternions | q 1 | = | q 2 | = 1 | q 1 q 2 | = 1 = ⇒ q 1 , q 2 ∈ S 3 q 1 q 2 ∈ S 3 = ⇒ • For unit quaternions: | q | = 1 q − 1 = ¯ q
<latexit sha1_base64="Wlz9P7sVd5Q+0R0ixWV4Xeso0=">ACXHicbVDBbhMxEHWlpaUtilIXLgYIqRKpdndJIJcEJW4gMShSE1bKRtFXu9sa9X2bu3ZqNGqf8LXcIUf4MI38Ak43oKgZSR73ryZ8XheWkphMYq+t4J7K6v319YftDcebm5td3YeHduiMhzGvJCFOU2ZBSk0jFGghNPSAFOphJP04t0yfzIHY0Whj3BRwlSxMy1ywRk6atZ5lczns5gu7z59Q/d9mDxLeFagc57eow2LQoH1VHvW6Ua9yBu9C+Ib0H37k3g7nO20tpKs4JUCjVwyaydxVOLXMKlntbMoOASrtJZaFk/IKdwcRBzdzEae3XvKYvHJPRvDuaKSe/bujZsrahUpdpWJ4bm/nluT/cpMK89G0FrqsEDRvBuWVpFjQpWY0EwY4yoUDjBvh/kr5OTOMo1O2nfjGOhxbF4XWqPCjSA0zixDhSuWh0FxWGYRurhFX+3P3lNvGKzjs90fDAW3AIP4NRn8UPO734kEv+jTsHnxopCTr5Cl5TnZJTF6TA/KeHJIx4eQz+UK+km+tH8FKsBFsNqVB6bnMfnHgie/AHijtfs=</latexit> <latexit sha1_base64="ZJSY/ASWNLDiOPpMi8VAmfg2u2A=">ACx3iclVHdbtMwGHXCz0aB0Y1LbiwqUCe6JmrdI0bRI3TOJiSHSbVFeV43xZTR0ns53QKuoFj7LH4i14BJx0Q/zshk+ydXzO92Mfh5ng2vj+d8d98P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OPpGv5Bv57vScsXPoHLVWp7OaeUz+KOf1D2rGw3A=</latexit> Quaternion as scalar plus vector • Write q as a pair of a scalar s ∈ R and vector v ∈ R 3 q = a + bi + cj + dk q = s + v where s = a and v = bi + cj + dk q = ( s, v ) where s = a and v = ( b, c, d ) • Multiplication: v 1 v 2 = − v 1 · v 2 + v 1 × v 2 ( s 1 + v 1 )( s 2 + v 2 ) = s 1 s 2 − v 1 · v 2 + s 1 v 2 + s 2 v 1 + v 1 × v 2 ( s 1 , v 1 )( s 2 , v 2 ) = ( s 1 s 2 − v 1 · v 2 , s 1 v 2 + s 2 v 1 + v 1 × v 2 ) | s | 2 + k v k 2 = 1 • For a unit quaternion, – so think of these as the sine and cosine of an angle ψ : q = (cos ψ , ˆ v sin ψ ) or cos ψ + ˆ v sin ψ – this is a lot like writing a 2D rotation as cos θ + i sin θ
<latexit sha1_base64="uwxD1PD8qyqb+3GaSr1CTCg7WBk=">ACLHicbVBNSysxFL2jPj/q0+fH0k2wC5sZ6Yt2J2CGwUXClYLbZFMekeDSWZekimWwT/hVn+Dv8aNiFvX/gTqT7e83khcHLOPbk3J0oFNzYInryJyakf0zOzc6X5nwuLv5aWV05NkmGLZaIRLcjalBwhS3LrcB2qpHKSOBZdLU30s8GqA1P1IkdptiT9ELxmDNqHdWuGFIh3cHgfKkcVIOiyP8g/ADlnTco6uh82Vvs9hOWSVSWCWpMJwxSuxUL/K16OdWM4E3pW5mMKXsil5gx0FJZpeXqx9QzYc0ydxot1RlhTs346cSmOGMnKdktpL81Ubkd9pnczGzV7OVZpZVGw8KM4EsQkZUD6XCOzYugAZq7XQm7pJoy65IqdQtj7reMu/lGS/+QR5rqoW/xWsY+V0xkfTdXM2vKwP3lPtNkWCjVms26mQM6uEnaP5J8LRWDevV4LhR3j0YRwmzsAbrsAkhbMu7MRtICBgFu4g3vwXv0nr2XceuE9+FZhX/Ke30Hs0+ofw=</latexit> <latexit sha1_base64="E39ngjsgV8nEvGp8Qkx5+8gAaGo=">ACK3icbVBNbxMxEJ0NHw2hpGl75GIRISEB2d0kUnNrpV6KxKFIpKmURJHXmW2s2N6t7V01WuVHcIXfwK/hVMSVOz8BZ7cgWjqSpef35nGL0oFNzYIr3ag4ePHm/VnzSebj9r7rR2985MkmGQ5aIRJ9H1KDgCoeW4HnqUYqI4GjaHm80Uc5asMT9dGuUpxKeqF4zBm1jhoZ8pM8nzWagedoCzyPwhvQPvwF5R1Otv1mpN5wjKJyjJBjRmHQWrfxAIv1bSg2nImcN2YZAZTypb0AscOKirRTIty6zV56Zg5iRPtjrKkZP91FQas5KR65TULsxdbUPep40zGw+mBVdpZlGxalCcCWITsomAzLlGZsXKAco0d7sStqCaMuCakxKY+EPjbv5Rkv/PY801Svf4pWMfa6YyObou7maX73N3VPuN2WC/W530O+RCvTCP2DwN8GzbifsdYIP/fbRuypKqMNzeAGvIQDOITOIUhMFjCJ/gMX7yv3jfvu/ejaq15N59uFXez986cKhG</latexit> Quaternions and rotations There is a natural association between the unit quaternion θ = 2 ψ v sin ψ ∈ S 3 ⊂ H cos ψ + ˆ and the 3D axis-angle rotation ˆ v v ( θ ) ∈ SO (3) R ˆ where θ = 2 ψ . cos ψ + ˆ v sin ψ [Wikimedia Commons user Geek3] Note s + v and − s − v represent the unit 3-sphere same rotation in 4D space
Recommend
More recommend