Presentation is loading. Please wait.

Presentation is loading. Please wait.

#8: Curves and Curved Surfaces CSE167: Computer Graphics Instructor: Ronen Barzel UCSD, Winter 2006.

Similar presentations


Presentation on theme: "#8: Curves and Curved Surfaces CSE167: Computer Graphics Instructor: Ronen Barzel UCSD, Winter 2006."— Presentation transcript:

1 #8: Curves and Curved Surfaces CSE167: Computer Graphics Instructor: Ronen Barzel UCSD, Winter 2006

2 1 Outline for today Summary of Bézier curves Piecewise-cubic curves, B-splines Surface Patches

3 2 Curves: Summary Use a few control points to describe a curve in space Construct a function x(t) moves a point from start to end of curve as t goes from 0 to 1 tangent to the curve is given by derivative x’(t) We looked at: Linear -- trivial case, just to get oriented Bézier curves -- in particular, cubic p0p0 p1p1 p0p0 p1p1 p2p2 p0p0 p1p1 p2p2 p3p3 LinearQuadraticCubic

4 3 Linear Interpolation: Summary Given two points p 0 and p 1 “Curve” is line segment between them p0p0 p1p1 t=1.. 0<t<1 t=0

5 4 Cubic Bézier Curve: Summary Given four points p 0, p 1, p 2, p 3 curve interpolates the endpoints intermediate points adjust shape: “tangent handles” Recursive geometric construction de Casteljau algorithm Three ways to express curve Weighted average of the control points: Bernstein polynomials Polynomial in t Matrix form x p0p0 p1p1 p2p2 p3p3

6 5 Notice: Weights always add to 1 B 0 and B 3 go to 1 -- interpolating the endpoints Cubic Bézier: Bernstein Polynomials

7 6 Cubic Bézier: Polynomial, Matrix, Notation

8 7 Tangent to Cubic Bézier

9 8 n th -order Bézier curve

10 9 Evaluate/draw curves by: Sampling uniformly in t Adaptive/Recursive Subdivision x (0.0) x (0.25) x (0.5) x (0.75) x(t) x (1.0)

11 10 Outline for today Summary of Bézier curves Piecewise-cubic curves, B-splines Surface Patches

12 11 More control points Cubic Bézier curve limited to 4 control points Cubic curve can only have one inflection Need more control points for more complex curves With k points, could define a k-1 order Bézier But it’s hard to control and hard to work with The intermediate points don’t have obvious effect on shape Changing any control point can change the whole curve Want local support: each control point only influences nearby portion of curve

13 12 Piecewise Curves With a large number of points… Construct a curve that is a sequence of simple (low-order) curves end-to-end Known as a piecewise polynomial curve E.g., a sequence of line segments: a piecewise linear curve E.g., a sequence of cubic curve segments: a piecewise cubic curve In this case, piecewise Bézier

14 13 Continuity For the whole curve to look smooth, we need to consider continuity: C 0 continuity: no gaps. The segments must match at the endpoints C 1 continuity: no corners. The tangents must match at the endpoints C 2 continuity: tangents vary smoothly. (makes smoother curves.) Note also: G 1, G 2, etc. continuity Looks at geometric continuity without considering parametric continuity Roughly, means that the tangent directions must match, but not the magnitudes Gets around “bad” parametrizations Often it’s what we really want, but it’s harder to compute

15 14 Constructing a single curve from many Given N curve segments: x 0 (t), x 1 (t), …, x N-1 (t) Each is parameterized for t from 0 to 1 Define a new curve, with u from 0 to N: Alternate: u also goes from 0 to 1

16 15 Given N+1 points p 0, p 1, …, p N Define curve: N+1 points define N linear segments x(i)=p i C 0 continuous by construction G 1 at p i when p i-1, p i, p i+1 are collinear C 1 at p i when p i -p i-1 = p i+1 -p i Piecewise-Linear curve p0p0 p1p1 p2p2 p3p3 p4p4 p5p5 p6p6 x(1.5) x(5.25) x(2.9)

17 16 Piecewise Bézier curve: segments x 0 (t) x 1 (t) x 2 (t) x 3 (t) p0p0 p1p1 p2p2 p3p3 p4p4 p5p5 p6p6 p7p7 p8p8 p9p9 p 10 p 11 p 12

18 17 Piecewise Bézier curve x 0 (t) x 1 (t) x 2 (t) x 3 (t) x(3.5) x(8.75)

19 18 Piecewise Bézier curve 3N+1 points define N Bézier segments x(i)=p 3i C 0 continuous by construction G 1 continuous at p 3i when p 3i-1, p 3i, p 3i+1 are collinear C 1 continuous at p 3i when p 3i -p 3i-1 = p 3i+1 -p 3i C 2 is harder to get p0p0 p0p0 p1p1 p2p2 P3P3 P3P3 p2p2 p1p1 p4p4 p5p5 p6p6 p6p6 p5p5 p4p4 C 1 continuous C 1 discontinuous

20 19 Piecewise Bézier curves Used often in 2D drawing programs Inconveniences: Must have 4 or 7 or 10 or 13 or … (1 plus a multiple of 3) points Not all points are the same UI inconvenience: Interpolate, approximate, approximate, interpolate, … Math inconvenience: Different weight functions for each point UI solution: “Bézier Handles” Math solution: B-spline

21 20 UI for Bézier Curve Handles Bézier segment points: Interpolating points presented normally as curve control points Approximating points presented as “handles” on the curve points UI features: All curve control points are the same Can have option to enforce C 1 continuity (www.blender.org)

22 21 Blending Functions Evaluate using “Sliding window” Local support: Window spans 4 points Window contains 4 different Bernstein polynomials Window moves forward by 3 units when u passes to next Bézier segment Evaluate matrix in window:

23 22 B-spline blending functions Still a sliding “window”, but use same weight function for every point Weight function goes to 0 outside the 4-point neighborhood local support -- each spot on curve only affected by neighbors Shift “window” by 1, not by 3 No discrete segments: every point is the same

24 23 B-Spline Widely used for surface modeling Intuitive behavior Local support: curve only affected by nearby control points Techniques for inserting new points, joining curves, etc. Doesn’t interpolate endpoints Not a problem for closed curves Sometimes use Bézier blending at the ends But wait, there’s more! Rational B-Splines Non-uniform Rational B-Splines

25 24 Big drawback of all cubic curves: can’t make circles! Nor ellipses, nor arcs. I.e. can’t make conic sections Rational B-spline: Add a weight to each point Homogeneous point: use w Weight causes point to “pull” more (or less) With proper points & weights, can do circles Rational B-splines widely used for surface modeling Need UI to adjust the weight Often hand-drawn curves are unweighted, but automatically-generated curves for circles etc. have weights Rational Curves pull more pull less

26 25 Non-Uniform Rational B-Spline (NURBS) Don’t assume that control points are equidistant in u Introduce knot vector that describes the separation of the points Features… Allows tighter bends or corners Allows corners (C 1 discontinuity) Certain knot values turn out to give a Bézier segment Allows mixing interpolating (e.g. at endpoints) and approximating Math is messier Read about it in Buss Very widely used for surface modeling Can interactively create as if uniform Techniques for cutting, inserting, merging, filleting, revolving, etc…

27 26 Outline for today Summary of Bézier curves Piecewise-cubic curves, B-splines Surface Patches

28 27 Curved Surfaces Remember the overview of curves: Described by a series of control points A function x(t) Segments joined together to form a longer curve Same for surfaces, but now two dimensions Described by a mesh of control points A function x(u,v) Patches joined together to form a bigger surface

29 28 x(u,v) describes a point in space for any given (u,v) pair u,v each range from 0 to 1 Rectangular topology Parametric curves: For fixed u 0, have a v curve x(u 0,v) For fixed v 0, have a u curve x(u,t 0 ) For any point on the surface, there are a pair of parametric curves that go through point Parametric Surface Patch 0 1 1 u v x y z x(0.8,0.7) u v x(0.4,v) x(u,0.25)

30 29 Parametric Surface Tangents The tangent to a parametric curve is also tangent to the surface For any point on the surface, there are a pair of (parametric) tangent vectors Note: not necessarily perpendicular to each other u v

31 30 Parametric Surface Normal Get the normal to a surface at any point by taking the cross product of the two parametric tangent vectors at that point. Order matters!

32 31 Polynomial Surface Patches x(s,t) is typically polynomial in both s and t Bilinear: Bicubic:

33 32 Bilinear Patch (control mesh) A bilinear patch is defined by a control mesh with four points p 0, p 1, p 2, p 3 AKA a (possibly-non-planar) quadrilateral Compute x(u,v) using a two-step construction p0p0 p1p1 p2p2 p3p3 u v

34 33 Bilinear Patch (step 1) For a given value of u, evaluate the linear curves on the two u- direction edges Use the same value u for both: q 0 =Lerp(u,p 0, p 1 ) q 1 =Lerp(u,p 0, p 1 ) p0p0 p1p1 p2p2 p3p3 u v q0q0 q1q1

35 34 Bilinear Patch (step 2) Consider that q 0, q 1 define a line segment. Evaluate it using v to get x p0p0 p1p1 p2p2 p3p3 u v q0q0 q1q1 x

36 35 Bilinear Patch (full) Combining the steps, we get the full formula p0p0 p1p1 p2p2 p3p3 u v q0q0 q1q1 x

37 36 Bilinear Patch (other order) Try the other order: evaluate first in the v direction p0p0 p1p1 p2p2 p3p3 u v r0r0 r1r1

38 37 Bilinear Patch (other order, step 2) Consider that r 0, r 1 define a line segment. Evaluate it using u to get x p0p0 p1p1 p2p2 p3p3 u v r0r0 r1r1 x

39 38 Bilinear Patch (other order, full) The full formula for the v direction first: p0p0 p1p1 p2p2 p3p3 u v r0r0 r1r1 x

40 39 Bilinear Patch (either order) It works out the same either way! p0p0 p1p1 p2p2 p3p3 u v q0q0 q1q1 r0r0 r1r1 x

41 40 Bilinear Patch p0p0 p1p1 p2p2 p3p3 p0p0 p1p1 p2p2 p3p3

42 41 Bilinear patch formulations

43 42 Bilinear patch: Matrix form

44 43 Bilinear Patch Properties of the bilinear patch: Interpolates the control points The boundaries are straight line segments connecting the control points If the all 4 points of the control mesh are co-planar, the patch is flat If the points are not coplanar, get a curved surface saddle shape, AKA hyperbolic paraboloid The parametric curves are all straight line segments! a (doubly) ruled surface: has (two) straight lines through every point Kinda nifty, but not terribly useful as a modeling primitive p0p0 p1p1 p2p2 p3p3 p0p0 p1p1 p2p2 p3p3

45 44 Bézier Control Mesh A bicubic patch has a grid of 4x4 control points, p 0 through p 15 Defines four Bézier curves along u: p 0,1,2,3 ; p 4,5,6,7 ; p 8,9,10,11 ; p 12,13,14,15 Defines four Bézier curves along v: p 0,4,8,12 ; p 1,6,9,13 ; p 2,6,10,14 ; p 3,7,11,15 Evaluate using same approach as bilinear… p0p0 p1p1 p2p2 p3p3 p4p4 p5p5 p6p6 p7p7 p8p8 p9p9 p 10 p 11 p 12 p 13 p 14 p 15 u v

46 45 Bézier patch (step 1) Evaluate all four of the u-direction Bézier curves at u, to get points q 0 … q 3 p0p0 p1p1 p2p2 p3p3 p4p4 p5p5 p6p6 p7p7 p8p8 p9p9 p 10 p 11 p 12 p 13 p 14 p 15 u v q0q0 q1q1 q2q2 q3q3

47 46 Bézier patch (step 2) Consider that points q 0 … q 3 define a Bézier curve; evaluate it at v p0p0 p1p1 p2p2 p3p3 p4p4 p5p5 p6p6 p7p7 p8p8 p9p9 p 10 p 11 p 12 p 13 p 14 p 15 u v q0q0 q1q1 q2q2 q3q3 x

48 47 Bézier patch (either order) Sure enough, you get the same result in either order. p0p0 p1p1 p2p2 p3p3 p4p4 p5p5 p6p6 p7p7 p8p8 p9p9 p 10 p 11 p 12 p 13 p 14 p 15 u v r0r0 r1r1 r2r2 r3r3 x q0q0 q1q1 q2q2 q3q3

49 48 Bézier patch Properties: Convex hull: any point on the surface will fall within the convex hull of the control points Interpolates 4 corner points. Approximates other 12 points, which act as “handles” The boundaries of the patch are the Bézier curves defined by the points on the mesh edges The parametric curves are all Bézier curves

50 49 Evaluating a Bézier patch Most straightforward: follow the 2-step construction Lets you evaluate patch using existing methods for evaluting curves Won’t write out the weighted average or polynomial forms But can do matrix form…

51 50 Bézier patch, matrix form

52 51 Bézier patch, matrix form C x stores the coefficients of the bicubic equation for x C y stores the coefficients of the bicubic equation for y C z stores the coefficients of the bicubic equation for z G x stores the geometry ( x components of the control points) G y stores the geometry ( y components of the control points) G z stores the geometry ( z components of the control points) B Bez is the basis matrix (Bézier basis) U and V are the vectors formed from the powers of u and v Compact notation Leads to efficient method of computation Can take advantage of hardware support for 4x4 matrix arithmetic

53 52 Tangents of Bézier patch The “q” and “r” curves we constructed are actually the parametric curves at x(u,v) Remember, tangents to surface = tangents to parametric curves So we can compute the tangents using the same construction curves Notice that the tangent in the u direction is for the curve that varies in u, i.e. for the “r” curve; Similarly, the tangent in the v direction is for the “q” curve. (Get the normal as usual by taking cross product of the tangents) p0p0 p1p1 p2p2 p3p3 p4p4 p5p5 p6p6 p7p7 p8p8 p9p9 p 10 p 11 p 12 p 13 p 14 p 15 u v r0r0 r1r1 r2r2 r3r3 x q0q0 q1q1 q2q2 q3q3

54 53 Tangents of Bézier patch, construction p0p0 p1p1 p2p2 p3p3 p4p4 p5p5 p6p6 p7p7 p8p8 p9p9 p 10 p 11 p 12 p 13 p 14 p 15 u v r0r0 r1r1 r2r2 r3r3 x q0q0 q1q1 q2q2 q3q3

55 54 Tangents of Bézier patch, matrix form The matrix form makes it easy to evaluate the tangents directly :

56 55 Tessellating a Bézier patch Uniform tessellation is most straightforward Evaluate points on a grid Compute tangents at each point, take cross product to get per-vertex normal Draw triangle strips (several choices of direction) Adaptive tessellation/recursive subdivision Potential for “cracks” if patches on opposite sides of an edge divide differently Tricky to get right, but can be done.

57 56 Building a surface from Bézier patches Lay out grid of adjacent meshes For C 0 continuity, must share points on the edge Each edge of a Bézier patch is a Bézier curve based only on the edge mesh points So if adjacent meshes share edge points, the patches will line up exactly But we have a crease…

58 57 C 1 continuity across Bézier edges We want the parametric curves that cross each edge to have C 1 continuity So the handles must be equal-and-opposite across the edge: http://www.spiritone.com/~english/cyclopedia/patches.html

59 58 Modeling with Bézier patches Original Utah teapot specified as Bézier Patches

60 59 Modeling Headaches Original Teapot isn’t “watertight” spout & handle intersect with body no bottom hole in spout gap between lid and body Rectangular topology makes it hard to: join or abut curved pieces build surfaces with holes build surfaces with awkward topology or structure

61 60 Advanced surface modeling B-spline patches For the same reason as using B-spline curves More uniform behavior Better mathematical properties Doesn’t interpolate any control points

62 61 Advanced surface modeling NURBS surfaces. Can take on more shapes conic sections kinks Can blend, merge, fillet, … Still has rectangular topology, though

63 62 Advanced surface modeling Trim curves: cut away part of surface Implement as part of tessellation/rendering And/or construct new geometry

64 63 Subdivision Surfaces Arbitrary mesh, not rectangular topology Not parametric No u,v parameters Can make surfaces with arbitrary topology or connectivity Work by recursively subdividing mesh faces Per-vertex annotation for weights, corners, creases Used in particular for character animation: One surface rather than collection of patches Can deform geometry without creating cracks

65 64 Done Next class: Scan Conversion Midterm review Class after that: Midterm!


Download ppt "#8: Curves and Curved Surfaces CSE167: Computer Graphics Instructor: Ronen Barzel UCSD, Winter 2006."

Similar presentations


Ads by Google