Geometry: 2-D Transformations Course web page: Chapter #3.
-
Upload
mark-underwood -
Category
Documents
-
view
216 -
download
3
Transcript of Geometry: 2-D Transformations Course web page: Chapter #3.
![Page 1: Geometry: 2-D Transformations Course web page: Chapter #3.](https://reader030.fdocuments.us/reader030/viewer/2022032415/56649efd5503460f94c110c5/html5/thumbnails/1.jpg)
Geometry: 2-D Transformations
Course web page:http://www.gomezconsultants.com
Chapter #3
![Page 2: Geometry: 2-D Transformations Course web page: Chapter #3.](https://reader030.fdocuments.us/reader030/viewer/2022032415/56649efd5503460f94c110c5/html5/thumbnails/2.jpg)
Why We Need Transformations
• What can we do so far?– Draw 2-D shapes by exhaustively
listing their vertices– Allow user interaction
• Something missing:– The ability to specify the intrinsic
shape of an object independently of its location, scale, or orientation
![Page 3: Geometry: 2-D Transformations Course web page: Chapter #3.](https://reader030.fdocuments.us/reader030/viewer/2022032415/56649efd5503460f94c110c5/html5/thumbnails/3.jpg)
Example: Shape vs. Viewing Issues
![Page 4: Geometry: 2-D Transformations Course web page: Chapter #3.](https://reader030.fdocuments.us/reader030/viewer/2022032415/56649efd5503460f94c110c5/html5/thumbnails/4.jpg)
Example: Shape vs. Viewing Issues
![Page 5: Geometry: 2-D Transformations Course web page: Chapter #3.](https://reader030.fdocuments.us/reader030/viewer/2022032415/56649efd5503460f94c110c5/html5/thumbnails/5.jpg)
Example: Shape vs. Viewing Issues
![Page 6: Geometry: 2-D Transformations Course web page: Chapter #3.](https://reader030.fdocuments.us/reader030/viewer/2022032415/56649efd5503460f94c110c5/html5/thumbnails/6.jpg)
Example: Shape vs. Viewing Issues
![Page 7: Geometry: 2-D Transformations Course web page: Chapter #3.](https://reader030.fdocuments.us/reader030/viewer/2022032415/56649efd5503460f94c110c5/html5/thumbnails/7.jpg)
Transformations for modeling, viewing
1. Make object model in idealized coordinate frame
2. Transform object with appropriate translation, scaling, rotation as needed
• Also useful for building complex objects from simpler parts
from Hill
![Page 8: Geometry: 2-D Transformations Course web page: Chapter #3.](https://reader030.fdocuments.us/reader030/viewer/2022032415/56649efd5503460f94c110c5/html5/thumbnails/8.jpg)
Notes on Notation
• Vectors, points: x, v (assume column vectors)
• Matrices: R, T• Scalars: x, a• Axes, objects: X, Y, O• Coordinate systems: W, C• Specials
– Transpose operator: xT (as opposed to x0)
– Identity matrix: Id– Matrices/vectors of zeroes, ones: 0, 1
![Page 9: Geometry: 2-D Transformations Course web page: Chapter #3.](https://reader030.fdocuments.us/reader030/viewer/2022032415/56649efd5503460f94c110c5/html5/thumbnails/9.jpg)
2-D Transformations
• Types– Translation– Scaling– Rotation– Shear, reflection
• Mathematical representation• OpenGL functions for applying
![Page 10: Geometry: 2-D Transformations Course web page: Chapter #3.](https://reader030.fdocuments.us/reader030/viewer/2022032415/56649efd5503460f94c110c5/html5/thumbnails/10.jpg)
2-D Translation
![Page 11: Geometry: 2-D Transformations Course web page: Chapter #3.](https://reader030.fdocuments.us/reader030/viewer/2022032415/56649efd5503460f94c110c5/html5/thumbnails/11.jpg)
2-D Translation
![Page 12: Geometry: 2-D Transformations Course web page: Chapter #3.](https://reader030.fdocuments.us/reader030/viewer/2022032415/56649efd5503460f94c110c5/html5/thumbnails/12.jpg)
2-D Translation
![Page 13: Geometry: 2-D Transformations Course web page: Chapter #3.](https://reader030.fdocuments.us/reader030/viewer/2022032415/56649efd5503460f94c110c5/html5/thumbnails/13.jpg)
2-D Translation
![Page 14: Geometry: 2-D Transformations Course web page: Chapter #3.](https://reader030.fdocuments.us/reader030/viewer/2022032415/56649efd5503460f94c110c5/html5/thumbnails/14.jpg)
2-D Translation
![Page 15: Geometry: 2-D Transformations Course web page: Chapter #3.](https://reader030.fdocuments.us/reader030/viewer/2022032415/56649efd5503460f94c110c5/html5/thumbnails/15.jpg)
2-D Scaling
![Page 16: Geometry: 2-D Transformations Course web page: Chapter #3.](https://reader030.fdocuments.us/reader030/viewer/2022032415/56649efd5503460f94c110c5/html5/thumbnails/16.jpg)
2-D Scaling
![Page 17: Geometry: 2-D Transformations Course web page: Chapter #3.](https://reader030.fdocuments.us/reader030/viewer/2022032415/56649efd5503460f94c110c5/html5/thumbnails/17.jpg)
2-D Scaling
1
sx
Horizontal shift proportional to horizontal position
![Page 18: Geometry: 2-D Transformations Course web page: Chapter #3.](https://reader030.fdocuments.us/reader030/viewer/2022032415/56649efd5503460f94c110c5/html5/thumbnails/18.jpg)
2-D Scaling
1sy
Vertical shift proportional to vertical position
![Page 19: Geometry: 2-D Transformations Course web page: Chapter #3.](https://reader030.fdocuments.us/reader030/viewer/2022032415/56649efd5503460f94c110c5/html5/thumbnails/19.jpg)
2-D Scaling
![Page 20: Geometry: 2-D Transformations Course web page: Chapter #3.](https://reader030.fdocuments.us/reader030/viewer/2022032415/56649efd5503460f94c110c5/html5/thumbnails/20.jpg)
2-D Scaling
![Page 21: Geometry: 2-D Transformations Course web page: Chapter #3.](https://reader030.fdocuments.us/reader030/viewer/2022032415/56649efd5503460f94c110c5/html5/thumbnails/21.jpg)
2-D Rotation
![Page 22: Geometry: 2-D Transformations Course web page: Chapter #3.](https://reader030.fdocuments.us/reader030/viewer/2022032415/56649efd5503460f94c110c5/html5/thumbnails/22.jpg)
2-D Rotation
This is a counterclockwise rotation
![Page 23: Geometry: 2-D Transformations Course web page: Chapter #3.](https://reader030.fdocuments.us/reader030/viewer/2022032415/56649efd5503460f94c110c5/html5/thumbnails/23.jpg)
2-D Rotation
µ
This is a counterclockwise rotation
![Page 24: Geometry: 2-D Transformations Course web page: Chapter #3.](https://reader030.fdocuments.us/reader030/viewer/2022032415/56649efd5503460f94c110c5/html5/thumbnails/24.jpg)
2-D Rotation
![Page 25: Geometry: 2-D Transformations Course web page: Chapter #3.](https://reader030.fdocuments.us/reader030/viewer/2022032415/56649efd5503460f94c110c5/html5/thumbnails/25.jpg)
2-D Rotation
![Page 26: Geometry: 2-D Transformations Course web page: Chapter #3.](https://reader030.fdocuments.us/reader030/viewer/2022032415/56649efd5503460f94c110c5/html5/thumbnails/26.jpg)
2-D Rotation (uncentered)
![Page 27: Geometry: 2-D Transformations Course web page: Chapter #3.](https://reader030.fdocuments.us/reader030/viewer/2022032415/56649efd5503460f94c110c5/html5/thumbnails/27.jpg)
2-D Rotation (uncentered)
![Page 28: Geometry: 2-D Transformations Course web page: Chapter #3.](https://reader030.fdocuments.us/reader030/viewer/2022032415/56649efd5503460f94c110c5/html5/thumbnails/28.jpg)
2-D Shear (horizontal)
![Page 29: Geometry: 2-D Transformations Course web page: Chapter #3.](https://reader030.fdocuments.us/reader030/viewer/2022032415/56649efd5503460f94c110c5/html5/thumbnails/29.jpg)
2-D Shear (horizontal)
Horizontal displacement proportional to vertical position
![Page 30: Geometry: 2-D Transformations Course web page: Chapter #3.](https://reader030.fdocuments.us/reader030/viewer/2022032415/56649efd5503460f94c110c5/html5/thumbnails/30.jpg)
2-D Shear (horizontal)
![Page 31: Geometry: 2-D Transformations Course web page: Chapter #3.](https://reader030.fdocuments.us/reader030/viewer/2022032415/56649efd5503460f94c110c5/html5/thumbnails/31.jpg)
2-D Reflection (vertical)
![Page 32: Geometry: 2-D Transformations Course web page: Chapter #3.](https://reader030.fdocuments.us/reader030/viewer/2022032415/56649efd5503460f94c110c5/html5/thumbnails/32.jpg)
2-D Reflection (vertical)
Just a special case of scaling—”negative” scaling
![Page 33: Geometry: 2-D Transformations Course web page: Chapter #3.](https://reader030.fdocuments.us/reader030/viewer/2022032415/56649efd5503460f94c110c5/html5/thumbnails/33.jpg)
2-D Reflection (vertical)
![Page 34: Geometry: 2-D Transformations Course web page: Chapter #3.](https://reader030.fdocuments.us/reader030/viewer/2022032415/56649efd5503460f94c110c5/html5/thumbnails/34.jpg)
2-D Transformations: OpenGL
• 2-D transformation functions*
– glTranslate(x, y, 0)– glScale(sx, sy, 0)– glRotate(theta, 0, 0, 1) (angle in
degrees; direction is counterclockwise)• Notes
– Set glMatrixMode(GL_MODELVIEW) first– Transformations should be specified before
drawing commands to be affected– Multiple transformations are applied in
reverse order
*Technically, these are 3-D
![Page 35: Geometry: 2-D Transformations Course web page: Chapter #3.](https://reader030.fdocuments.us/reader030/viewer/2022032415/56649efd5503460f94c110c5/html5/thumbnails/35.jpg)
Example: 2-D Translation in OpenGL
Two ways to do this:
glRectf(.25,.25,.75,.75); glTranslatef(.5,.5,0);glRectf(-.25,-.25,.25,.25);
![Page 36: Geometry: 2-D Transformations Course web page: Chapter #3.](https://reader030.fdocuments.us/reader030/viewer/2022032415/56649efd5503460f94c110c5/html5/thumbnails/36.jpg)
Example: Order of transformations
glTranslatef(.5,.5,0);glRotatef(45,0,0,1);glRectf(-.25,-.25,.25,.25);
glRotatef(45,0,0,1);glTranslatef(.5,.5,0);glRectf(-.25,-.25,.25,.25);
Remember: Order of application is backwards from drawing commands
![Page 37: Geometry: 2-D Transformations Course web page: Chapter #3.](https://reader030.fdocuments.us/reader030/viewer/2022032415/56649efd5503460f94c110c5/html5/thumbnails/37.jpg)
Limiting “Scope” of Transformations
• Transformations are ordinarily applied to all subsequent draw commands
• To limit effects, use push/pop functions:glPushMatrix();
// transform
// draw affected by transform
glPopMatrix();
// draw unaffected by transform
![Page 38: Geometry: 2-D Transformations Course web page: Chapter #3.](https://reader030.fdocuments.us/reader030/viewer/2022032415/56649efd5503460f94c110c5/html5/thumbnails/38.jpg)
Example: Pushing, popping transformations
glPushMatrix();glTranslatef(.5,.5,0);glRotatef(45,0,0,1);glRectf(-.25,-.25,.25,.25);glPopMatrix();
glPushMatrix();// draw axis linesglPopMatrix();