ReviewCSE167: Computer GraphicsInstructor: Steve RotenbergUCSD, Fall 2005FinalThe final is on Tuesday, December 6From 11:30-2:30Center Hall, room 105It will cover material from the entire quarterIt will be similar to the midterm, but with 20 questionsThere will not be any questions on C++ or OpenGLTopicsThe final will have geometry problems similar to those in the midtermThere will be some mathematical questions about curved surfaces and ray tracing (lectures 12, 13, & 16)I suggest studying lectures 12, 13 & 16 well, as I might ask about anything from those (you don’t have to memorize the Fresnel equations, but you should know what they are for)There will not be any math questions about BRDFs, the ‘Rendering Equation’, or global illumination, but I expect you to be familiar with the concepts of these thingsThere will be conceptual questions about scene management and modelingThere will also be mathematical and conceptual questions from things covered in the first half of the class (traditional graphics pipeline)Example: Distance to PlaneA plane is described by a point p on the plane and a unit normal n. Find the distance from point x to the plane•pn• xExample: Distance to PlaneThe distance is the length of the projection of x-p onto n :•pn• xx-p( )npx⋅−=distExample: Target ‘Lock On’For an airplane to get a missile locked on, the target must be within a 10 degree cone in front of the plane. If the plane’s matrix is M and the target position is t, find an expression that determines if the plane can get a lock on.M• tExample: Target ‘Lock On’For an airplane to get a missile locked on, the target must be within a 10 degree cone in front of the plane. If the plane’s matrix is M and the target position is t, find an expression that determines if the plane can get a lock on.abcd• tExample: Target ‘Lock On’We want to check the angle between the heading vector (-c ) and the vector from d to t:We can speed that up by comparing the cosine instead ( cos(10°)=.985 )( )°<−⋅−−10cos1tdctdif( )985.0>−⋅−tdctdifExample: Target ‘Lock On’We can even speed that up further by removing the division and the square root in the magnitude computation:All together, this requires 8 multiplications and 8 adds( )( )( )22*970.0 tdctd−>⋅−ifExample: Camera ‘Look At’Our eye is located at position e and we want to look at a target at position t. Generate an appropriate camera matrix M.Example: Camera ‘Look At’Our eye is located at position e and we want to look at a target at position t. Generate an appropriate camera matrix M.Two possible approaches include:Measure angles and rotate matrix into placeConstruct a,b,c, & d vectors of M directlyExample: Camera ‘Look At’Method 1: Measure Angles & RotateMeasure Angles:Tilt angleHeading anglePositionConstruct matrix by starting with the identity, then apply tilt and heading rotationsExample: Camera ‘Look At’Method 2: Build Matrix DirectlyThe d vector is just the position of the camera, which is e:The c vector is a unit length vector that points directly behind the viewer:tetec−−=ed=Example: Camera ‘Look At’Method 2: Build Matrix DirectlyThe a vector is a unit length vector that points to the right of the viewer. It is perpendicular to the c axis. To keep the camera from rolling, we also want the a vector to lay flat in the xz-plane, perpendicular to the y-axis.Note that a cross product with the y-axis can be optimized as follows:cycya××=[ ] [ ]xzcc−=×0010 cExample: Camera ‘Look At’Method 2: Build Matrix DirectlyThe b vector is a unit length vector that points up relative to the viewer. It is perpendicular to the both the c and a axesNote that b does not need to be normalized because it is already unit length. This is because a and c are unit length vectors 90 degrees apart.acb×=1*1*190sin=°=acbExample: Camera ‘Look At’Method 2: Build Matrix DirectlySummary:acb×=tetec−−=ed=cycya××=Position Vector Dot Matrixzzzzyzxzyyzyyyxyxxzxyxxxzyxzzzzyyyyxxxxdcvbvavvdcvbvavvdcvbvavvvvvdcbadcbadcba+++=′+++=′+++=′⋅=⋅=′11000vMvdcbav+++=′zyxvvvPosition Vector Dot Matrixdcbav+++=′zyxvvvv=(.5,.5,0,1)xyLocal Space(0,0,0)Position Vector Dot Matrixdcbav+++=′zyxvvvv=(.5,.5,0,1)xyLocal Space(0,0,0)xyWorld Space(0,0,0)abdMatrix MPosition Vector Dot Matrixdcbav+++=′zyxvvvv=(.5,.5,0,1)xyLocal Space(0,0,0)xyWorld Space(0,0,0)abdv’Position vs. Direction VectorsVectors representing a position in 3D space are expanded into 4D as:Vectors representing direction are expanded as:[ ]1zyxvvv[ ]0zyxvvvDirection Vector Dot Matrixcbavzyxvvv++=′zzzyzxzyzyyyxyxzxyxxxzyxzzzzyyyyxxxxcvbvavvcvbvavvcvbvavvvvvdcbadcbadcba++=′++=′++=′⋅=⋅=′01000vMvThe abcd vectors of M’ are the abcd vectors of M transformed by matrix NNotice that a, b, and c transform as direction vectors and d transforms as a positionMatrix Dot Matrix=1000zzzzyyyyxxxxdcbadcbadcbaMMNM⋅=′IdentityTake one more look at the identity matrixIt’s a axis lines up with x, b lines up with y, and c lines up with zPosition d is at the originTherefore, it represents a transformation with no rotation or translation=1000010000100001ILinear InterpolationLinear interpolation (Lerp) is a common technique for generating a new value that is somewhere in between two other valuesA ‘value’ could be a number, vector, color, or even something more complex like an entire 3D object…Consider interpolating between two points a and b by some parameter t( ) ( )baba tttLerp+−=1,,abt=1..0<t<1t=0de Casteljau Algorithmp0p1p2p3We start with our original set of pointsIn the case of a cubic Bezier curve, we start with four pointsde Casteljau Algorithmp0q0p1p2p3q2q1( )( )( )322211100,,,,,,ppqppqppqtLerptLerptLerp===de Casteljau Algorithmq0q2q1r1r0( )( )211100,,,,qqrqqrtLerptLerp==de Casteljau Algorithmr1xr0•( )10,, rrx tLerp=Bezier Curvex•p0p1p2p3Recursive Linear Interpolation( )( )( )322211100,,,,,,ppqppqppqtLerptLerptLerp===( )( )211100,,,,qqrqqrtLerptLerp==( )10,, rrx tLerp=3210pppp210qqq10rrx3210ppppExpanding the Lerps( ) ( )( ) ( )( ) ( )(
View Full Document