cs417/418 computer graphics - cornell university€¦ · • 3d affine transformation has 12...
TRANSCRIPT
![Page 1: CS417/418 Computer Graphics - Cornell University€¦ · • 3D affine transformation has 12 degrees of freedom –count them from the matrix entries we’re allowed to change •](https://reader034.vdocument.in/reader034/viewer/2022042318/5f06efcb7e708231d41a7a2d/html5/thumbnails/1.jpg)
© 2013 Steve Marschner •(with previous instructors James/Bala)
Cornell CS4620 Fall 2013 • Lecture 6
3D Tranformations
CS 4620 Lecture 6
1
![Page 2: CS417/418 Computer Graphics - Cornell University€¦ · • 3D affine transformation has 12 degrees of freedom –count them from the matrix entries we’re allowed to change •](https://reader034.vdocument.in/reader034/viewer/2022042318/5f06efcb7e708231d41a7a2d/html5/thumbnails/2.jpg)
© 2013 Steve Marschner •(with previous instructors James/Bala)
Cornell CS4620 Fall 2013 • Lecture 6
Translation
2
![Page 3: CS417/418 Computer Graphics - Cornell University€¦ · • 3D affine transformation has 12 degrees of freedom –count them from the matrix entries we’re allowed to change •](https://reader034.vdocument.in/reader034/viewer/2022042318/5f06efcb7e708231d41a7a2d/html5/thumbnails/3.jpg)
© 2013 Steve Marschner •(with previous instructors James/Bala)
Cornell CS4620 Fall 2013 • Lecture 6
Translation
2
![Page 4: CS417/418 Computer Graphics - Cornell University€¦ · • 3D affine transformation has 12 degrees of freedom –count them from the matrix entries we’re allowed to change •](https://reader034.vdocument.in/reader034/viewer/2022042318/5f06efcb7e708231d41a7a2d/html5/thumbnails/4.jpg)
© 2013 Steve Marschner •(with previous instructors James/Bala)
Cornell CS4620 Fall 2013 • Lecture 6
Translation
2
![Page 5: CS417/418 Computer Graphics - Cornell University€¦ · • 3D affine transformation has 12 degrees of freedom –count them from the matrix entries we’re allowed to change •](https://reader034.vdocument.in/reader034/viewer/2022042318/5f06efcb7e708231d41a7a2d/html5/thumbnails/5.jpg)
© 2013 Steve Marschner •(with previous instructors James/Bala)
Cornell CS4620 Fall 2013 • Lecture 6
Translation
2
![Page 6: CS417/418 Computer Graphics - Cornell University€¦ · • 3D affine transformation has 12 degrees of freedom –count them from the matrix entries we’re allowed to change •](https://reader034.vdocument.in/reader034/viewer/2022042318/5f06efcb7e708231d41a7a2d/html5/thumbnails/6.jpg)
© 2013 Steve Marschner •(with previous instructors James/Bala)
Cornell CS4620 Fall 2013 • Lecture 6
Scaling
3
![Page 7: CS417/418 Computer Graphics - Cornell University€¦ · • 3D affine transformation has 12 degrees of freedom –count them from the matrix entries we’re allowed to change •](https://reader034.vdocument.in/reader034/viewer/2022042318/5f06efcb7e708231d41a7a2d/html5/thumbnails/7.jpg)
© 2013 Steve Marschner •(with previous instructors James/Bala)
Cornell CS4620 Fall 2013 • Lecture 6
Scaling
3
![Page 8: CS417/418 Computer Graphics - Cornell University€¦ · • 3D affine transformation has 12 degrees of freedom –count them from the matrix entries we’re allowed to change •](https://reader034.vdocument.in/reader034/viewer/2022042318/5f06efcb7e708231d41a7a2d/html5/thumbnails/8.jpg)
© 2013 Steve Marschner •(with previous instructors James/Bala)
Cornell CS4620 Fall 2013 • Lecture 6
Scaling
3
![Page 9: CS417/418 Computer Graphics - Cornell University€¦ · • 3D affine transformation has 12 degrees of freedom –count them from the matrix entries we’re allowed to change •](https://reader034.vdocument.in/reader034/viewer/2022042318/5f06efcb7e708231d41a7a2d/html5/thumbnails/9.jpg)
© 2013 Steve Marschner •(with previous instructors James/Bala)
Cornell CS4620 Fall 2013 • Lecture 6
Scaling
3
![Page 10: CS417/418 Computer Graphics - Cornell University€¦ · • 3D affine transformation has 12 degrees of freedom –count them from the matrix entries we’re allowed to change •](https://reader034.vdocument.in/reader034/viewer/2022042318/5f06efcb7e708231d41a7a2d/html5/thumbnails/10.jpg)
© 2013 Steve Marschner •(with previous instructors James/Bala)
Cornell CS4620 Fall 2013 • Lecture 6
Rotation about z axis
4
![Page 11: CS417/418 Computer Graphics - Cornell University€¦ · • 3D affine transformation has 12 degrees of freedom –count them from the matrix entries we’re allowed to change •](https://reader034.vdocument.in/reader034/viewer/2022042318/5f06efcb7e708231d41a7a2d/html5/thumbnails/11.jpg)
© 2013 Steve Marschner •(with previous instructors James/Bala)
Cornell CS4620 Fall 2013 • Lecture 6
Rotation about z axis
4
![Page 12: CS417/418 Computer Graphics - Cornell University€¦ · • 3D affine transformation has 12 degrees of freedom –count them from the matrix entries we’re allowed to change •](https://reader034.vdocument.in/reader034/viewer/2022042318/5f06efcb7e708231d41a7a2d/html5/thumbnails/12.jpg)
© 2013 Steve Marschner •(with previous instructors James/Bala)
Cornell CS4620 Fall 2013 • Lecture 6
Rotation about x axis
5
![Page 13: CS417/418 Computer Graphics - Cornell University€¦ · • 3D affine transformation has 12 degrees of freedom –count them from the matrix entries we’re allowed to change •](https://reader034.vdocument.in/reader034/viewer/2022042318/5f06efcb7e708231d41a7a2d/html5/thumbnails/13.jpg)
© 2013 Steve Marschner •(with previous instructors James/Bala)
Cornell CS4620 Fall 2013 • Lecture 6
Rotation about x axis
5
![Page 14: CS417/418 Computer Graphics - Cornell University€¦ · • 3D affine transformation has 12 degrees of freedom –count them from the matrix entries we’re allowed to change •](https://reader034.vdocument.in/reader034/viewer/2022042318/5f06efcb7e708231d41a7a2d/html5/thumbnails/14.jpg)
© 2013 Steve Marschner •(with previous instructors James/Bala)
Cornell CS4620 Fall 2013 • Lecture 6
Rotation about y axis
6
![Page 15: CS417/418 Computer Graphics - Cornell University€¦ · • 3D affine transformation has 12 degrees of freedom –count them from the matrix entries we’re allowed to change •](https://reader034.vdocument.in/reader034/viewer/2022042318/5f06efcb7e708231d41a7a2d/html5/thumbnails/15.jpg)
© 2013 Steve Marschner •(with previous instructors James/Bala)
Cornell CS4620 Fall 2013 • Lecture 6
Rotation about y axis
6
![Page 16: CS417/418 Computer Graphics - Cornell University€¦ · • 3D affine transformation has 12 degrees of freedom –count them from the matrix entries we’re allowed to change •](https://reader034.vdocument.in/reader034/viewer/2022042318/5f06efcb7e708231d41a7a2d/html5/thumbnails/16.jpg)
© 2013 Steve Marschner •(with previous instructors James/Bala)
Cornell CS4620 Fall 2013 • Lecture 6
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– there are many more 3D rotations than 2D
• a 3D space around a given point, not just 1D
2D 3D
7
![Page 17: CS417/418 Computer Graphics - Cornell University€¦ · • 3D affine transformation has 12 degrees of freedom –count them from the matrix entries we’re allowed to change •](https://reader034.vdocument.in/reader034/viewer/2022042318/5f06efcb7e708231d41a7a2d/html5/thumbnails/17.jpg)
© 2013 Steve Marschner •(with previous instructors James/Bala)
Cornell CS4620 Fall 2013 • Lecture 6
Properties of Rotation Matrices
• Columns of R are mutually orthonormal: RRT=RTR=I
• Right-handed coordinate systems: det(R)=1
8
![Page 18: CS417/418 Computer Graphics - Cornell University€¦ · • 3D affine transformation has 12 degrees of freedom –count them from the matrix entries we’re allowed to change •](https://reader034.vdocument.in/reader034/viewer/2022042318/5f06efcb7e708231d41a7a2d/html5/thumbnails/18.jpg)
© 2013 Steve Marschner •(with previous instructors James/Bala)
Cornell CS4620 Fall 2013 • Lecture 6
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
9
![Page 19: CS417/418 Computer Graphics - Cornell University€¦ · • 3D affine transformation has 12 degrees of freedom –count them from the matrix entries we’re allowed to change •](https://reader034.vdocument.in/reader034/viewer/2022042318/5f06efcb7e708231d41a7a2d/html5/thumbnails/19.jpg)
© 2013 Steve Marschner •(with previous instructors James/Bala)
Cornell CS4620 Fall 2013 • Lecture 6
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 (NASA standard airplane coordinates)• pitch, yaw, roll
10
![Page 20: CS417/418 Computer Graphics - Cornell University€¦ · • 3D affine transformation has 12 degrees of freedom –count them from the matrix entries we’re allowed to change •](https://reader034.vdocument.in/reader034/viewer/2022042318/5f06efcb7e708231d41a7a2d/html5/thumbnails/20.jpg)
© 2013 Steve Marschner •(with previous instructors James/Bala)
Cornell CS4620 Fall 2013 • Lecture 6
Roll, yaw, Pitch
11
![Page 21: CS417/418 Computer Graphics - Cornell University€¦ · • 3D affine transformation has 12 degrees of freedom –count them from the matrix entries we’re allowed to change •](https://reader034.vdocument.in/reader034/viewer/2022042318/5f06efcb7e708231d41a7a2d/html5/thumbnails/21.jpg)
• NASA standard• Euler angles: stack up three coord axis rotations
• ZYX case: Rz(thetaz)*Ry(thetay)*Rx(thetax)
© 2013 Steve Marschner •(with previous instructors James/Bala)
Cornell CS4620 Fall 2013 • Lecture 6
3D rotations
12
![Page 22: CS417/418 Computer Graphics - Cornell University€¦ · • 3D affine transformation has 12 degrees of freedom –count them from the matrix entries we’re allowed to change •](https://reader034.vdocument.in/reader034/viewer/2022042318/5f06efcb7e708231d41a7a2d/html5/thumbnails/22.jpg)
© 2013 Steve Marschner •(with previous instructors James/Bala)
Cornell CS4620 Fall 2013 • Lecture 6
Specifying rotations: Euler rotations
• Euler angles
13
![Page 23: CS417/418 Computer Graphics - Cornell University€¦ · • 3D affine transformation has 12 degrees of freedom –count them from the matrix entries we’re allowed to change •](https://reader034.vdocument.in/reader034/viewer/2022042318/5f06efcb7e708231d41a7a2d/html5/thumbnails/23.jpg)
© 2013 Steve Marschner •(with previous instructors James/Bala)
Cornell CS4620 Fall 2013 • Lecture 6
Gimbal Lock
14
![Page 24: CS417/418 Computer Graphics - Cornell University€¦ · • 3D affine transformation has 12 degrees of freedom –count them from the matrix entries we’re allowed to change •](https://reader034.vdocument.in/reader034/viewer/2022042318/5f06efcb7e708231d41a7a2d/html5/thumbnails/24.jpg)
© 2013 Steve Marschner •(with previous instructors James/Bala)
Cornell CS4620 Fall 2013 • Lecture 6
Euler angles
• Gimbal lock removes one degree of freedom
15
worth a look:http://www.youtube.com/watch?v=zc8b2Jo7mno(also http://www.youtube.com/watch?v=rrUCBOlJdt4)
![Page 25: CS417/418 Computer Graphics - Cornell University€¦ · • 3D affine transformation has 12 degrees of freedom –count them from the matrix entries we’re allowed to change •](https://reader034.vdocument.in/reader034/viewer/2022042318/5f06efcb7e708231d41a7a2d/html5/thumbnails/25.jpg)
© 2013 Steve Marschner •(with previous instructors James/Bala)
Cornell CS4620 Fall 2013 • Lecture 6
Matrices for axis-angle rotations
• Showed matrices for coordinate axis rotations– but what if we want rotation about some random 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
![Page 26: CS417/418 Computer Graphics - Cornell University€¦ · • 3D affine transformation has 12 degrees of freedom –count them from the matrix entries we’re allowed to change •](https://reader034.vdocument.in/reader034/viewer/2022042318/5f06efcb7e708231d41a7a2d/html5/thumbnails/26.jpg)
© 2013 Steve Marschner •(with previous instructors James/Bala)
Cornell CS4620 Fall 2013 • Lecture 6
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 similarity transform T = F Rx(θ ) F–1
17
![Page 27: CS417/418 Computer Graphics - Cornell University€¦ · • 3D affine transformation has 12 degrees of freedom –count them from the matrix entries we’re allowed to change •](https://reader034.vdocument.in/reader034/viewer/2022042318/5f06efcb7e708231d41a7a2d/html5/thumbnails/27.jpg)
© 2013 Steve Marschner •(with previous instructors James/Bala)
Cornell CS4620 Fall 2013 • Lecture 6
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
![Page 28: CS417/418 Computer Graphics - Cornell University€¦ · • 3D affine transformation has 12 degrees of freedom –count them from the matrix entries we’re allowed to change •](https://reader034.vdocument.in/reader034/viewer/2022042318/5f06efcb7e708231d41a7a2d/html5/thumbnails/28.jpg)
© 2013 Steve Marschner •(with previous instructors James/Bala)
Cornell CS4620 Fall 2013 • Lecture 6
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 = u / ||u||• 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 is not near a: e.g. set smallest entry to 1
19
![Page 29: CS417/418 Computer Graphics - Cornell University€¦ · • 3D affine transformation has 12 degrees of freedom –count them from the matrix entries we’re allowed to change •](https://reader034.vdocument.in/reader034/viewer/2022042318/5f06efcb7e708231d41a7a2d/html5/thumbnails/29.jpg)
© 2013 Steve Marschner •(with previous instructors James/Bala)
Cornell CS4620 Fall 2013 • Lecture 6
Building general rotations
• Alternative: 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
![Page 30: CS417/418 Computer Graphics - Cornell University€¦ · • 3D affine transformation has 12 degrees of freedom –count them from the matrix entries we’re allowed to change •](https://reader034.vdocument.in/reader034/viewer/2022042318/5f06efcb7e708231d41a7a2d/html5/thumbnails/30.jpg)
© 2013 Steve Marschner •(with previous instructors James/Bala)
Cornell CS4620 Fall 2013 • Lecture 6
Building general rotations
• Alternative: 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
![Page 31: CS417/418 Computer Graphics - Cornell University€¦ · • 3D affine transformation has 12 degrees of freedom –count them from the matrix entries we’re allowed to change •](https://reader034.vdocument.in/reader034/viewer/2022042318/5f06efcb7e708231d41a7a2d/html5/thumbnails/31.jpg)
© 2013 Steve Marschner •(with previous instructors James/Bala)
Cornell CS4620 Fall 2013 • Lecture 6
Specifying Rotations
• Many ways to specify rotation– Indirectly through frame transformations– Directly through
• Euler angles: 3 angles about 3 axes• (Axis, angle) rotation: based on Euler’s theorem• Quaternions
22
![Page 32: CS417/418 Computer Graphics - Cornell University€¦ · • 3D affine transformation has 12 degrees of freedom –count them from the matrix entries we’re allowed to change •](https://reader034.vdocument.in/reader034/viewer/2022042318/5f06efcb7e708231d41a7a2d/html5/thumbnails/32.jpg)
© 2013 Steve Marschner •(with previous instructors James/Bala)
Cornell CS4620 Fall 2013 • Lecture 6
Derivation of General Rotation Matrix
23
• Axis angle rotation
![Page 33: CS417/418 Computer Graphics - Cornell University€¦ · • 3D affine transformation has 12 degrees of freedom –count them from the matrix entries we’re allowed to change •](https://reader034.vdocument.in/reader034/viewer/2022042318/5f06efcb7e708231d41a7a2d/html5/thumbnails/33.jpg)
© 2013 Steve Marschner •(with previous instructors James/Bala)
Cornell CS4620 Fall 2013 • Lecture 6
Axis-angle ONB
24
![Page 34: CS417/418 Computer Graphics - Cornell University€¦ · • 3D affine transformation has 12 degrees of freedom –count them from the matrix entries we’re allowed to change •](https://reader034.vdocument.in/reader034/viewer/2022042318/5f06efcb7e708231d41a7a2d/html5/thumbnails/34.jpg)
© 2013 Steve Marschner •(with previous instructors James/Bala)
Cornell CS4620 Fall 2013 • Lecture 6
Axis-angle rotation
25
![Page 35: CS417/418 Computer Graphics - Cornell University€¦ · • 3D affine transformation has 12 degrees of freedom –count them from the matrix entries we’re allowed to change •](https://reader034.vdocument.in/reader034/viewer/2022042318/5f06efcb7e708231d41a7a2d/html5/thumbnails/35.jpg)
© 2013 Steve Marschner •(with previous instructors James/Bala)
Cornell CS4620 Fall 2013 • Lecture 6 26
![Page 36: CS417/418 Computer Graphics - Cornell University€¦ · • 3D affine transformation has 12 degrees of freedom –count them from the matrix entries we’re allowed to change •](https://reader034.vdocument.in/reader034/viewer/2022042318/5f06efcb7e708231d41a7a2d/html5/thumbnails/36.jpg)
© 2013 Steve Marschner •(with previous instructors James/Bala)
Cornell CS4620 Fall 2013 • Lecture 6
Rotation Matrix for Axis-Angle
27
![Page 37: CS417/418 Computer Graphics - Cornell University€¦ · • 3D affine transformation has 12 degrees of freedom –count them from the matrix entries we’re allowed to change •](https://reader034.vdocument.in/reader034/viewer/2022042318/5f06efcb7e708231d41a7a2d/html5/thumbnails/37.jpg)
© 2013 Steve Marschner •(with previous instructors James/Bala)
Cornell CS4620 Fall 2013 • Lecture 6
Transforming normal vectors
• Transforming surface normals– differences of points (and therefore tangents) transform OK– normals do not --> use inverse transpose matrix
28
![Page 38: CS417/418 Computer Graphics - Cornell University€¦ · • 3D affine transformation has 12 degrees of freedom –count them from the matrix entries we’re allowed to change •](https://reader034.vdocument.in/reader034/viewer/2022042318/5f06efcb7e708231d41a7a2d/html5/thumbnails/38.jpg)
© 2013 Steve Marschner •(with previous instructors James/Bala)
Cornell CS4620 Fall 2013 • Lecture 6
Transforming normal vectors
• Transforming surface normals– differences of points (and therefore tangents) transform OK– normals do not --> use inverse transpose matrix
28
![Page 39: CS417/418 Computer Graphics - Cornell University€¦ · • 3D affine transformation has 12 degrees of freedom –count them from the matrix entries we’re allowed to change •](https://reader034.vdocument.in/reader034/viewer/2022042318/5f06efcb7e708231d41a7a2d/html5/thumbnails/39.jpg)
© 2013 Steve Marschner •(with previous instructors James/Bala)
Cornell CS4620 Fall 2013 • Lecture 6
Building transforms from points
• 2D affine transformation has 6 degrees of freedom (DOFs)– this is the number of “knobs” we have to set to define one
• So, 6 constraints suffice to define the transformation– handy kind of constraint: point p maps to point q (2 constraints
at once)– three point constraints add up to constrain all 6 DOFs
(i.e. can map any triangle to any other triangle)
• 3D affine transformation has 12 degrees of freedom– count them from the matrix entries we’re allowed to change
• So, 12 constraints suffice to define the transformation– in 3D, this is 4 point constraints
(i.e. can map any tetrahedron to any other tetrahedron)
29