Download presentation

Presentation is loading. Please wait.

Published byAmy Leman Modified about 1 year ago

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

2
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 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

3
Representations of Curves Problems with series of points used to model a curve Piecewise linear - Does not accurately model a smooth linePiecewise linear - Does not accurately model a smooth line It’s tediousIt’s tedious Expensive to manipulate curve because all points must be repositionedExpensive to manipulate curve because all points must be repositioned Instead, model curve as piecewise-polynomial x = x(t), y = y(t), z = z(t)x = x(t), y = y(t), z = z(t) –where x(), y(), z() are polynomials Problems with series of points used to model a curve Piecewise linear - Does not accurately model a smooth linePiecewise linear - Does not accurately model a smooth line It’s tediousIt’s tedious Expensive to manipulate curve because all points must be repositionedExpensive to manipulate curve because all points must be repositioned Instead, model curve as piecewise-polynomial x = x(t), y = y(t), z = z(t)x = x(t), y = y(t), z = z(t) –where x(), y(), z() are polynomials

4
Specifying CurvesSpecifying Curves (hyperlink) Control Points A set of points that influence the curve’s shapeA set of points that influence the curve’s shapeKnots Control points that lie on the curveControl points that lie on the curve Interpolating Splines Curves that pass through the control points (knots)Curves that pass through the control points (knots) Approximating Splines Control points merely influence shapeControl points merely influence shape Control Points A set of points that influence the curve’s shapeA set of points that influence the curve’s shapeKnots Control points that lie on the curveControl points that lie on the curve Interpolating Splines Curves that pass through the control points (knots)Curves that pass through the control points (knots) Approximating Splines Control points merely influence shapeControl points merely influence shape

5
Parametric Curves Very flexible representation They are not required to be functions They can be multivalued with respect to any dimensionThey can be multivalued with respect to any dimension Very flexible representation They are not required to be functions They can be multivalued with respect to any dimensionThey can be multivalued with respect to any dimension

6
Cubic Polynomials x(t) = a x t 3 + b x t 2 + c x t + d x Similarly for y(t) and z(t)Similarly for y(t) and z(t) Let t: (0 <= t <= 1) Let T = [t 3 t 2 t 1] Coefficient Matrix C Curve: Q(t) = T*C Curve: Q(t) = T*C x(t) = a x t 3 + b x t 2 + c x t + d x Similarly for y(t) and z(t)Similarly for y(t) and z(t) Let t: (0 <= t <= 1) Let T = [t 3 t 2 t 1] Coefficient Matrix C Curve: Q(t) = T*C Curve: Q(t) = T*C

7
Parametric Curves How do we find the tangent to a curve? If f(x) = x 2 – 4If f(x) = x 2 – 4 –tangent at (x=3) is f’(x) = 2 (x) – 4 = 2 (3) - 4 How do we find the tangent to a curve? If f(x) = x 2 – 4If f(x) = x 2 – 4 –tangent at (x=3) is f’(x) = 2 (x) – 4 = 2 (3) - 4 Derivative of Q(t) is the tangent vector at t: d/dt Q(t) = Q’(t) = d/dt T * C = [3t 2 2t 1 0] * Cd/dt Q(t) = Q’(t) = d/dt T * C = [3t 2 2t 1 0] * C Derivative of Q(t) is the tangent vector at t: d/dt Q(t) = Q’(t) = d/dt T * C = [3t 2 2t 1 0] * Cd/dt Q(t) = Q’(t) = d/dt T * C = [3t 2 2t 1 0] * C

8
Piecewise Curve Segments One curve constructed by connecting many smaller segments end- to-end Continuity describes the joint C 1 is tangent continuity (velocity)C 1 is tangent continuity (velocity) C 2 is 2 nd derivative continuity (acceleration)C 2 is 2 nd derivative continuity (acceleration) One curve constructed by connecting many smaller segments end- to-end Continuity describes the joint C 1 is tangent continuity (velocity)C 1 is tangent continuity (velocity) C 2 is 2 nd derivative continuity (acceleration)C 2 is 2 nd derivative continuity (acceleration)

9
Continuity of Curves If direction (but not necessarily magnitude) of tangent matches G 1 geometric continuityG 1 geometric continuity The tangent value at the end of one curve is proportional to the tangent value of the beginning of the next curveThe tangent value at the end of one curve is proportional to the tangent value of the beginning of the next curve Matching direction and magnitude of d n / dt n –C n continous If direction (but not necessarily magnitude) of tangent matches G 1 geometric continuityG 1 geometric continuity The tangent value at the end of one curve is proportional to the tangent value of the beginning of the next curveThe tangent value at the end of one curve is proportional to the tangent value of the beginning of the next curve Matching direction and magnitude of d n / dt n –C n continous

10
Parametric Cubic Curves In order to assure C 2 continuity, curves must be of at least degree 3 Here is the parametric definition of a cubic (degree 3) spline in two dimensions How do we extend it to three dimensions? In order to assure C 2 continuity, curves must be of at least degree 3 Here is the parametric definition of a cubic (degree 3) spline in two dimensions How do we extend it to three dimensions?

11
Parametric Cubic Splines Can represent this as a matrix too

12
Coefficients So how do we select the coefficients? [a x b x c x d x ] and [a y b y c y d y ] must satisfy the constraints defined by the knots and the continuity conditions[a x b x c x d x ] and [a y b y c y d y ] must satisfy the constraints defined by the knots and the continuity conditions So how do we select the coefficients? [a x b x c x d x ] and [a y b y c y d y ] must satisfy the constraints defined by the knots and the continuity conditions[a x b x c x d x ] and [a y b y c y d y ] must satisfy the constraints defined by the knots and the continuity conditions

13
Parametric Curves Difficult to conceptualize curve as x(t) = a x t 3 + b x t 2 + c x t + d x (artists don’t think in terms of coefficients of cubics) Instead, define curve as weighted combination of 4 well-defined cubic polynomials (wait a second! Artists don’t think this way either!) Each curve type defines different cubic polynomials and weighting schemes Difficult to conceptualize curve as x(t) = a x t 3 + b x t 2 + c x t + d x (artists don’t think in terms of coefficients of cubics) Instead, define curve as weighted combination of 4 well-defined cubic polynomials (wait a second! Artists don’t think this way either!) Each curve type defines different cubic polynomials and weighting schemes

14
Parametric Curves Hermite – two endpoints and two endpoint tangent vectors Bezier - two endpoints and two other points that define the endpoint tangent vectors Splines – four control points C1 and C2 continuity at the join pointsC1 and C2 continuity at the join points Come close to their control points, but not guaranteed to touch themCome close to their control points, but not guaranteed to touch them Examples of Splines Examples of Splines Hermite – two endpoints and two endpoint tangent vectors Bezier - two endpoints and two other points that define the endpoint tangent vectors Splines – four control points C1 and C2 continuity at the join pointsC1 and C2 continuity at the join points Come close to their control points, but not guaranteed to touch themCome close to their control points, but not guaranteed to touch them Examples of Splines Examples of Splines

15
Hermite Cubic Splines An example of knot and continuity constraints

16
Hermite Cubic Splines One cubic curve for each dimension A curve constrained to x/y-plane has two curves: One cubic curve for each dimension A curve constrained to x/y-plane has two curves:

17
Hermite Cubic Splines A 2-D Hermite Cubic Spline is defined by eight parameters: a, b, c, d, e, f, g, h How do we convert the intuitive endpoint constraints into these (relatively) unintuitive eight parameters? We know: (x, y) position at t = 0, p 1(x, y) position at t = 0, p 1 (x, y) position at t = 1, p 2(x, y) position at t = 1, p 2 (x, y) derivative at t = 0, dp/dt(x, y) derivative at t = 0, dp/dt (x, y) derivative at t = 1, dp/dt(x, y) derivative at t = 1, dp/dt A 2-D Hermite Cubic Spline is defined by eight parameters: a, b, c, d, e, f, g, h How do we convert the intuitive endpoint constraints into these (relatively) unintuitive eight parameters? We know: (x, y) position at t = 0, p 1(x, y) position at t = 0, p 1 (x, y) position at t = 1, p 2(x, y) position at t = 1, p 2 (x, y) derivative at t = 0, dp/dt(x, y) derivative at t = 0, dp/dt (x, y) derivative at t = 1, dp/dt(x, y) derivative at t = 1, dp/dt

18
Hermite Cubic Spline We know: (x, y) position at t = 0, p 1(x, y) position at t = 0, p 1 We know: (x, y) position at t = 0, p 1(x, y) position at t = 0, p 1

19
Hermite Cubic Spline We know: (x, y) position at t = 1, p 2(x, y) position at t = 1, p 2 We know: (x, y) position at t = 1, p 2(x, y) position at t = 1, p 2

20
Hermite Cubic Splines So far we have four equations, but we have eight unknowns Use the derivatives So far we have four equations, but we have eight unknowns Use the derivatives

21
Hermite Cubic Spline We know: (x, y) derivative at t = 0, dp/dt(x, y) derivative at t = 0, dp/dt We know: (x, y) derivative at t = 0, dp/dt(x, y) derivative at t = 0, dp/dt

22
Hermite Cubic Spline We know: (x, y) derivative at t = 1, dp/dt(x, y) derivative at t = 1, dp/dt We know: (x, y) derivative at t = 1, dp/dt(x, y) derivative at t = 1, dp/dt

23
Hermite Specification Matrix equation for Hermite Curve t = 0 t = 1 t = 0 t = 1 t 3 t 2 t 1 t 0 p1p1 p2p2 r p 1 r p 2

24
Solve Hermite Matrix

25
Spline and Geometry Matrices M Hermite G Hermite

26
Resulting Hermite Spline Equation

27
Demonstration Hermite

28
Sample Hermite Curves

29
Blending Functions By multiplying first two matrices in lower-left equation, you have four functions of ‘t’ that blend the four control parameters These are blending functions By multiplying first two matrices in lower-left equation, you have four functions of ‘t’ that blend the four control parameters These are blending functions

30
Hermite Blending Functions If you plot the blending functions on the parameter ‘t’

31
Hermite Blending Functions Remember, each blending function reflects influence of P 1, P 2, P 1, P 2 on spline’s shape

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

33
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 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

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

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

36
Bézier Basis and Geometry Matrices Matrix Form But why is M Bezier a good basis matrix? Matrix Form But why is M Bezier a good basis matrix?

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

38
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 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

39
Bézier Curves Will always remain within bounding region defined by control points

40
Bézier Curves Bezier

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

42
B-Spline Curve Start with a sequence of control points Select four from middle of sequence (p i-2, p i-1, p i, p i+1 ) d Bezier and Hermite goes between p i-2 and p i+1Bezier and Hermite goes between p i-2 and p i+1 B-Spline doesn’t interpolate (touch) any of them but approximates the going through p i-1 and p iB-Spline doesn’t interpolate (touch) any of them but approximates the going through p i-1 and p i Start with a sequence of control points Select four from middle of sequence (p i-2, p i-1, p i, p i+1 ) d Bezier and Hermite goes between p i-2 and p i+1Bezier and Hermite goes between p i-2 and p i+1 B-Spline doesn’t interpolate (touch) any of them but approximates the going through p i-1 and p iB-Spline doesn’t interpolate (touch) any of them but approximates the going through p i-1 and p i p0p0p0p0 p0p0p0p0 p4p4p4p4 p4p4p4p4 p2p2p2p2 p2p2p2p2 p1p1p1p1 p1p1p1p1 p3p3p3p3 p3p3p3p3 p5p5p5p5 p5p5p5p5 p6p6p6p6 p6p6p6p6 Q3Q3Q3Q3 Q3Q3Q3Q3 Q4Q4Q4Q4 Q4Q4Q4Q4 Q5Q5Q5Q5 Q5Q5Q5Q5 Q6Q6Q6Q6 Q6Q6Q6Q6

43
Uniform B-Splines Approximating Splines Approximates n+1 control points P 0, P 1, …, P n, n ¸ 3 P 0, P 1, …, P n, n ¸ 3 Curve consists of n –2 cubic polynomial segments Q 3, Q 4, … Q nQ 3, Q 4, … Q n t varies along B-spline as Q i : t i <= t < t i+1 t i (i = integer) are knot points that join segment Q i-1 to Q i Curve is uniform because knots are spaced at equal intervals of parameter, t Approximating Splines Approximates n+1 control points P 0, P 1, …, P n, n ¸ 3 P 0, P 1, …, P n, n ¸ 3 Curve consists of n –2 cubic polynomial segments Q 3, Q 4, … Q nQ 3, Q 4, … Q n t varies along B-spline as Q i : t i <= t < t i+1 t i (i = integer) are knot points that join segment Q i-1 to Q i Curve is uniform because knots are spaced at equal intervals of parameter, t

44
Uniform B-Splines First curve segment, Q 3, is defined by first four control points Last curve segment, Q m, is defined by last four control points, P m-3, P m-2, P m-1, P m Each control point affects four curve segments First curve segment, Q 3, is defined by first four control points Last curve segment, Q m, is defined by last four control points, P m-3, P m-2, P m-1, P m Each control point affects four curve segments

45
B-spline Basis Matrix Formulate 16 equations to solve the 16 unknowns The 16 equations enforce the C 0, C 1, and C 2 continuity between adjoining segments, Q Formulate 16 equations to solve the 16 unknowns The 16 equations enforce the C 0, C 1, and C 2 continuity between adjoining segments, Q

46
B-Spline Basis Matrix Note the order of the rows in my M B-Spline is different from in the book Observe also that the order in which I number the points is differentObserve 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 matrixTherefore my matrix aligns with the book’s matrix if you reorder the points, and thus reorder the rows of the matrix Note the order of the rows in my M B-Spline is different from in the book Observe also that the order in which I number the points is differentObserve 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 matrixTherefore my matrix aligns with the book’s matrix if you reorder the points, and thus reorder the rows of the matrix

47
B-Spline Points along B-Spline are computed just as with Bezier Curves

48
B-Spline By far the most popular spline used C 0, C 1, and C 2 continuous By far the most popular spline used C 0, C 1, and C 2 continuous

49
B-Spline Locality of points

50
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 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

51
NURBs To generate three-dimension points Four B-Splines are usedFour 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)The 3-D point output by a NURB is the x, y, z coordinates divided by the weighting term (like homogeneous coordinates) To generate three-dimension points Four B-Splines are usedFour 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)The 3-D point output by a NURB is the x, y, z coordinates divided by the weighting term (like homogeneous coordinates)

52
What is a NURB? Nonuniform: The amount of parameter, t, that is used to model each curve segment varies Nonuniformity permits either C 2, C 1, or C 0 continuity at join points between curve segmentsNonuniformity permits either C 2, C 1, or C 0 continuity at join points between curve segments Nonuniformity permits control points to be added to middle of curveNonuniformity permits control points to be added to middle of curve Nonuniform: The amount of parameter, t, that is used to model each curve segment varies Nonuniformity permits either C 2, C 1, or C 0 continuity at join points between curve segmentsNonuniformity permits either C 2, C 1, or C 0 continuity at join points between curve segments Nonuniformity permits control points to be added to middle of curveNonuniformity permits control points to be added to middle of curve

53
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 pointsThis 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 individuallyIf 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 allB-spline is preserved under affine transformations, but that is all 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 pointsThis 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 individuallyIf 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 allB-spline is preserved under affine transformations, but that is all

54
Converting Between Splines Consider two spline basis formulations for two spline types

55
Converting Between Splines We can transform the control points from one spline basis to another

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

57
Rendering Splines Horner’s Method Incremental (Forward Difference) Method Subdivision Methods Horner’s Method Incremental (Forward Difference) Method Subdivision Methods

58
Horner’s Method Three multiplications Three additions Three multiplications Three additions

59
Forward Difference But this still is expensive to compute Solve for change at k ( k ) and change at k+1 ( k+1 )Solve for change at k ( k ) and change at k+1 ( k+1 ) Boot strap with initial values for x 0, 0, and 1Boot strap with initial values for x 0, 0, and 1 Compute x 3 by adding x 0 + 0 + 1Compute x 3 by adding x 0 + 0 + 1 But this still is expensive to compute Solve for change at k ( k ) and change at k+1 ( k+1 )Solve for change at k ( k ) and change at k+1 ( k+1 ) Boot strap with initial values for x 0, 0, and 1Boot strap with initial values for x 0, 0, and 1 Compute x 3 by adding x 0 + 0 + 1Compute x 3 by adding x 0 + 0 + 1

60
Subdivision Methods Bezier

61
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); }

Similar presentations

© 2016 SlidePlayer.com Inc.

All rights reserved.

Ads by Google