david breen, william regli and maxim peysakhov geometric and intelligent computing laboratory
DESCRIPTION
CS 430/536 Computer Graphics I 3D Transformations World Window to Viewport Transformation Week 2, Lecture 4. David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent Computing Laboratory Department of Computer Science Drexel University http://gicl.cs.drexel.edu. Outline. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent Computing Laboratory](https://reader035.vdocuments.us/reader035/viewer/2022062723/5681401c550346895dab721d/html5/thumbnails/1.jpg)
1
CS 430/536Computer Graphics I
3D TransformationsWorld Window to Viewport Transformation
Week 2, Lecture 4
David Breen, William Regli and Maxim Peysakhov
Geometric and Intelligent Computing Laboratory
Department of Computer Science
Drexel Universityhttp://gicl.cs.drexel.edu
![Page 2: David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent Computing Laboratory](https://reader035.vdocuments.us/reader035/viewer/2022062723/5681401c550346895dab721d/html5/thumbnails/2.jpg)
2
Outline
• World window to viewport transformation
• 3D transformations
• Coordinate system transformation
![Page 3: David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent Computing Laboratory](https://reader035.vdocuments.us/reader035/viewer/2022062723/5681401c550346895dab721d/html5/thumbnails/3.jpg)
3
The Window-to-Viewport Transformation
• Problem: Screen windows cannot display the whole world (window management)
• How to transform and clip:Objects to Windows to Screen
Pics/Math courtesy of Dave Mount @ UMD-CP
![Page 4: David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent Computing Laboratory](https://reader035.vdocuments.us/reader035/viewer/2022062723/5681401c550346895dab721d/html5/thumbnails/4.jpg)
4
Window-to-Viewport Transformation
• Given a window and a viewport, what is the transformation from WCS to VPCS?
Three steps:• Translate• Scale• Translate
1994 Foley/VanDam/Finer/Huges/Phillips ICG
![Page 5: David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent Computing Laboratory](https://reader035.vdocuments.us/reader035/viewer/2022062723/5681401c550346895dab721d/html5/thumbnails/5.jpg)
5
Transforming World Coordinates to Viewports
• 3 steps1. Translate
2. Scale
3. Translate
Overall Transformation:
1994 Foley/VanDam/Finer/Huges/Phillips ICG
![Page 6: David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent Computing Laboratory](https://reader035.vdocuments.us/reader035/viewer/2022062723/5681401c550346895dab721d/html5/thumbnails/6.jpg)
6
Clipping to the Viewport
• Viewport size may not be big enough for everything
• Display only the pixels inside the viewport
• Transform lines in world• Then clip in world•Transform to image• Then draw• Do not transform pixels
1994 Foley/VanDam/Finer/Huges/Phillips ICG
![Page 7: David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent Computing Laboratory](https://reader035.vdocuments.us/reader035/viewer/2022062723/5681401c550346895dab721d/html5/thumbnails/7.jpg)
7
Another Example• Scan-converted
– Lines– Polygons– Text– Fill regions
• Clipregionsfor display
1994 Foley/VanDam/Finer/Huges/Phillips ICG
![Page 8: David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent Computing Laboratory](https://reader035.vdocuments.us/reader035/viewer/2022062723/5681401c550346895dab721d/html5/thumbnails/8.jpg)
9
3D Transformations
![Page 9: David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent Computing Laboratory](https://reader035.vdocuments.us/reader035/viewer/2022062723/5681401c550346895dab721d/html5/thumbnails/9.jpg)
10
Representation of 3D Transformations
• Z axis represents depth• Right Handed System
– When looking “down” at the origin, positive rotation is CCW
• Left Handed System– When looking “down”, positive
rotation is in CW– More natural interpretation for
displays, big z means “far” (into screen)
1994 Foley/VanDam/Finer/Huges/Phillips ICG
![Page 10: David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent Computing Laboratory](https://reader035.vdocuments.us/reader035/viewer/2022062723/5681401c550346895dab721d/html5/thumbnails/10.jpg)
11
3D Homogenous Coordinates
• Homogenous coordinates for 2D space requires 3D vectors & matrices
• Homogenous coordinates for 3D space requires 4D vectors & matrices
• [x,y,z,w]
![Page 11: David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent Computing Laboratory](https://reader035.vdocuments.us/reader035/viewer/2022062723/5681401c550346895dab721d/html5/thumbnails/11.jpg)
12
3D Transformations:Scale & Translate
• Scale– Parameters for each
axis direction
• Translation
![Page 12: David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent Computing Laboratory](https://reader035.vdocuments.us/reader035/viewer/2022062723/5681401c550346895dab721d/html5/thumbnails/12.jpg)
13
3D Transformations: Rotation
• One rotation for each world coordinate axis
![Page 13: David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent Computing Laboratory](https://reader035.vdocuments.us/reader035/viewer/2022062723/5681401c550346895dab721d/html5/thumbnails/13.jpg)
14
Rotation Around an Arbitrary Axis
• Rotate a point P around axis n (x,y,z) by angle
• c = cos()• s = sin()• t = (1 - c) Graphics Gems I, p. 466 & 498
![Page 14: David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent Computing Laboratory](https://reader035.vdocuments.us/reader035/viewer/2022062723/5681401c550346895dab721d/html5/thumbnails/14.jpg)
• Also can be expressed as the Rodrigues Formula
15
Rotation Around an Arbitrary Axis
![Page 15: David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent Computing Laboratory](https://reader035.vdocuments.us/reader035/viewer/2022062723/5681401c550346895dab721d/html5/thumbnails/15.jpg)
Improved Rotations
• Euler Angles have problems– How to interpolate keyframes?– Angles aren’t independent– Interpolation can create Gimble Lock, i.e.
loss of a degree of freedom when axes align
• Solution: Quaternions!
16
![Page 16: David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent Computing Laboratory](https://reader035.vdocuments.us/reader035/viewer/2022062723/5681401c550346895dab721d/html5/thumbnails/16.jpg)
17
![Page 17: David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent Computing Laboratory](https://reader035.vdocuments.us/reader035/viewer/2022062723/5681401c550346895dab721d/html5/thumbnails/17.jpg)
18
![Page 18: David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent Computing Laboratory](https://reader035.vdocuments.us/reader035/viewer/2022062723/5681401c550346895dab721d/html5/thumbnails/18.jpg)
19
![Page 19: David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent Computing Laboratory](https://reader035.vdocuments.us/reader035/viewer/2022062723/5681401c550346895dab721d/html5/thumbnails/19.jpg)
20
![Page 20: David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent Computing Laboratory](https://reader035.vdocuments.us/reader035/viewer/2022062723/5681401c550346895dab721d/html5/thumbnails/20.jpg)
21
![Page 21: David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent Computing Laboratory](https://reader035.vdocuments.us/reader035/viewer/2022062723/5681401c550346895dab721d/html5/thumbnails/21.jpg)
22
slerp – Spherical linear interpolation
Need to take equals steps on the sphere
A & B are quaternions
![Page 22: David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent Computing Laboratory](https://reader035.vdocuments.us/reader035/viewer/2022062723/5681401c550346895dab721d/html5/thumbnails/22.jpg)
What about interpolating multiple keyframes?
• Shoemake suggests using Bezier curves on the sphere
• Offers a variation of the De Casteljau algorithm using slerp and quaternion control points
• See K. Shoemake, “Animating rotation with quaternion curves”, Proc. SIGGRAPH ’85
23
![Page 23: David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent Computing Laboratory](https://reader035.vdocuments.us/reader035/viewer/2022062723/5681401c550346895dab721d/html5/thumbnails/23.jpg)
24
3D Transformations:Reflect & Shear
• Reflection:
about x-y plane
• Shear:
(function of z)
![Page 24: David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent Computing Laboratory](https://reader035.vdocuments.us/reader035/viewer/2022062723/5681401c550346895dab721d/html5/thumbnails/24.jpg)
25
3D Transformations:Shear
![Page 25: David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent Computing Laboratory](https://reader035.vdocuments.us/reader035/viewer/2022062723/5681401c550346895dab721d/html5/thumbnails/25.jpg)
26
Example
Pics/Math courtesy of Dave Mount @ UMD-CP
![Page 26: David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent Computing Laboratory](https://reader035.vdocuments.us/reader035/viewer/2022062723/5681401c550346895dab721d/html5/thumbnails/26.jpg)
27
Example: Composition of 3D Transformations
• Goal: Transform P1P2 and P1P3
1994 Foley/VanDam/Finer/Huges/Phillips ICG
![Page 27: David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent Computing Laboratory](https://reader035.vdocuments.us/reader035/viewer/2022062723/5681401c550346895dab721d/html5/thumbnails/27.jpg)
28
Example (Cont.)
• Process1. Translate P1 to (0,0,0)
2. Rotate about y
3. Rotate about x
4. Rotate about z
(1)
(2-3)
(4)
1994 Foley/VanDam/Finer/Huges/Phillips ICG
![Page 28: David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent Computing Laboratory](https://reader035.vdocuments.us/reader035/viewer/2022062723/5681401c550346895dab721d/html5/thumbnails/28.jpg)
29
Final Result• What we’ve really
done is transform the local coordinate system Rx, Ry, Rz to align with the origin x,y,z
1994 Foley/VanDam/Finer/Huges/Phillips ICG
![Page 29: David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent Computing Laboratory](https://reader035.vdocuments.us/reader035/viewer/2022062723/5681401c550346895dab721d/html5/thumbnails/29.jpg)
30
Example 2: Composition of 3D Transformations
• Airplane defined in x,y,z
• Problem: want to point it in Dir of Flight (DOF)centered at point P
• Note: DOF is a vector• Process:
– Rotate plane– Move to P
1994 Foley/VanDam/Finer/Huges/Phillips ICG
![Page 30: David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent Computing Laboratory](https://reader035.vdocuments.us/reader035/viewer/2022062723/5681401c550346895dab721d/html5/thumbnails/30.jpg)
31
Example 2 (cont.)
• Zp axis to be DOF
• Xp axis to be a horizontal vector perpendicular to DOF– y x DOF
• Yp, vector perpendicular to both Zp and Xp (i.e.Zp x Xp)
1994 Foley/VanDam/Finer/Huges/Phillips ICG
![Page 31: David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent Computing Laboratory](https://reader035.vdocuments.us/reader035/viewer/2022062723/5681401c550346895dab721d/html5/thumbnails/31.jpg)
32
Transformations to Change Coordinate Systems
• Issue: the world has many different relative frames of reference
• How do we transform among them?• Example: CAD Assemblies & Animation Models
![Page 32: David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent Computing Laboratory](https://reader035.vdocuments.us/reader035/viewer/2022062723/5681401c550346895dab721d/html5/thumbnails/32.jpg)
33
Transformations to Change Coordinate Systems
• 4 coordinate systems1 point P
1994 Foley/VanDam/Finer/Huges/Phillips ICG
![Page 33: David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent Computing Laboratory](https://reader035.vdocuments.us/reader035/viewer/2022062723/5681401c550346895dab721d/html5/thumbnails/33.jpg)
34
Coordinate System Example (1)
• Translate the House to the origin
1994 Foley/VanDam/Finer/Huges/Phillips ICG
The matrix Mij that maps points from coordinate system j to i is the inverse of the matrix Mji that maps points from coordinate system j to coordinate system i.
P1
![Page 34: David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent Computing Laboratory](https://reader035.vdocuments.us/reader035/viewer/2022062723/5681401c550346895dab721d/html5/thumbnails/34.jpg)
35
Coordinate System Example (2)• Transformation
Composition:
1994 Foley/VanDam/Finer/Huges/Phillips ICG
![Page 35: David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent Computing Laboratory](https://reader035.vdocuments.us/reader035/viewer/2022062723/5681401c550346895dab721d/html5/thumbnails/35.jpg)
36
World Coordinates and Local Coordinates
• To move the tricycle, we need to know how all of its parts relate to the WCS
• Example: front wheel rotates on the ground wrt the front wheel’s z axis:Coordinates of P in wheel coordinate system:
1994 Foley/VanDam/Finer/Huges/Phillips ICG
![Page 36: David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent Computing Laboratory](https://reader035.vdocuments.us/reader035/viewer/2022062723/5681401c550346895dab721d/html5/thumbnails/36.jpg)
37
Questions about Homework 1?
• Go to web site