Unformatted text preview:

Transformations and ProjectionsTransformation of lines/normalsRotation about a known axisOpenGL Transformation SupportTransformation ExampleOpenGL TransformationsExamplesHierarchical Transformations in OpenGLViewing in 3DWorld to Eye CoordinatesSlide 11Slide 12Slide 13Slide 14Camera AnalogySpecifying 3D View (Camera Analogy)Specifying 3D ViewEye Coordinate SystemSlide 19Eye Coordinate System (OpenGL/GLU library)gluLookAt()Slide 22Camera ObscuraSlide 24Slide 25Slide 26Slide 27Slide 28Perspective ProjectionSlide 30Slide 32Slide 33Properties of ProjectionSlide 36The Equation of Weak PerspectiveParallel ProjectionSlide 39OpenGL for ProjectionTransformations and Projections(Some slides adapted from Amitabh Varshney)Transformation of lines/normals•2D. Line is set of points (x,y) for which (a,b,c).(x,y,1)T=0. Suppose we rotate points by R. Notice that:(a,b,c)RT R(x,y,1)TSo, (a,b,c)RT is the rotation of the line (a,b,c).Surface normals are similar, except they are defined by (a,b,c).(x,y,z)T = 0Rotation about a known axis•Suppose we want to rotate about u. •Find R so that u will be the new z axis.–u is third row of R.–Second row is anything orthogonal to u.–Third row is cross-product of first two.–Make sure matrix has determinant 1.•Then rotate about (new) z axis.•Then apply inverse of first rotation.OpenGL Transformation Support•Three matrices–GL_MODELVIEW, GL_PROJECTION, GL_TEXTURE– glMatrixMode( mode ) specifies the active matrix• glLoadIdentity( ) –Set the active matrix to identity• glLoadMatrix{fd}(TYPE *m) –Set the 16 values of the current matrix to those specified by m• glMultMatrix{fd}(TYPE *m) –Multiplies the current active matrix by mm1 m5 m9 m13m2 m6 m10 m14m3 m7 m11 m15m4 m8 m12 m16m =Transformation ExampleglMatrixMode(GL_MODELVIEW);glLoadIdentity( ); // matrix = IglMultMatrix(N); // matrix = NglMultmatrix(M); // matrix = NM glMultMatrix(L); // matrix = NMLglBegin(GL_POINTS);glVertex3f(v); // v will be transformed: NMLvglEnd( );OpenGL Transformations• glTranslate{fd}(TYPE x, TYPE y, TYPE z)–Multiply the current matrix by the translation matrix• glRotate{fd}(TYPE angle, TYPE x, TYPE y, TYPE z)–Multiply the current matrix by the rotation matrix that rotates an object about the axis from (0,0,0) to (x, y, z)• glScale{fd}(TYPE x, TYPE y, TYPE z)–Multiply the current matrix by the scale matrixExamplesglMatrixMode(GL_MODELVIEW);glRecti(50,100,200,150);glTranslatef(-200.0, -50.0, 0.0);glRecti(50,100,200,150);glLoadIdentity();glRotatef(90.0, 0.0, 0.0, 1.0);glRecti(50,100,200,150);glLoadIdentity();glscalef(-.5, 1.0, 1.0)glRecti(50,100,200,150);Hierarchical Transformations in OpenGL•Stacks for Modelview and Projection matrices• glPushMatrix( )–push-down all the matrices in the active stack one level–the top-most matrix is copied (the top and the second-from-top matrices are initially the same).• glPopMatrix( )–pop-off and discard the top matrix in the active stack •Stacks used during recursive traversal of the hierarchy. •Typical depths of matrix stacks:–Modelview stack = 32 (aggregating several transformations)–Projection Stack = 2 (eg: 3D graphics and 2D help-menu)Viewing in 3D•World (3D)  Screen (2D) •Orienting Eye coordinate system in World coordinate system– View Orientation Matrix •Specifying viewing volume and projection parameters for n d (d < n) – View Mapping MatrixWorld to Eye Coordinates(Images Removed)World to Eye Coordinates•We need to transform from the world coordinates to the eye coordinates•The eye coordinate system is specified by:–View reference point (VRP) •(VRPx, VRPy, VRPz)–Direction of the axes: eye coordinate system•U = (ux, uy, uz)•V = (vx, vy, vz)•N = (nx, ny, nz)World to Eye Coordinates•There are two steps in the transformation (in order)–Translation –RotationWorld to Eye Coordinates•Translate World Origin to VRP 1 0 0 -VRPx 0 1 0 -VRPy 0 0 1 -VRPz 0 0 0 1 x y z 1 a b c 1=World to Eye Coordinates•Rotate World X, Y, Z to the Eye coordinate system u, v, n, also known as the View Reference Coordinate system a b c 1 x’ y’ z’ 1=ux uy uz 0vx vy vz 0nx ny nz 00 0 0 1Camera Analogy(Images Removed)Specifying 3D View(Camera Analogy)• Center of camera (x, y, z) : 3 parameters• Direction of pointing (,) : 2 parameters• Camera tilt () : 1 parameter• Area of film (w, h) : 2 parameters• Focus (f) : 1 parameterSpecifying 3D View•Center of camera (x, y, z) : View Reference Point (VRP)• Direction of pointing (,) : View Plane Normal (VPN)• Camera tilt () : View Up (VUP)• Area of film (w, h) : Aspect Ratio (w/h), Field of view (fov)• Focus (f) : Will consider laterEye Coordinate System•View Reference Point (VRP)•View Plane Normal (VPN)•View Up (VUP)VRP (origin)VUP (Y-axis)VPN (Z-axis)Viewing PlaneVUP  VPN(X-axis)World to Eye Coordinates•Translate World Origin to VRP •Rotate World X, Y, Z to the Eye coordinate system, also known as the View Reference Coordinate system, VRC = (VUP  VPN, VUP, VPN), respectively: ( VUP  VPN ) 0 ( VUP ) 0 ( VPN ) 0 0 0 0 1Eye Coordinate System(OpenGL/GLU library)• gluLookAt (eyex , eyey , eyez , lookatx , lookaty , lookatz , upx , upy , upz );• In our terminology:eye = VRP lookat = VRP + VPN up = VUP• gluLookAt also works even if:–lookat is any point along the VPN–VUP is not perpendicular to VPNgluLookAt()Image from: Interactive Computer Graphics by Ed Angel(Images Removed)Eye Coordinate System(OpenGL/GLU library)•This how the gluLookAt parameters are used to generate the eye coordinate system parameters: VRP = eye VPN = (lookat - eye) / lookat - eye) VUP = VPN  (up  VPN)•The eye coordinate system parameters are then used in translation T(VRP) and rotation R(XYZ VRC) to get the view-orientation matrixhttp://www.acmi.net.au/AIC/CAMERA_OBSCURA.html (Russell Naughton)Camera Obscura"When images of illuminated objects ... penetrate through a small hole into a very dark room ... you will see [on the opposite wall] these objects in their proper form and color, reduced in size ... in a reversed position, owing to the intersection of the rays".Da


View Full Document

UMD CMSC 427 - Transformations and Projections

Download Transformations and Projections
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Transformations and Projections and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Transformations and Projections 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?