Download Presentation
## CS 497: Computer Graphics

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -

**CS 497: Computer Graphics**James Money**Overview**Things to discuss: • Contracts with Dr. Fairfield. • Tests, Quizzes, and Projects. • Attendance and Lectures • Course Contents • Grading**Contract w/ Dr. Fairfield**• You must complete a contract with Dr. Fairfield within two weeks of the start of the semester or when you sign up for the class. • It must include arrangements on grading, attendance, etc. • I must also receive a copy of the contract.**Tests, Quizzes, and Projects**• Tests: There will be no tests as I can foresee it. However, I might schedule one. • Quizzes: I reserve the right to give unannounced quizzes on material I have covered in lectures. • Projects: They are assigned in advance and must be turned in by the due date at 4:30PM in Dr. Fairfield’s office or Dr. Sochacki’s office.**Attendance:**You are expected to attend class everyday and 10% of grade is based on that. Lectures: I will give lectures almost everyday. Come prepared to learn and respond to ideas in class. Attendance & Lectures**Matrices, Vectors, and operations on them.**3D Modeling 3D Clipping Visible Surface Determination Lighting and Lighting techniques. Shading Texture Mapping Graphics Databases Object Collision Course Contents Luigi’s**Grading**• Attendance: 10% • Projects I, II, and III: 50% • Broken into 10%, 20% and 20% • Final Project: 40%**The Problem:**We want to view a 3D World on a 2D surface such as a computer monitor given an arbitrary view point and view angles in that world. We want this world to be as accurate as possible for us, such that we can not distinguish it from reality.**The Solution:**The answer lies in a mathematical approach called Projections. Projections transform 3D objects onto a 2D plane, from which we are viewing. Before we can discuss projections, we must discuss the mathematical backgrounds that form the basis of projections, which is where we will begin next time!**Homework**• Read Chapter 1 • Read section 3.6,3.14 • Read Chapter 4 if needed. • Read Chapter 5. • Read Chapter 6.**Topics**• Vectors, Matrices, and Planes. • Mathematics we perform on them.**Vectors**• A Vector is a column of numbers as such: 1 2 3 4**Vectors**• We can add them, but not multiply them: 1 5 6 2 6 8 3 7 10 4 8 12 + =**Vectors**• Instead of multiplying vector we can do two things with them: • Dot Product • Cross Product**Vectors and Dot Products**The Dot Product of V and W is defined as: V•W = V1 W1 V2 W2 … … Vn Wn =V1*W1 + V2*W2 + … + Vn*Wn Length of (V)=SQRT(V •V)=||V|| •**Vector and Dot Products**The dot product is not order dependent: V •W = W •V And this also equals: V •W = ||V||*||W||Cos(θ) Remember:||V||=**Matrices**• Matrices are n-columns of vectors:**Matrices**• You can Add matrices directly: = +**Multiplying Vectors**• You can multiply a vector times a matrix: Note: The number of columns in the matrix must equal the number of rows in the vector.**Multiplying Matrices**• Multiplying a matrix is a series of Matrix*Vector multiplications performed on each column of the second matrix.**Multiplying Matrices**• If A and B are mxp and pxn sized matrices then AB is a mxn matrix. • ABBA in general! • If I is the identity matrix then AI=IA=A. I is:**Matrices, Inverses, & Determinants**• The inverse of A is A-1 and AA-1=I=A-1A • The determinant of a matrix tells us if it is invertible. If Det A = 0, A is NOT invertible.(There are also a slew of other laws that apply if this is true.) The Det(A) if it is 3x3 is:**Vectors and Cross Products**• Cross Products allow you to find a vector that if perpendicular to the given two vectors if they are in 3D: V x W = Det( ) = i(V2W3 - W2V3) - j(V1W3 - W1V3) + k(V1W2 - W1V2)**Planes**• A Plane is the 3D space equivalent to the line in 2D space. It is defined by: Ax + By +Cz + D = 0. • A,B,C are the coefficients of the normal vector of the plane.**Planes and Normals**• The normal vector of a plane is perpendicular to the plane and defines it. Given 3 points we can define a plane:**Planes**• Given the Normal to a plane we can find D and the equation by plugging a point on the plane in the equation: Plot of (A,B,C,D) as (1,0,0,0) for X=0 plane.**Homework**Continuation of Last Time! • Read Chapter 1 • Read section 3.6,3.14 • Read Chapter 4 if needed. • Read Chapter 5. • Read Chapter 6.**Points and Homogeneous Form**Given a Point in the form: we can represent them as a homogeneous point in 4D space:**Homogenous Form and Matrices**We represent a 3D coordinate in homogenous form to allow easy manipulation with matrices. We use 4x4 matrices to act on these points. I for these matrices is:**From XYZ to Homogeneous and Back**• To make a point into homogeneous form: • To make a homogeneous vector into XYZ form again:**Translation**To move a point from its current position to (x+a,y+b,z+c) use the matrix:**Scaling**To scale a point by (a,b,c):**Rotating in X**To rotate a point around the x axis:**Rotating in Y**To rotate a point around the Y axis:**Rotating in Z**To rotate a point around the Z axis:**Combining Matrices**• You can combine matrices to simplify the processing of the points. However you must remember, order is important!(ABBA) • If you translate then scale, that is not necessarily the same as scaling then translating. • Also, rotations must be done around (0,0,0) in most cases. In this case, you must translate to the origin, rotate, and then translate back.**Homework**Continuation of Last Time! • Read Chapter 1 • Read section 3.6,3.14 • Read Chapter 4 if needed. • Read Chapter 5. • Read Chapter 6.**Projections**The mismatch between a 3D world and 2D drawing surface is solved via projections. Let’s first examine how we specify our 3D world we want to view.**3D Viewing Process**We specify a view volume in the world, a projection onto the projection plane, and viewport on the viewing surface. The points are first clipped against the view volume, then projected, and finally mapped to the display. Clip against view volume Project onto projection plane Transform into viewport in 2D device coordinates for display 3D world coordinates Clipped world coordinates**Projections**Projections transform points of n-dimension to that of less than n-dimension. In our case, we are transforming a n dimensional point to a n-1 dimensional point. We will limit ourselves to 2D from 3D. A projection of a 3D object is defined by projectors from a center of projection, through the projection plane, and through the endpoints of an object. The projection of a line in 3D is a line in 2D, so we only need to consider endpoints of objects.**Perspective Projections**Here is an example of perspective projection: A Projection plane B A` Projectors B` Center of Projection(COP) - Note also the vanishing point**Specifying a View**To specify a view, you will need: • The projection plane, also called the view plane. The view plane is defined by: • View Reference Point(VRP) • View Plane Normal(VPN) • View Up Vector(VUP) V View Plane VUP VRP U VPN N**Specifying a View**• Window on the view plane(in VRP coordinates): • Min U value • Min V value • Max U value • Max V value (Umax,Vmax) V View Plane VRP CW U N (Umin,Vmin) VPN**Specifying a View**• The center of projection and direction defined by: • Projection Reference Point(PRP) V View Plane CW U N Center of Projection(PRP)**Specifying a View**• Front and Back Clipping planes, at a distance F and B from the view plane. Back Clipping Plane View Plane VRP B(+) VPN F(-) Front Clipping Plane**From View Volume to display**• The view volume is scaled to that of a unit pyramid from 0..1. • Points then can be clipped to this view volume, or eliminated entirely. • The clipped points are projected and then scaled by the viewport specifications of xmin, xmax, ymin, ymax, zmin, zmax(The monitor dimensions).**Perspective Projection**To perform the perspective projection: • Translate VRP to the origin. • Rotate such that N becomes the Z axis, U the X axis, and V the Y axis. • Translate so that COP is at the origin. • Shear so that the center of the view volume becomes the Z axis. • Scale so that the view volume becomes the canonical perspective view volume.**Translate VRP to origin**This is simple: Translate by (-VRP).**Rotating the Axes**• VPN becomes the Z axis so: • The U axis is perpendicular to the VUP and VPN so: • The V axis is perpendicular to Rz and Rx so:**Rotating the Axes**• The Rotation matrix is: Where R1x is the first component of Rx, etc.