CS-184: Compute Gaphics Lectue #6: 3D Tansfomations and Rotations Pof. James O Bien Univesity of Califonia, Bekeley V2006-F-06-1.0 Today Tansfomations in 3D Rotations Matices Eule angles Eponential maps Quatenions 2
3D Tansfomations Geneally, the etension fom 2D to 3D is staightfowad Vectos get longe by one Matices get eta column and ow SVD still woks the same way Scale, Tanslation, and Shea all basically the same Rotations get inteesting 3 Tanslations à = 1 0 t 0 1 t y 0 0 1 1 0 0 t à = 0 1 0 t y 0 0 1 t z 0 0 0 1 Fo 2D Fo 3D 4
Scales à = s 0 0 0 s y 0 0 0 1 s 0 0 0 à = 0 s y 0 0 0 0 s z 0 0 0 0 1 Fo 2D Fo 3D (Ais-aligned) 5 Sheas à = 1 h y 0 h y 1 0 0 0 1 1 h y h z 0 à = h y 1 h yz 0 h z h zy 1 0 0 0 0 1 Fo 2D Fo 3D (Ais-aligned) 6
à = Sheas 1 h y h z 0 h y 1 h yz 0 h z h zy 1 0 0 0 0 1 Sheas y into 7 Rotations 3D Rotations fundamentally moe comple than in 2D 2D: amount of otation 3D: amount and ais of otation -vs- 2D 3D 8
Rotations Rotations still othonomal Det(R) = 1 1 Peseve lengths and distance to oigin 3D otations DO NOT COMMUTE Right-hand ule Unique matices 9 Ais-aligned 3D Rotations 2D otations implicitly otate about a thid out of plane ais 10
Ais-aligned 3D Rotations 2D otations implicitly otate about a thid out of plane ais [ ] cos() sin() R = sin() cos() cos() sin() 0 R = sin() cos() 0 0 0 1 Note: looks same as R 11 Ais-aligned 3D Rotations R = 1 0 0 0 cos() sin() ˆ 0 sin() cos() R = cos() 0 sin() 0 1 0 ŷ sin() 0 cos() cos() sin() 0 R = sin() cos() 0 ẑ 0 0 1 ŷ ẑ ˆ 12
Ais-aligned 3D Rotations R = 1 0 0 0 cos() sin() ˆ 0 sin() cos() R = cos() 0 sin() 0 1 0 ŷ sin() 0 cos() cos() sin() 0 R = sin() cos() 0 ẑ 0 0 1 Z is in you face ŷ ẑ ˆ 12 Ais-aligned 3D Rotations R = 1 0 0 0 cos() sin() ˆ 0 sin() cos() R = cos() 0 sin() 0 1 0 ŷ sin() 0 cos() cos() sin() 0 R = sin() cos() 0 ẑ 0 0 1 Also ight handed Zup ẑ ŷ ˆ 13
Ais-aligned 3D Rotations Also known as diection-cosine matices R = 1 0 0 0 cos() sin() R = cos() 0 sin() 0 1 0 ˆ ŷ 0 sin() cos() sin() 0 cos() cos() sin() 0 R = sin() cos() 0 ẑ 0 0 1 14 Abitay Rotations Can be built fom ais-aligned matices: R = Rẑ Rŷ R ˆ Result due to Eule... hence called Eule Angles Easy to stoe in vecto R = ot(,y,z) But NOT a vecto. 15
Abitay Rotations R = Rẑ Rŷ R ˆ R ˆ Rŷ Rẑ R 16 Abitay Rotations Allows tumbling Eule angles ae non-unique Gimbal-lock Moving -vs- fied aes Revese of each othe 17
Eponential Maps Diect epesentation of abitay otation AKA: ais-angle, angula displacement vecto Rotate Encode = degees about some ais by length of vecto ˆ 18 Given vecto Eponential Maps, how to get mati Method fom tet: 1. otate about ais to put into the -y plane 2. otate about z ais align with the ais 3. otate degees about ais 4. undo #2 and then #1 5. composite togethe R 19
Eponential Maps Vecto epessing a point has two pats does not change otates like a 2D point 20 Eponential Maps = ˆ = ˆ (ˆ ) = + sin() + cos() sin() cos() 21
Eponential Maps Rodiguez Fomula = ˆ(ˆ ) +sin()(ˆ ) cos()(ˆ (ˆ )) Actually a mino vaiation... 22 Eponential Maps Rodiguez Fomula = ˆ(ˆ ) +sin()(ˆ ) cos()(ˆ (ˆ )) Linea in Actually a mino vaiation... 22
Eponential Maps Building the mati = ((ˆˆ t ) + sin()(ˆ ) cos()(ˆ )(ˆ )) (ˆ ) = 0 ˆ z ˆ y ˆ z 0 ˆ ˆ y ˆ 0 Antisymmetic mati (a )b = a b Easy to veify by epansion 23 Eponential Maps Allows tumbling No gimbal-lock Oientations ae space within -adius ball Nealy unique epesentation Singulaities on shells at 2 Nice fo intepolation 24
Eponential Maps Why eponential? Recall seies epansion of e e = 1 + 1 + 2 2 + 3 3 + 25 Eponential Maps = Why eponential? Recall seies epansion of e Eule: what happens if you put in i fo e i = 1 + i 1 + 2 2 + i3 3 (1 + 2 2 + 4 4 + ) + i = cos() + isin() + 4 4 + ( 1 + 3 3 + ) 26
Why eponential? e (ˆ ) = I + (ˆ ) 1 Eponential Maps + (ˆ )2 2 2 + (ˆ )3 3 3 + (ˆ )4 4 4 + But notice that: (ˆ ) 3 = (ˆ ) e (ˆ ) = I + (ˆ ) 1 + (ˆ )2 2 2 + (ˆ )3 3 + (ˆ )2 4 4 + 27 Eponential Maps e (ˆ ) = I + (ˆ ) 1 + (ˆ )2 2 2 + (ˆ )3 3 + (ˆ )2 4 4 + ( ) ) e (ˆ ) = (ˆ ) 1 3 3 + + I + (ˆ ) (+ 2 2 2 4 4 + e (ˆ ) = (ˆ )sin() + I + (ˆ ) 2 (1 cos()) 28
Quatenions Moe popula than eponential maps Natual etension of e i = cos() + isin() Due to Hamilton (1843) Inteesting histoy Involves hemaphoditic monstes 29 Quatenions Ube-Comple Numbes q = (z 1,z 2,z 3,s) = (z,s) q = iz 1 + jz 2 + kz 3 + s i 2 = j 2 = k 2 = 1 i j = k ji = k jk = i k j = i ki = j ik = j 30
Quatenions Multiplication natual consequence of defn. q p = (z q s p + z p s q + z p z q, s p s q z p z q ) Conjugate q = ( z,s) Magnitude q 2 = z z + s 2 = q q 31 Quatenions Vectos as quatenions v = (v,0) Rotations as quatenions = (ˆsin 2,cos 2 ) Rotating a vecto = Composing otations = 1 2 Compae to Ep. Map 32
Quatenions No tumbling No gimbal-lock Oientations ae double unique Suface of a 3-sphee in 4D = 1 Nice fo intepolation 33 Rotation Matices Eigen system One eal eigenvalue Real ais is ais of otation Imaginay values ae 2D otation as comple numbe Logaithmic fomula (ˆ ) = ln(r) = 2sin (R RT ) = cos 1 ( T(R) 1 2 ) Simila fomulae as fo eponential... 34
Rotation Matices Conside: & $ RI = $ $ % y z y yy zy z yz zz #& 1 $ $ 0 " $ % 0 0 1 0 0# 0 1 " Columns ae coodinate aes afte tansfomation (tue fo geneal matices) Rows ae oiginal aes in oiginal system (not tue fo geneal matices) 35 Note: Rotation stuff in the book is a bit weak... luckily you have these nice slides 36