1 / 72

Bezier and Spline Curves and Surfaces - Chapter 11 modified by Ray Wisman rwisman@ius

Bezier and Spline Curves and Surfaces - Chapter 11 modified by Ray Wisman rwisman@ius.edu. Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico. Objectives. Introduce the Bezier curves and surfaces Derive the required matrices

kita
Télécharger la présentation

Bezier and Spline Curves and Surfaces - Chapter 11 modified by Ray Wisman rwisman@ius

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. Bezier and Spline Curves and Surfaces - Chapter 11 modified by Ray Wisman rwisman@ius.edu Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

  2. Objectives • Introduce the Bezier curves and surfaces • Derive the required matrices • Introduce the B-spline and compare it to the standard cubic Bezier

  3. Comparison Main three types of curves given 4 control points Hermite/Bezier B Spline Interpolating

  4. Bezier’s Idea • In graphics and CAD, we do not usually have derivative data • Bezier suggested using the same 4 data points as with the cubic interpolating curve to approximate the derivatives in the Hermite form

  5. Bezier’s Idea • Cubic Bezier controlled by 4 points. • Interpolates first and last. • Beginning (final) derivatives approximated as 1/3 the vectors between the first (last) two points. • Seldom havederivativesavailable • Do have points

  6. Bezier Examples • Segments of degree 2-6. • X’s are control points • Lines shown connecting control points. • End points always on curve.

  7. Variation Diminishing Property of Bezier Curves • A line intersects curve no more than it intersects line segments connecting control points. • Means that if control polygon has no wiggles, the curve will not either.

  8. Connected Bezier Curves • Two Bezier segments can connect to form a C1 spline. • C0 if connected, p3 = q0. • C1 spline because vector between last two points of first segment is equal to vector between first two points of last segment. • C1 requires p2 collinear with q1, nota normal Bezier constraint p2 p3=q0 q1

  9. Useful Bezier Properties • Curve bounded by convex hull of control points • If control polygon has no wiggles, the curve will not either. • Curves are symmetric, reversing the control point order yields same curve, with reversed parameterization (i.e. u). • Curves are affine invariant. Translating, rotating, scaling or skewing control points is same as on curve itself. • There are good, simple algorithms for evaluating and subdividing Bezier curves into pieces that are Bezier curves. Useful for rendering Bezier curves with line segments and determining intersection of curves.

  10. Approximating Derivatives p2 p1 p2 located at u=2/3 p1 located at u=1/3 slope p’(1) slope p’(0) p3 p0 u

  11. Equations Interpolating conditions are the same as Hermite f(0) = p(0) = p0 = c0 f(1) = p(1) = p3 = c0+c1+c2+c3 Approximating derivative conditions based on control points f’(0) = p’(0) = 3(p1-p0) = c1 f’(1) = p’(1) = 3(p3-p2) = c1+2c2+3c3 Bezier constraints as control points:

  12. Equations Hermite Basis: Bezier Constraints: Determine Bezier Basis MB for: c=MBp

  13. Bezier Matrix for Degree 3 p(u)=(1-3u+3u2-u3)p0+(3u+6u2-3u3)p1+(3u2-3u3)p2+(u3)p3 b0=1-3u+3u2-u3 b1=3u+6u2-3u3 b2=3u2-3u3 b3=u3 p(u) = uTMBp = b(u)Tp 1-3u+3u2 -u3 + 3u+6u2-3u3 + 3u2-3u3+ u3=1+0u+0u2+0u3 blending functions

  14. Blending Functions p(u) = uTMBp = b(u)Tp = b0(u)p0 +b1(u)p1+b2(u)p2+b3(u)p3 b3 b0 b1 b2 Example: At u=[0,1], contributions by b0,1,2,3 sums to 1 Note that all zeros are at 0 or 1 which forces the functions to be smooth (no wiggles) over [0,1]

  15. Bernstein Polynomials • Bezier blending functions are a special case of the Bernstein polynomials • These polynomials give the blending polynomials for any degree Bezier form • All zeros at 0 and 1 • For any degree they all sum to 1 • They are all between 0 and 1 inside (0,1) • 0<bid(u) for 0<u<1

  16. Bernstein PolynomialsCubic Example • Cubic Bezier special case of Bernstein polynomials, d=3 Simplifies determining blending functions.

  17. Convex Hull Property • is a convex sum • Convex hull is smallest convex object that includes set of points • The properties of the Bernstein polynomials ensure that all Bezier curves lie in the convex hull of their control points • Hence, even though we do not interpolate all the data, we cannot be too far away p1 p2 convex hull Bezier curve p3 p0

  18. Example RunDownload Bezier Patches Using same data arrayP=[pij] as with interpolating form Patch lies in convex hull 16 points 4 b(v) 4 b(u)

  19. Analysis • Bezier form is much smoother than interpolating form • Derivatives are not continuous at join points because use different approximations on left and right, only C0 • Can we do better with Bezier? • Go to higher order Bezier • More work • Derivative continuity still only approximate • Supported by OpenGL • Use smaller interval and more polynomial segments • Apply different conditions • Tricky without letting order increase

  20. B-Splines • Basis splines: use the data at p=[pi-2pi-1 pipi+1]T to define curve only between pi-1and pi • Method for approximating a set of n points with a curve made up of polynomials of degree d-1 that gives Cd-2 continuity • Can apply more continuity conditions to each segment • For cubics, we can have continuity of function, first and second derivatives at join points • Cost is 3 times as much work for curves • Add one new point each time rather than three • For surfaces, we do 9 times as much work

  21. Comparison Bezier curves have 1 common point. Add 3 new points for each new curve. B-Splines achieve smoother joints by 3 common points. Add 1 new point for each new curve. joint joint Hermite/Bezier B Spline

  22. B-Splines • Purpose is to join curves so that the joints are smooth. • Method is to overlap control points. • Evaluate u=[0,1] between 2 control points. • Example: • Points: {p0, p1, p2, p3, p4} • Curve q=[p0, p1, p2, p3] • Curve p=[p1, p2, p3, p4] • p(0)=p2=q(1) • Evaluate u=[0,1] for p={p2, p3} and q={p1, p2} • Conditions where p(0)=q(1) requires continuity at joint. • Satisfied by: • p(0)=q(1)= 1/6(p1+4p2+p3) p’(0)=q’(1)= 1/2(p3-p1) q(1) p0 p1 p3 p(0) p2 p4

  23. B-SplinesQuadratic Example Control points p1, p2, p3 for curve p(u), u=[0,1]. Adding control point p4 for curve q(u), u=[0,1]. p(1) p(1) q(0) p3 p2 p2 p3 p(0) q(1) p(0) p1 p4 p1

  24. B-Splines • General representation of a function as a linear combination of other functions, where pi are coefficients and bi are the basis functions • B-splines where bi,d are the basis functions of d-1 degree • Each B-spline or basis function made up of set of d polynomials each of degree d-1. • If coefficients are points (2 or 3D) called control points.

  25. B-Splines Properties • Local modification of a B-spline curve. • Changing one of the control points in (a) produces curve (b) which is modified only in the neighborhood of the altered control point.

  26. Linear B-Splines Exampled=2 t t • Knot vector = {1, 2, 3, 4 } • b1,2 defined on knots {1, 2, 3}, d=2 intervals1-2, 2-3. • b2,2 defined on knots {2, 3, 4}, d=2 intervals 2-3, 3-4. • Both non-zero only over interval 2-3

  27. Linear B-Splines Example t t d=2 subintervals per blending function, knots = {1, 2, 3, 4} b1,2(t) subintervals 1-2, 2-3 b2,2(t) subintervals 2-3, 3-4 b1,2(1)=0 b1,2(2)=1 b1,2(3)=0 b2,2(2)=0 b2,2(3)=1 b2,2(4)=0

  28. Linear B-Splines Exampled=2 1.75 2.75 t 1.75 2.75 t t specifies knot subinterval, ranges from 1 to 4, knots = {1,2,3,4} 0bi,2(t)1 b1,2 (1.75) = 1.75-1 = .75 b1,2 (2.75)=2-2.75+1=.25 b2,2 (1.75) = 0 b2,2 (2.75) = 2.75-2 = .75 bi,2 sums to 1 only on 2-3 subinterval.

  29. Linear B-Splines Exampled=2 t t Only valid on interval t = [2,3] bi,2 sums to 1 only on 2-3 subinterval.

  30. Linear B-Splines Exampled=2 Both blending functions non-zero on interval t=[2,3] Blending functions must sum to 1. Interval defines start and end of line. p1=(1,3), p2=(2,5) f(2)= p1b1,2 (2)+ p2b2,2 (2)=(1,3)*1+(2,5)*0=(1,3) f(3)= p1b1,2 (3)+ p2b2,2 (3)=(1,3)*0+(2,5)*1=(2,5) f(2) f(3) p1(1,3) p2(2,5)

  31. Linear B-Splines Exampled=2 1.5 2.5 t 1.5 2.5 t f(1.5) f(2) f(2.5) f(3) (.5,1.5) p1(1,3) p2(2,5) f(1.5)= p1b1,2 (1.5)+ p2b2,2 (1.5)=(1,3)*.5+(2,5)*0=(.5, 1.5) f(2.5)= p1b1,2 (2.5)+ p2b2,2 (2.5)=(1,3)*.5+(2,5)*.5=(.5, 1.5)+(1,2.5) =(1.5,4)

  32. Linear B-Splines Exampled=2 t • Each bi,2 a first-degree (linear) B-spline with d=2 subintervals. • Knot vector = {1, 2, 3, 4 } defines subintervals 1-2, 2-3, 3-4. • Defined first knot of first B-spline interval, b1,2, at i=1. • Here, iterate over B-splines or coefficients by i=1 to 2 for t=[2,3]

  33. B-Splines Properties • Each B-spline has d+1 knots, first-degree (linear) d=2 has 3 knots • Each B-spline is zero before first and after last knot • Overall spline has local control because each coefficient is multiplied by one B-spline, each non-zero only between the d+1 knots • For example, p1b1,2(t) non-zero only over knot subintervals 1-2 and 2-3 • Each B-spline is Cd-2 (C0 here) continuous, overall spline is then Cd-2 (i.e. consider derivatives). • B-splines set sum to 1 between knots d and n+1, (i.e. where nonzero), affine control points transforms (e.g rotating) will transform entire curve.

  34. More B-Splines Properties • The polynomial curve has degree d-1 and is C(d-2) continuous over u. • For n+1 control points, curve described by n+1 blending functions. • Each blending function Bk,d defined over d subintervals of total range of u starting at knot uk . • Range of parameter u divided into n+d subintervals by the n+d+1 values specified in the knot vector. • With knot values {u0,u1,…un+d} resulting B-spline curve defined only in interval from knot value ud-1 up to knot un+1. • For any u in interval from knot value ud-1 to un+1 • Each section of the spline (between two consecutive knot values) is influenced by d control values. • Any one control point can influence the shape of at most d curve sections.

  35. Uniform Quadratic B-Splinesd=3 • b2,3 made up of 3 quadratic pieces (d=3, quadratic degree=2) • Pieces between d=3 intervals, 2-3, 3-4 and 4-5 • Nonzero only within 2-5 • d+1=4 knots • C(d-2) = C(3-2) = C1 continuous, joint slope equal

  36. Uniform Quadratic B-SplinesIntervals d=3 • b2,3 defined over intervals 2-3, 3-4, 4-5 • Note t converts 0u1 • Examples: b2,3(2)=1/2(0)2 = 0 if 22<3 u=2-2=0b2,3(3)=-02+0+1/2 = 1/2 if 2+13<4 u=3-(2+1)=0 t

  37. Uniform Quadratic B-SplinesDownload example b1 b2 b3 b4 b5 b6 b7 • Set of 7 B-splines with d=3 and uniform knot spacing • n+1=3 (number control points) • Overall summing of B-splines at most d=3 nonzero at any time, the 1st, 2nd and 3rd intervals, i to i+1, i+1 to i+2 and i+2 to i+3 • Can think of any piece of overall function as made up of d degree d-1 polynomials that depend on d coefficients • For d=3:

  38. For control points p2, p3, p4 For control points p1, p2, p3

  39. b1 b2 b3 t Control points p1, p2, p3 using b1, b2, b3: All defined only over t=[3,4]. p3(1,1,0) p2(-1,1,0) f(4) f(3) p1(-1,-1,0)

  40. b1 b2 b3 b4 t Control points p1, p2, p3 using b1, b2, b3: All defined only over t=[3,4]. Adjacent B-splinescurves share all but two control points. Joint smooth because C1 continuity. Adding control point p4 using b2, b3, b4: All defined only over t=[4,5]. p3(1,1,0) p2(-1,1,0) p3(1,1,0) p2(-1,1,0) f(4) f(4) f(3) f(5) f(3) p1(-1,-1,0) p4(1,-1,0) p1(-1,-1,0)

  41. b1 b2 b3 b4 b5 b6 t Control points p1, p2, p3, p4, p5=p1, p6=p2 using b1, b2, b3, b4, b5, b6 Defined over t=[3,7]. Create 4 curves using defined range: Knots: {1,2,3,4,5,6,7,8,9} d=3, n=4; defines curve over 4 knots {d to d+n} 3-4, 4-5, 5-6, 6-7 t=[3,4] p1, p2, p3 t=[4,5] p2, p3, p4 t=[5,6] p3, p4, p5 t=[6,7] p4, p5, p6 p3(1,1,0) p6 =p2(-1,1,0) f(4) f(3) f(7) f(5) f(6) p5 =p1(-1,-1,0) p4(1,-1,0)

  42. OpenGL Knot Example • Much reference to the knot vector because used to describe curves in OpenGL. The following example recreates the quadratic B-spline circle but uses the Bezier basis supported by OpenGL. The same 6 control points are also used. • OpenGL needs data on the control points and the knots. • GLfloatcpts[6][3] = {{-1,-1,0},{-1,1,0},{1,1,0},{1,-1,0},{-1,-1,0},{-1,1,0}}; • GLfloat Knots[] = {1,2,3,4,5,6,7,8,9}; • GLUnurbsObj *pNurb = gluNewNurbsRenderer(); // Nurbs object • gluNurbsProperty(pNurb, GLU_SAMPLING_TOLERANCE, 100.0f); • gluNurbsProperty(pNurb, GLU_DISPLAY_MODE, (GLfloat)GLU_FILL);

  43. OpenGL Knot Example • The remainder is telling OpenGL how to generate the curve from the control points and knots. • pNurb = gluNewNurbsRenderer(); • gluNurbsProperty(pNurb, GLU_SAMPLING_TOLERANCE, 100.0f); • gluNurbsProperty(pNurb, GLU_DISPLAY_MODE, (GLfloat)GLU_FILL); • gluBeginCurve(pNurb); // Render the NURB • gluNurbsCurve(pNurb, • 9, Knots, // # and Knots list • 3, // # elements/point • cpts, // control points • 3, // # intervals d • GL_MAP1_VERTEX_3); • gluEndCurve(pNurb);

  44. Uniform Quadratic B-SplinesExample b1 b2 b3 b4 b5 b6 b7 t • 7 control points • 7 quadratic B-splines • 5 curves • Set of 7 control points to define a 5 segment curve requires 7 B-splines • Using d=3 and uniform knot spacing {1,2,3,4,5,6,7,8,9,10} • n+d+1 (10) knots • Sum of B-splines is 1 over range d to n+1 (knots 3 through 8) f(3) f(8)

  45. B-Splines Blending Functions • General expression for B-spline. • Each blending function defined over d subintervals of a total range u. • Values of uminand umaxdepend upon number of control points, the same number of blending functions

  46. B-Splines Blending FunctionsCox-deBoors Recurrence • Blending functions for B-spline defined by Cox-deBoors recurrence: • Defined in terms of d (number of blending function subintervals) • Each subinterval endpoint uj referred to as a knot. Entire set of selected endpoints called a knot vector. • Can choose any value for knots subject to uj uj+1 (increasing order)

  47. Uniform Periodic B-Splines • When knot spacing constant called uniform B-spline. {-1.5, -1.0, -0.5, 0, 0.5, 1, 1.5, 2.0} • Often knots are normalized to range between 0 and 1. {0, 0.2, 0.4, 0.6, 0.8, 1.0} • Convenient for start at 0 and separation of 1. {0, 1, 2, 3, 4, 5, 6, 7} • Uniform B-splines have periodic blending functions. • For given values of n and d all blending functions same shape. Each successive a shifted version of previous. • Where u is the interval between adjacent knots.

  48. Periodic blending function for n=d=3 and integer uniform knot vector {0,1,2,3,4,5,6}

  49. Periodic blending function for n=d=3 and integer uniform knot vector {0,1,2,3,4,5,6} B1 B0 B3 B2 • Blending function B0 spans d=3 intervals, knots 0-1, 1-2, 2-3 • Knot vector {0,1,2,3,4,5,6} • Range of parameter u is 0 to 6 with n+d=3+3=6 subintervals. • u selects the appropriate knot subinterval.

  50. Blending function B0 spans d=3 intervals, knots 0-1, 1-2, 2-3 • 4 control points. • Curve defined over 0-1, 1-2, 2-3, 3-4, 4-5, 5-6 B0 B1 B2 B3 p(2) p(4)

More Related