This preview shows pages 1–18. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: 1 CSE472 Computer Graphics Geometric Transformations 3D Transformations in OpenGL 2D Transformations 3D Transformations 2 CSE472 Computer Graphics What’s a Transformation? Transformation Mathematical operation that moves or changes the shape of an object We’re most interested in: • Translation (moving) • Rotation (spinning) • Scaling (changing size) 3 CSE472 Computer Graphics OpenGL code glTranslated(x, y, z) Tells the system that whatever follows is moved by (x, y, z) glTranslated(100, 0, 0); DrawTable(); 4 CSE472 Computer Graphics But… What does “whatever follows” mean? Any future OpenGL code You’ve set the “state” of OpenGL to move things right 100. 5 CSE472 Computer Graphics What will this do? for(int i=0; i<10; i++) { glTranslated(100, 0, 0); DrawTable(); } 6 CSE472 Computer Graphics Saving the State We save the current state using: glPushMatrix(); We retrieve the current state using: glPopMatrix(); 7 CSE472 Computer Graphics Common way you will do this… glPushMatrix(); glTranslated(100, 0, 0); DrawTable(); glPopMatrix(); 8 CSE472 Computer Graphics Rotation glRotated(angle, x, y, z); Rotates angle (degrees) counterclockwise around the vector x,y,z glPushMatrix(); glRotated(90, 0, 0, 1); DrawTable(); glPopMatrix(); 9 CSE472 Computer Graphics Scaling glScaled(x, y, z) Scales by x,y,z in each dimension Never use negative dimensions Use sparingly (we’ll discuss later) 10 CSE472 Computer Graphics Order Read OpenGL transformation backwards glPushMatrix(); glTranslated(10, 0, 0); glRotated(90, 0, 0, 1); DrawTable(); glPopMatrix(); Done first! Done second! 11 CSE472 Computer Graphics TransformDemo application Will be available on the class web site… 12 CSE472 Computer Graphics Now we need to learn what these things actually do… We’ll learn the underlying matricies We’ll learn how the matrix stack works We’ll learn how to make custom transformations 13 CSE472 Computer Graphics Some Review… Point or coordinate p or (x, y) or (x, y, z) Means a location in space Distance between two points d = sqrt( (x 1x 2 ) 2 +(y 1y 2 ) 2 +(z 1z 2 ) 2 ) Euclidian distance M T H 3 1 4 i n a N u t s h e l l 14 CSE472 Computer Graphics Vectors Vector v or (x,y) or (x,y,z) Means a direction in space Difference of points is a vector v = p 1 – p 2 = ((x 1x 2 ), (y 1y 2 ), (z 1z 2 )) If I’m at p 2 , what direction to go to get to p 1 p 1 p 2 15 CSE472 Computer Graphics Vector Length Length of a vector L = v = sqrt(x 2 +y 2 +z 2 ) Normalized vector Any vector where L = 1 Normalizing Divide by the length v / v 16 CSE472 Computer Graphics 2D Transformations x,y points to x’,y’ points We’ll use to derive the 3D transformations 17 CSE472 Computer Graphics Affine operations Translation x’ = x + c y’ = y + f Scaling...
View
Full
Document
This note was uploaded on 07/25/2008 for the course CSE 472 taught by Professor Owen during the Spring '08 term at Michigan State University.
 Spring '08
 OWEN
 Computer Graphics

Click to edit the document details