Review CSE167: Computer Graphics Instructor: Steve Rotenberg UCSD, Fall 2005

download Review CSE167: Computer Graphics Instructor: Steve Rotenberg UCSD, Fall 2005

of 59

  • date post

    21-Jan-2016
  • Category

    Documents

  • view

    215
  • download

    0

Embed Size (px)

Transcript of Review CSE167: Computer Graphics Instructor: Steve Rotenberg UCSD, Fall 2005

  • ReviewCSE167: Computer GraphicsInstructor: Steve RotenbergUCSD, Fall 2005

  • FinalThe 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 OpenGL

  • TopicsThe 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 dont 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

  • Example: Distance to PlaneThe distance is the length of the projection of x-p onto n:x-p

  • Example: Target Lock OnFor an airplane to get a missile locked on, the target must be within a 10 degree cone in front of the plane. If the planes matrix is M and the target position is t, find an expression that determines if the plane can get a lock on.M t

  • Example: Target Lock OnFor an airplane to get a missile locked on, the target must be within a 10 degree cone in front of the plane. If the planes matrix is M and the target position is t, find an expression that determines if the plane can get a lock on.abcd t

  • Example: Target Lock OnWe 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 )

  • Example: Target Lock OnWe 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

  • Example: Camera Look AtOur 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 AtOur 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 directly

  • Example: Camera Look AtMethod 1: Measure Angles & RotateMeasure Angles:Tilt angleHeading anglePositionConstruct matrix by starting with the identity, then apply tilt and heading rotations

  • Example: Camera Look AtMethod 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:

  • Example: Camera Look AtMethod 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:

  • Example: Camera Look AtMethod 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 axes

    Note 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.

  • Example: Camera Look AtMethod 2: Build Matrix DirectlySummary:

  • Position Vector Dot Matrix

  • Position Vector Dot Matrixv=(.5,.5,0,1)xyLocal Space(0,0,0)

  • Position Vector Dot Matrixv=(.5,.5,0,1)xyLocal Space(0,0,0)xyWorld Space(0,0,0)abdMatrix M

  • Position Vector Dot Matrixv=(.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:

  • Direction Vector Dot Matrix

  • Matrix Dot Matrix

    The 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 position

  • Identity

    Take one more look at the identity matrixIts 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

  • Linear 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 objectConsider interpolating between two points a and b by some parameter t

  • de Casteljau Algorithm

    We start with our original set of pointsIn the case of a cubic Bezier curve, we start with four pointsp0p1p2p3

  • de Casteljau Algorithmp0q0p1p2p3q2q1

  • de Casteljau Algorithmq0q2q1r1r0

  • de Casteljau Algorithmr1xr0

  • Bezier Curvexp0p1p2p3

  • Recursive Linear Interpolation

  • Expanding the Lerps

  • Bernstein Polynomials

  • Bernstein PolynomialsThe Bernstein polynomial form of a Bezier curve is

    where

    and

  • Bernstein PolynomialsB33B03B13B23

  • Cubic Equation Form

  • Cubic Matrix Form

  • Cubic Matrix Form

  • Matrix Form

  • Bezier Curves & Cubic CurvesBy adjusting the 4 control points of a cubic Bezier curve, we can represent any cubic curveLikewise, any cubic curve can be represented uniquely by a cubic Bezier curveThere is a one-to-one mapping between the 4 Bezier control points (p0,p1,p2,p3) and the pure cubic coefficients (a,b,c,d)The Bezier basis matrix BBez (and its inverse) perform this mappingThere are other common forms of cubic curves that also retain this property (Hermite, Catmull-Rom, B-Spline)

  • DerivativesFinding the derivative (tangent) of a curve is easy:

  • TangentsThe derivative of a curve represents the tangent vector to the curve at some point

  • Convex Hull PropertyIf we take all of the control points for a Bezier curve and construct a convex polygon around them, we have the convex hull of the curveAn important property of Bezier curves is that every point on the curve itself will be somewhere within the convex hull of the control pointsp0p1p2p3

  • ContinuityA cubic curve defined for t ranging from 0 to 1 will form a single continuous curve and not have any gapsWe say that it has geometric continuity, or C0 continuityWe can easily see that the first derivative will be a continuous quadratic function and the second derivative will be a continuous linear functionThe third derivative (and all others) are continuous as well, but in a trivial way (constant), so we generally just say that a cubic curve has second derivative continuity or C2 continuityIn general, the higher the continuity value, the smoother the curve will be, although its actually a little more complicated than that

  • Interpolation / ApproximationWe say that cubic Bezier curves interpolate the two endpoints (p0 & p3), but only approximate the interior points (p1 & p2)In geometric design applications, it is often desirable to be able to make a single curve that interpolates through several points

  • Piecewise CurvesRather than use a very high degree curve to interpolate a large number of points, it is more common to break the curve up into several simple curvesFor example, a large complex curve could be broken into cubic curves, and would therefore be a piecewise cubic curveFor the entire curve to look smooth and continuous, it is necessary to maintain C1 continuity across segments, meaning that the position and tangents must match at the endpointsFor smoother looking curves, it is best to maintain the C2 continuity as well

  • Connecting Bezier CurvesA simple way to make larger curves is to connect up Bezier curvesConsider two Bezier curves defined by p0p3 and v0v3If p3=v0, then they will have C0 continuityIf (p3-p2)=(v1-v0), then they will have C1 continuityC2 continuity is more difficultp0p0p1p2P3P3p2p1v0v1v2v3v3v2v1v0C0 continuityC1 continuity

  • Bezier SurfacesBezier surfaces are a straightforward extension to Bezier curvesInstead of the curve being parameterized by a single variable t, we use two variables, s and tBy definition, we choose to have s and t range from 0 to 1 and we say that an s-tangent crossed with a t-tangent will represent the normal for the front of the surfacest0,01,11,00,1n

  • Curved SurfacesThe Bezier surface is a type of parametric surfaceA parametric surface is a surface that can be parametrized by two variables, s and tParametric surfaces have a rectangular topologyIn computer graphics, parametric surfaces are sometimes called patches, curved surfaces, or just surfacesThere are also some non-parametric surfaces used in computer graphics, but we wont consider those now

  • Control MeshConsider a bicubic Bezier surface (bicubic means that it is a cubic function in both the s and t parameters)A cubic curve has 4 control points, and a bicubic surface has a grid of 4x4 control points, p0 through p15p0p1p2p3p4p5p6p7p8p9p10p11p12p13p14p15st

  • Surface EvaluationThe bicubic surface can be thought