1 / 38

CS 445 / 645 Introduction to Computer Graphics

CS 445 / 645 Introduction to Computer Graphics. Lecture 23 B ézier Curves. Assign 4. Task List Get fluid to give you four viewing windows Build an interface so you can click down a series of points Render line segments between points Design a way to insert, move, and delete these points

shona
Télécharger la présentation

CS 445 / 645 Introduction to Computer Graphics

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS 445 / 645Introduction to Computer Graphics Lecture 23 Bézier Curves

  2. Assign 4 • Task List • Get fluid to give you four viewing windows • Build an interface so you can click down a series of points • Render line segments between points • Design a way to insert, move, and delete these points • How do you know if you are adding a point to the front of the spline versus adding a point after the first point of the spline?

  3. Assign 4 • Task List • Build a camera model for each window • Error in assignment: Orthographic cameras don’t zoom. They change their viewing frusta (left, right, top, bottom) • Perspective camera needs track ball (Angel 4.10.2, A.11) • First-person camera that slides along curve • acceptable to have uniform increments of t • Even though this may lead to non-uniform velocities • Curve derivative defines look-at direction, but what about V-up?

  4. Assign 4 • Task List • Build three B-Splines (x, y, and z) from vertex list • Convert B-Spline into Bezier Splines • Recursively subdivide Bezier Spline (Angel 10.9.2) • Render subdivided Bezier Spline as line segments • Incorporate Yannick’s pipe code to recreate a first-person view of riding through pipe

  5. Virtual Trackball • Can we use the mouse to control the 2-D rotation of a viewing volume? • Imagine a track ball (draw it on board) • User moves point on ball from (x, y, z) to (a, b, c) • Imagine the points projected onto the ground • User moves point on ground from (x, 0, z) to (a, 0, c)

  6. Trackball • Movement of points on track ball can be inferred from mouse drags on screen • Inverse problem • Where on trackball does (a, 0, c) hit? • Ball is unit sphere, so ||x, y, z|| = 1.0 • x = a, z = c, y = solve for it

  7. Trackball • User defines two points • Place where first clicked X = (x, y, z) • Place where released A = (a, b, c) • Ball rotates along axis perp to line defined by these two points • compute cross produce of lines to origin: (X – O) x (A – O) • Ball rotates by amount proportional to distance between lines • magnitude of cross product tells us angle between lines (dot product too) • |sin q| = ||cross product|| • Compute rotation matrix and use it to rotate world

  8. Splines - History • Draftsman use ‘ducks’ and strips of wood (splines) to draw curves • Wood splines have second-order continuity • And pass through the control points A Duck (weight) Ducks trace out curve

  9. Bézier Curves • Similar to Hermite, but more intuitive definition of endpoint derivatives • Four control points, two of which are knots

  10. Bézier Curves • The derivative values of the Bezier Curve at the knots are dependent on the adjacent points • The scalar 3 was selected just for this curve

  11. Bézier vs. Hermite • We can write our Bezier in terms of Hermite • Note this is just matrix form of previous equations

  12. Bézier vs. Hermite • Now substitute this in for previous Hermite

  13. Bézier Basis and Geometry Matrices • Matrix Form • But why is MBezier a good basis matrix?

  14. Bézier Blending Functions • Look at the blending functions • This family of polynomials is calledorder-3 Bernstein Polynomials • C(3, k) tk (1-t)3-k; 0<= k <= 3 • They are all positive in interval [0,1] • Their sum is equal to 1

  15. Bézier Blending Functions • Thus, every point on curve is linear combination of the control points • The weights of the combination are all positive • The sum of the weights is 1 • Therefore, the curve is a convex combination of the control points

  16. Bézier Curves • Will always remain within bounding region defined by control points

  17. Bézier Curves • Bezier

  18. Why more spline slides? • Bezier and Hermite splines have global influence • Piecewise Bezier or Hermite don’t enforce derivative continuity at join points • Moving one control point affects the entire curve • B-splines consist of curve segments whose polynomial coefficients depend on just a few control points • Local control • Examples of Splines

  19. B-Spline Curve • Start with a sequence of control points • Select four from middle of sequence (pi-2, pi-1, pi, pi+1) d • Bezier and Hermite goes between pi-2 and pi+1 • B-Spline doesn’t interpolate (touch) any of them but approximates the going through pi-1 and pi p2 p6 p1 Q4 Q5 Q3 Q6 p3 p0 p4 p5

  20. Uniform B-Splines • Approximating Splines • Approximates n+1 control points • P0, P1, …, Pn, n ¸ 3 • Curve consists of n –2 cubic polynomial segments • Q3, Q4, … Qn • t varies along B-spline as Qi: ti <= t < ti+1 • ti (i = integer) are knot points that join segment Qi-1 to Qi • Curve is uniform because knots are spaced at equal intervals of parameter,t

  21. Uniform B-Splines • First curve segment, Q3, is defined by first four control points • Last curve segment, Qm, is defined by last four control points, Pm-3, Pm-2, Pm-1, Pm • Each control point affects four curve segments

  22. B-spline Basis Matrix • Formulate 16 equations to solve the 16 unknowns • The 16 equations enforce the C0, C1, and C2 continuity between adjoining segments, Q

  23. B-Spline Basis Matrix • Note the order of the rows in my MB-Spline is different from in the book • Observe also that the order in which I number the points is different • Therefore my matrix aligns with the book’s matrix if you reorder the points, and thus reorder the rows of the matrix

  24. B-Spline • Points along B-Spline are computed just as with Bezier Curves

  25. B-Spline • By far the most popular spline used • C0, C1, and C2 continuous

  26. B-Spline • Locality of points

  27. Nonuniform, Rational B-Splines(NURBS) • The native geometry element in Maya • Models are composed of surfaces defined by NURBS, not polygons • NURBS are smooth • NURBS require effort to make non-smooth

  28. NURBs • To generate three-dimension points • Four B-Splines are used • Three define the x, y, and z position • One defines a weighting term • The 3-D point output by a NURB is the x, y, z coordinates divided by the weighting term (like homogeneous coordinates)

  29. What is a NURB? • Nonuniform: The amount of parameter, t, that is used to model each curve segment varies • Nonuniformity permits either C2, C1, or C0 continuity at join points between curve segments • Nonuniformity permits control points to be added to middle of curve

  30. What do we get? • NURBs are invariant under rotation, scaling, translation, and perspective transformations of the control points (nonrational curves are not preserved under perspective projection) • This means you can transform the control points and redraw the curve using the transformed points • If this weren’t true you’d have to sample curve to many points and transform each point individually • B-spline is preserved under affine transformations, but that is all

  31. Converting Between Splines • Consider two spline basis formulations for two spline types

  32. Converting Between Splines • We can transform the control points from one spline basis to another

  33. Converting Between Splines • With this conversion, we can convert a B-Spline into a Bezier Spline • Bezier Splines are easy to render

  34. Rendering Splines • Horner’s Method • Incremental (Forward Difference) Method • Subdivision Methods

  35. Horner’s Method • Three multiplications • Three additions

  36. Forward Difference • But this still is expensive to compute • Solve for change at k (Dk) and change at k+1 (Dk+1) • Boot strap with initial values for x0, D0, and D1 • Compute x3 by adding x0 + D0 + D1

  37. Subdivision Methods • Bezier

  38. Rendering Bezier Spline public void spline(ControlPoint p0, ControlPoint p1, ControlPoint p2, ControlPoint p3, int pix) { float len = ControlPoint.dist(p0,p1) + ControlPoint.dist(p1,p2) + ControlPoint.dist(p2,p3); float chord = ControlPoint.dist(p0,p3); if (Math.abs(len - chord) < 0.25f) return; fatPixel(pix, p0.x, p0.y); ControlPoint p11 = ControlPoint.midpoint(p0, p1); ControlPoint tmp = ControlPoint.midpoint(p1, p2); ControlPoint p12 = ControlPoint.midpoint(p11, tmp); ControlPoint p22 = ControlPoint.midpoint(p2, p3); ControlPoint p21 = ControlPoint.midpoint(p22, tmp); ControlPoint p20 = ControlPoint.midpoint(p12, p21); spline(p20, p12, p11, p0, pix); spline(p3, p22, p21, p20, pix); }

More Related