DOC PREVIEW
UVA CS 445 - Transformations

This preview shows page 1-2-3-4-5-6 out of 19 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 19 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 19 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 19 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 19 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 19 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 19 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 19 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

TransformationsAdminRecap: OpenGL: Modeling TransformsRecap: OpenGL: Matrix ManipulationSlide 5OpenGL: Specifying ColorOpenGL: Specifying NormalsMore OpenGLTranslationsScalingSlide 11Slide 122-D RotationSlide 143-D RotationSlide 16Slide 17Slide 18Composing Canonical RotationsTransformationsCS 445/645Introduction to Computer GraphicsDavid Luebke, Spring 2003David Luebke 2 01/14/19Admin●Call roll●Assn 1■News flash: Assn 1 not necessarily a gimme■Turn-in instructions by email soon■Problems with lab?David Luebke 3 01/14/19Recap: OpenGL: Modeling Transforms●OpenGL provides several commands for performing modeling transforms:■glTranslate{fd}(x, y, z)○Creates a matrix T that transforms an object by translating (moving) it by the specified x, y, and z values■glRotate{fd}(angle, x, y, z)○Creates a matrix R that transforms an object by rotating it counterclockwise angle degrees about the vector {x, y, z}■glScale{fd}(x, y, z)○Creates a matrix S that scales an object by the specified factors in the x, y, and z directionsDavid Luebke 4 01/14/19Recap:OpenGL: Matrix Manipulation●Each of these postmultiplies the current matrix■E.g., if current matrix is C, then C=CS■The current matrix is either the modelview matrix or the projection matrix (also a texture matrix, won’t discuss)■Set these with glMatrixMode(), e.g.:glMatrixMode(GL_MODELVIEW);glMatrixMode(GL_PROJECTION);■WARNING: common mistake ahead!○Be sure that you are in GL_MODELVIEW mode before making modeling or viewing calls!○Ugly mistake because it can appear to work, at least for a while…David Luebke 5 01/14/19Recap:OpenGL: Matrix Manipulation●More matrix manipulation calls■To replace the current matrix with an identity matrix:glLoadIdentity()■Postmultiply the current matrix with an arbitrary matrix:glMultMatrix{fd}(float/double m[16])■ Copy the current matrix and push it onto a stack:glPushMatrix()■Discard the current matrix and replace it with whatever’s on top of the stack:glPopMatrix()■Note that there are matrix stacks for both modelview and projection modesDavid Luebke 6 01/14/19OpenGL: Specifying Color●Can specify other properties such as color■To produce a single aqua-colored triangle:glColor3f(0.1, 0.5, 1.0); glVertex3fv(v0); glVertex3fv(v1); glVertex3fv(v2);■To produce a Gouraud-shaded triangle:glColor3f(1, 0, 0); glVertex3fv(v0);glColor3f(0, 1, 0); glVertex3fv(v1);glColor3f(0, 0, 1); glVertex3fv(v2);■In OpenGL, colors can also have a fourth component  (opacity)○Generally want  = 1.0 (opaque);David Luebke 7 01/14/19OpenGL: Specifying Normals●Calling glColor() sets the color for all vertices following, until the next call to glColor()●Calling glNormal() sets the normal vector for the following vertices, till next glNormal() ●So flat-shaded lighting requires:glNormal3f(Nx, Ny, Nz);glVertex3fv(v0);glVertex3fv(v1);glVertex3fv(v2);■While smooth shading requires:glNormal3f(N0x, N0y, N0z); glVertex3fv(v0);glNormal3f(N1x, N1y, N1z); glVertex3fv(v1);glNormal3f(N2x, N2y, N2z); glVertex3fv(v2);■(Of course, lighting requires additional setup…)David Luebke 8 01/14/19More OpenGL●Other things you’ll need to know:■To clear the screen:glClearColor(r, g, b, a);glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);●Nate Robins has an excellent set of OpenGL tutorials that help illustrate many of these concepts & functions:http://www.cs.utah.edu/~narobins/opengl.html Also http://xmission.com/~nate/tutors.html ●Next: the math and concepts underlying the transformation callsDavid Luebke 9 01/14/19Translations●For convenience we usually describe objects in relation to their own coordinate system●We can translate or move points to a new position by adding offsets to their coordinates:■Note that this translates all points uniformlyzyxtttzyxzyx'''David Luebke 10 01/14/19Scaling●Scaling a coordinate means multiplying each of its components by a scalar●Uniform scaling means this scalar is the same for all components: 2David Luebke 11 01/14/19Scaling●Non-uniform scaling: different scalars per component:●How can we represent this in matrix form?X  2,Y  0.5David Luebke 12 01/14/19Scaling●Scaling operation:●Or, in matrix form:czbyaxzyx'''zyxcbazyx000000'''scaling matrixDavid Luebke 13 01/14/192-D Rotation(x, y)(x’, y’)x’ = x cos() - y sin()y’ = x sin() + y cos()(Draw it)David Luebke 14 01/14/192-D Rotation●This is easy to capture in matrix form:●3-D is more complicated■Need to specify an axis of rotation■Simple cases: rotation about X, Y, Z axes      yxyxcossinsincos''David Luebke 15 01/14/193-D Rotation●What does the 3-D rotation matrix look like for a rotation about the Z-axis?■Build it coordinate-by-coordinatezyxzyx1000)cos()sin(0)sin()cos('''David Luebke 16 01/14/193-D Rotation●What does the 3-D rotation matrix look like for a rotation about the Y-axis?■Build it coordinate-by-coordinatezyxzyx)cos(0)sin(010)sin(0)cos('''David Luebke 17 01/14/193-D Rotation●What does the 3-D rotation matrix look like for a rotation about the X-axis?■Build it coordinate-by-coordinatezyxzyx)cos()sin(0)sin()cos(0001'''David Luebke 18 01/14/193-D Rotation●General rotations in 3-D require rotating about an arbitrary axis of rotation●Deriving the rotation matrix for such a rotation directly is a good exercise in linear algebra●Standard approach: express general rotation as composition of canonical rotations ■Rotations about X, Y, ZDavid Luebke 19 01/14/19Composing Canonical Rotations●Goal: rotate about arbitrary vector A by  ■Idea: we know how to


View Full Document

UVA CS 445 - Transformations

Documents in this Course
Lighting

Lighting

49 pages

Color

Color

20 pages

Clipping

Clipping

10 pages

Shadows

Shadows

95 pages

Color

Color

37 pages

Radiosity

Radiosity

49 pages

Clipping

Clipping

59 pages

Assign 3

Assign 3

28 pages

Splines

Splines

17 pages

Color

Color

17 pages

Load more
Download Transformations
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 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 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?