3d transformations - cornell university...• in 3d, specifying a rotation is more complex –basic...
TRANSCRIPT
![Page 1: 3D Transformations - Cornell University...• In 3D, specifying a rotation is more complex –basic rotation about origin: unit vector (axis) and angle •convention: positive rotation](https://reader030.vdocument.in/reader030/viewer/2022040408/5eb880bbd9113c50692cca3e/html5/thumbnails/1.jpg)
Cornell CS4620 Fall 2015 • Lecture 11
3D Transformations
CS 4620 Lecture 11
1© 2015 Kavita Bala
w/ prior instructor Steve Marschner •
![Page 2: 3D Transformations - Cornell University...• In 3D, specifying a rotation is more complex –basic rotation about origin: unit vector (axis) and angle •convention: positive rotation](https://reader030.vdocument.in/reader030/viewer/2022040408/5eb880bbd9113c50692cca3e/html5/thumbnails/2.jpg)
Cornell CS4620 Fall 2015 • Lecture 11
Announcements
• A2 due tomorrow
• Demos on Monday– Please sign up for a slot– Post on piazza
2© 2015 Kavita Bala
w/ prior instructor Steve Marschner •
![Page 3: 3D Transformations - Cornell University...• In 3D, specifying a rotation is more complex –basic rotation about origin: unit vector (axis) and angle •convention: positive rotation](https://reader030.vdocument.in/reader030/viewer/2022040408/5eb880bbd9113c50692cca3e/html5/thumbnails/3.jpg)
Cornell CS4620 Fall 2015 • Lecture 11
Translation
3© 2015 Kavita Bala
w/ prior instructor Steve Marschner •
![Page 4: 3D Transformations - Cornell University...• In 3D, specifying a rotation is more complex –basic rotation about origin: unit vector (axis) and angle •convention: positive rotation](https://reader030.vdocument.in/reader030/viewer/2022040408/5eb880bbd9113c50692cca3e/html5/thumbnails/4.jpg)
Cornell CS4620 Fall 2015 • Lecture 11
Scaling
4© 2015 Kavita Bala
w/ prior instructor Steve Marschner •
![Page 5: 3D Transformations - Cornell University...• In 3D, specifying a rotation is more complex –basic rotation about origin: unit vector (axis) and angle •convention: positive rotation](https://reader030.vdocument.in/reader030/viewer/2022040408/5eb880bbd9113c50692cca3e/html5/thumbnails/5.jpg)
Cornell CS4620 Fall 2015 • Lecture 11
Rotation about z axis
5© 2015 Kavita Bala
w/ prior instructor Steve Marschner •
![Page 6: 3D Transformations - Cornell University...• In 3D, specifying a rotation is more complex –basic rotation about origin: unit vector (axis) and angle •convention: positive rotation](https://reader030.vdocument.in/reader030/viewer/2022040408/5eb880bbd9113c50692cca3e/html5/thumbnails/6.jpg)
Cornell CS4620 Fall 2015 • Lecture 11
Rotation about x axis
6© 2015 Kavita Bala
w/ prior instructor Steve Marschner •
![Page 7: 3D Transformations - Cornell University...• In 3D, specifying a rotation is more complex –basic rotation about origin: unit vector (axis) and angle •convention: positive rotation](https://reader030.vdocument.in/reader030/viewer/2022040408/5eb880bbd9113c50692cca3e/html5/thumbnails/7.jpg)
Cornell CS4620 Fall 2015 • Lecture 11
Rotation about y axis
7© 2015 Kavita Bala
w/ prior instructor Steve Marschner •
![Page 8: 3D Transformations - Cornell University...• In 3D, specifying a rotation is more complex –basic rotation about origin: unit vector (axis) and angle •convention: positive rotation](https://reader030.vdocument.in/reader030/viewer/2022040408/5eb880bbd9113c50692cca3e/html5/thumbnails/8.jpg)
Cornell CS4620 Fall 2015 • Lecture 11
Properties of Matrices
• Translations: linear part is the identity• Scales: linear part is diagonal• Rotations: linear part is orthogonal
– Columns of R are mutually orthonormal: RRT=RTR=I– Also, determinant of R det(R) = 1
8© 2015 Kavita Bala
w/ prior instructor Steve Marschner •
![Page 9: 3D Transformations - Cornell University...• In 3D, specifying a rotation is more complex –basic rotation about origin: unit vector (axis) and angle •convention: positive rotation](https://reader030.vdocument.in/reader030/viewer/2022040408/5eb880bbd9113c50692cca3e/html5/thumbnails/9.jpg)
Cornell CS4620 Fall 2015 • Lecture 11
General Rotation Matrices
• A rotation in 2D is around a point• A rotation in 3D is around an axis
– so 3D rotation is w.r.t a line, not just a point
2D 3D
9© 2015 Kavita Bala
w/ prior instructor Steve Marschner •
![Page 10: 3D Transformations - Cornell University...• In 3D, specifying a rotation is more complex –basic rotation about origin: unit vector (axis) and angle •convention: positive rotation](https://reader030.vdocument.in/reader030/viewer/2022040408/5eb880bbd9113c50692cca3e/html5/thumbnails/10.jpg)
Cornell CS4620 Fall 2015 • Lecture 11
Specifying rotations
• In 2D, a rotation just has an angle• In 3D, specifying a rotation is more complex
– basic rotation about origin: unit vector (axis) and angle• convention: positive rotation is CCW when vector is pointing at you
• Many ways to specify rotation– Indirectly through frame transformations– Directly through
• Euler angles: 3 angles about 3 axes• (Axis, angle) rotation• Quaternions
10© 2015 Kavita Bala
w/ prior instructor Steve Marschner •
![Page 11: 3D Transformations - Cornell University...• In 3D, specifying a rotation is more complex –basic rotation about origin: unit vector (axis) and angle •convention: positive rotation](https://reader030.vdocument.in/reader030/viewer/2022040408/5eb880bbd9113c50692cca3e/html5/thumbnails/11.jpg)
Cornell CS4620 Fall 2015 • Lecture 11
Euler angles
• An object can be oriented arbitrarily• Euler angles: stack up three coord axis rotations
• ZYX case: Rz(thetaz)*Ry(thetay)*Rx(thetax)• “heading, attitude, bank”(common for airplanes)
• “pitch, yaw, roll”(common for ground vehicles)
• “pan, tilt, roll”(common for cameras)
11© 2015 Kavita Bala
w/ prior instructor Steve Marschner •
![Page 12: 3D Transformations - Cornell University...• In 3D, specifying a rotation is more complex –basic rotation about origin: unit vector (axis) and angle •convention: positive rotation](https://reader030.vdocument.in/reader030/viewer/2022040408/5eb880bbd9113c50692cca3e/html5/thumbnails/12.jpg)
Cornell CS4620 Fall 2015 • Lecture 11
Roll, yaw, Pitch
12© 2015 Kavita Bala
w/ prior instructor Steve Marschner •
![Page 13: 3D Transformations - Cornell University...• In 3D, specifying a rotation is more complex –basic rotation about origin: unit vector (axis) and angle •convention: positive rotation](https://reader030.vdocument.in/reader030/viewer/2022040408/5eb880bbd9113c50692cca3e/html5/thumbnails/13.jpg)
Cornell CS4620 Fall 2015 • Lecture 11
Specifying rotations: Euler rotations
• Euler angles
13© 2015 Kavita Bala
w/ prior instructor Steve Marschner •
![Page 14: 3D Transformations - Cornell University...• In 3D, specifying a rotation is more complex –basic rotation about origin: unit vector (axis) and angle •convention: positive rotation](https://reader030.vdocument.in/reader030/viewer/2022040408/5eb880bbd9113c50692cca3e/html5/thumbnails/14.jpg)
Cornell CS4620 Fall 2015 • Lecture 11
Gimbal Lock
14© 2015 Kavita Bala
w/ prior instructor Steve Marschner •
![Page 15: 3D Transformations - Cornell University...• In 3D, specifying a rotation is more complex –basic rotation about origin: unit vector (axis) and angle •convention: positive rotation](https://reader030.vdocument.in/reader030/viewer/2022040408/5eb880bbd9113c50692cca3e/html5/thumbnails/15.jpg)
Cornell CS4620 Fall 2015 • Lecture 11
Euler angles
• Gimbal lock removes one degree of freedom
15© 2015 Kavita Bala
w/ prior instructor Steve Marschner •
worth a look:http://www.youtube.com/watch?v=zc8b2Jo7mno(also http://www.youtube.com/watch?v=rrUCBOlJdt4)
![Page 16: 3D Transformations - Cornell University...• In 3D, specifying a rotation is more complex –basic rotation about origin: unit vector (axis) and angle •convention: positive rotation](https://reader030.vdocument.in/reader030/viewer/2022040408/5eb880bbd9113c50692cca3e/html5/thumbnails/16.jpg)
Cornell CS4620 Fall 2015 • Lecture 11
Matrices for axis-angle rotations
• Showed matrices for coordinate axis rotations– but what if we want rotation about some other axis?
• Compute by composing elementary transforms– transform rotation axis to align with x axis– apply rotation– inverse transform back into position
• Just as in 2D this can be interpreted as a similarity transform
16© 2015 Kavita Bala
w/ prior instructor Steve Marschner •
![Page 17: 3D Transformations - Cornell University...• In 3D, specifying a rotation is more complex –basic rotation about origin: unit vector (axis) and angle •convention: positive rotation](https://reader030.vdocument.in/reader030/viewer/2022040408/5eb880bbd9113c50692cca3e/html5/thumbnails/17.jpg)
Cornell CS4620 Fall 2015 • Lecture 11
Building general rotations
• Using elementary transforms you need three– translate axis to pass through origin– rotate about y to get into x-y plane– rotate about z to align with x axis
• Alternative: construct frame and change coordinates– choose p, u, v, w to be orthonormal frame with p and u matching
the rotation axis
– apply transform T = F Rx(θ ) F–1
17© 2015 Kavita Bala
w/ prior instructor Steve Marschner •
![Page 18: 3D Transformations - Cornell University...• In 3D, specifying a rotation is more complex –basic rotation about origin: unit vector (axis) and angle •convention: positive rotation](https://reader030.vdocument.in/reader030/viewer/2022040408/5eb880bbd9113c50692cca3e/html5/thumbnails/18.jpg)
Cornell CS4620 Fall 2015 • Lecture 11
Orthonormal frames in 3D
• Useful tools for constructing transformations• Recall rigid motions
– affine transforms with pure rotation– columns (and rows) form right handed ONB
• that is, an orthonormal basis
18© 2015 Kavita Bala
w/ prior instructor Steve Marschner •
![Page 19: 3D Transformations - Cornell University...• In 3D, specifying a rotation is more complex –basic rotation about origin: unit vector (axis) and angle •convention: positive rotation](https://reader030.vdocument.in/reader030/viewer/2022040408/5eb880bbd9113c50692cca3e/html5/thumbnails/19.jpg)
Cornell CS4620 Fall 2015 • Lecture 11
Building 3D frames
• Given a vector a and a secondary vector b – The u axis should be parallel to a; the u–v plane should contain
b • u = a / ||a||• w = u x b; w = w / ||w||• v = w x u
• Given just a vector a – The u axis should be parallel to a; don’t care about orientation
about that axis• Same process but choose arbitrary b first• Good choice for b is not near a: e.g. set smallest entry to 1
19© 2015 Kavita Bala
w/ prior instructor Steve Marschner •
![Page 20: 3D Transformations - Cornell University...• In 3D, specifying a rotation is more complex –basic rotation about origin: unit vector (axis) and angle •convention: positive rotation](https://reader030.vdocument.in/reader030/viewer/2022040408/5eb880bbd9113c50692cca3e/html5/thumbnails/20.jpg)
Cornell CS4620 Fall 2015 • Lecture 11
Building general rotations
• Construct frame and change coordinates– choose p, u, v, w to be orthonormal frame with p and u
matching the rotation axis
– apply similarity transform T = F Rx(θ ) F–1
– interpretation: move to x axis, rotate, move back– interpretation: rewrite u-axis rotation in new coordinates– (each is equally valid)
– (note above is linear transform; add affine coordinate)20
© 2015 Kavita Balaw/ prior instructor Steve Marschner •
![Page 21: 3D Transformations - Cornell University...• In 3D, specifying a rotation is more complex –basic rotation about origin: unit vector (axis) and angle •convention: positive rotation](https://reader030.vdocument.in/reader030/viewer/2022040408/5eb880bbd9113c50692cca3e/html5/thumbnails/21.jpg)
Cornell CS4620 Fall 2015 • Lecture 11
Building general rotations
• Construct frame and change coordinates– choose p, u, v, w to be orthonormal frame with p and u matching
the rotation axis
– apply similarity transform T = F Rx(θ ) F–1
– interpretation: move to x axis, rotate, move back– interpretation: rewrite u-axis rotation in new coordinates– (each is equally valid)
• Sleeker alternative: Rodrigues’ formula
21© 2015 Kavita Bala
w/ prior instructor Steve Marschner •
![Page 22: 3D Transformations - Cornell University...• In 3D, specifying a rotation is more complex –basic rotation about origin: unit vector (axis) and angle •convention: positive rotation](https://reader030.vdocument.in/reader030/viewer/2022040408/5eb880bbd9113c50692cca3e/html5/thumbnails/22.jpg)
Cornell CS4620 Fall 2015 • Lecture 11
Derivation of General Rotation Matrix
22© 2015 Kavita Bala
w/ prior instructor Steve Marschner •
• Axis angle rotation
![Page 23: 3D Transformations - Cornell University...• In 3D, specifying a rotation is more complex –basic rotation about origin: unit vector (axis) and angle •convention: positive rotation](https://reader030.vdocument.in/reader030/viewer/2022040408/5eb880bbd9113c50692cca3e/html5/thumbnails/23.jpg)
Cornell CS4620 Fall 2015 • Lecture 11
Axis-angle ONB
23© 2015 Kavita Bala
w/ prior instructor Steve Marschner •
![Page 24: 3D Transformations - Cornell University...• In 3D, specifying a rotation is more complex –basic rotation about origin: unit vector (axis) and angle •convention: positive rotation](https://reader030.vdocument.in/reader030/viewer/2022040408/5eb880bbd9113c50692cca3e/html5/thumbnails/24.jpg)
Cornell CS4620 Fall 2015 • Lecture 11
Axis-angle rotation
24© 2015 Kavita Bala
w/ prior instructor Steve Marschner •
![Page 25: 3D Transformations - Cornell University...• In 3D, specifying a rotation is more complex –basic rotation about origin: unit vector (axis) and angle •convention: positive rotation](https://reader030.vdocument.in/reader030/viewer/2022040408/5eb880bbd9113c50692cca3e/html5/thumbnails/25.jpg)
Cornell CS4620 Fall 2015 • Lecture 11
Rotation Matrix for Axis-Angle
25© 2015 Kavita Bala
w/ prior instructor Steve Marschner •
![Page 26: 3D Transformations - Cornell University...• In 3D, specifying a rotation is more complex –basic rotation about origin: unit vector (axis) and angle •convention: positive rotation](https://reader030.vdocument.in/reader030/viewer/2022040408/5eb880bbd9113c50692cca3e/html5/thumbnails/26.jpg)
Cornell CS4620 Fall 2015 • Lecture 11
Transforming normal vectors
• Transforming surface normals– differences of points (and therefore tangents) transform OK– normals do not. Instead, use inverse transpose matrix
26© 2015 Kavita Bala
w/ prior instructor Steve Marschner •