Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Graphics Inf4/MSc Computer Graphics Lecture 10 Curves and Surfaces I.

Similar presentations


Presentation on theme: "Computer Graphics Inf4/MSc Computer Graphics Lecture 10 Curves and Surfaces I."— Presentation transcript:

1 Computer Graphics Inf4/MSc Computer Graphics Lecture 10 Curves and Surfaces I

2 Computer Graphics Inf4/MSc 23/10/2007Lecture 102 Types of Curves Explicit: y = mx + b r = A r x + B r y + C r Implicit: Ax + By + C = 0 (x – x 0 ) 2 + (y – y 0 ) 2 – r 2 = 0 Parametric: x = x 0 + (x 1 – x 0 )t x = x 0 + rcos  y = y 0 + (y 1 – y 0 )t y = y 0 + rsin 

3 Computer Graphics Inf4/MSc 23/10/2007Lecture 103 Why parametric? Parametric curves are very flexible. They are not required to be functions –Curves can be multi-valued with respect to any coordinate system. Parameter count generally gives the object’s dimension. (x(u,v), y(u,v), z(u,v)) Coord functions independent.

4 Computer Graphics Inf4/MSc 23/10/2007Lecture 104 Specifying curves Control Points: –A set of points that influence the curve’s shape. Knots: –Control points that lie on the curve. Interpolating spline: –Curve passes through the control points. Approximating spline: –Control points merely influence shape.

5 Computer Graphics Inf4/MSc 23/10/2007Lecture 105 Piecewise curve segments We can represent an arbitrary length curve as a series of curves pieced together. But we will want to control how these curves fit together …

6 Computer Graphics Inf4/MSc 23/10/2007Lecture 106 Parametric Cubic Curves In order to assure C 2 continuity our functions must be of at least degree 3. This is also the lowest order to describe a non-planar curve. Cubic has 4 degrees of freedom and can control 4 things. Use polynomials: x(t) of degree n is a function of t. - y(t) and z(t) are similar and each is handled independently (why parametric is easier to handle than implicit form). That is:

7 Computer Graphics Inf4/MSc 23/10/2007Lecture 107 An Illustrative Example The whole story of parametric splines is in deriving their coefficients. How we do that, by satisfying constraints set by the knots and continuity conditions, is what classifies the spline system and distinguishes the different systems. Example: Cubic Hermite Splines

8 Computer Graphics Inf4/MSc 23/10/2007Lecture 108 Hermite splines 4 degrees of freedom, 2 at each end to control C 0 and C 1 continuity at each end. Polynomial can be specified by the position of, and gradient at, each endpoint of curve. Determine: x = X(t) in terms of x 0, x 0 /, x 1, x 1 / Now: X(t) = a 3 t 3 + a 2 t 2 + a 1 t + a 0 and X / (t) = 3a 3 t 2 + 2a 2 t + a 1

9 Computer Graphics Inf4/MSc 23/10/2007Lecture 109 Finding Hermite coefficients Substituting for t at each endpoint: x 0 = X(0) = a 0 x 0 / = X / (0) = a 1 x 1 = X(1) = a 3 + a 2 + a 1 + a 0 x 1 / = X / (1) = 3a 3 + 2a 2 + a 1 And the solution is: a 0 = x 0 a 1 = x 0 / a 2 = -3x 0 – 2x 0 / + 3x 1 – x 1 / a 3 = 2x 0 + x 0 / - 2x 1 + x 1 /

10 Computer Graphics Inf4/MSc 23/10/2007Lecture 1010 The Hermite matrix: M H The resultant polynomial can be expressed in matrix form: X(t) = t T M H q ( q is the control vector) We can now define a parametric polynomial for each coordinate required independently, ie. X(t), Y(t) and Z(t)

11 Computer Graphics Inf4/MSc 23/10/2007Lecture 1011 Hermite Basis (Blending) Functions x0x0 x1x1 x0/x0/ x1/x1/ The graph shows the shape of the four basis functions – often called blending functions. They are labelled with the elements of the control vector that they weight. Note that at each end only position is non-zero, so the curve must touch the endpoints

12 Computer Graphics Inf4/MSc 23/10/2007Lecture 1012 Family of Hermite curves. x(t) y(t) Note : Start points on left.

13 Computer Graphics Inf4/MSc 23/10/2007Lecture 1013 Displaying Hermite curves. Simple : –Loop through t – select step size to suit. –Plug x values into the geometry matrix. –Evaluate P(t)  x value for current position. –Repeat for y & z independently. –Draw line segment between current and previous point. Joining curves: –Coincident endpoints for C 0 continuity –Align tangent vectors for C 1 continuity.

14 Computer Graphics Inf4/MSc 23/10/2007Lecture 1014 Bézier Curves Hermite cubic curves are difficult to model – need to specify point and gradient. More intuitive to only specify points. Pierre Bézier specified 2 endpoints and 2 additional control points to specify the gradient at the endpoints. Can be derived from Hermite matrix: –Two end control points specify tangent

15 Computer Graphics Inf4/MSc 23/10/2007Lecture 1015 Bézier Curves P2P2 P1P1 P4P4 P3P3 P3P3 P4P4 P2P2 P1P1 Note the Convex Hull has been shown as a dashed line – use as a bounding extent for intersection purposes.

16 Computer Graphics Inf4/MSc 23/10/2007Lecture 1016 Bézier Matrix We must first define the blending functions. For a polynomial of order n (degree n-1), we have n control points with terms up to t n-1, as follows: f r is a blending function the coefficient of t r in the binomial expansion of (t+(1-t)) n-1

17 Computer Graphics Inf4/MSc 23/10/2007Lecture 1017 Bézier Matrix The cubic form is the most popular X(t) = t T M B q (M B is the Bézier matrix) With n=4 and r=0,1,2,3 we get: Similarly for Y(t) and Z(t)

18 Computer Graphics Inf4/MSc 23/10/2007Lecture 1018 Bézier blending functions This is how they look – Again the Convex Hull property holds, ie. The functions sum to 1 at any point along the curve. Endpoints have full weight The weights of each function is clear and the labels show the control points being weighted. q0q0 q3q3 q1q1 q2q2

19 Computer Graphics Inf4/MSc 23/10/2007Lecture 1019 Example Interpolation Spline. Catmull-Rom spline interpolates control points. The gradient at each control point is the vector between adjacent control points.

20 Computer Graphics Inf4/MSc 23/10/2007Lecture 1020 Uniform Nonrational B-Splines Cubic Bézier curves are joined together in the same way as Hermite curves for arbitrary length by joining short 4-point pieces with C 0 and C 1 order continuity. However cubic B-Splines can have any number of control points and any length of curve with C 0, C 1 and C 2 order continuity. Segments of the B-Spline, joined at knots, depend on a few adjacent control points which are shared between segments for continuity.

21 Computer Graphics Inf4/MSc 23/10/2007Lecture 1021 What are B-Splines? Consider a bi-infinite set of knots {t i } B-Splines are a set of local functions which together form a basis for certain classes of piecewise polynomial functions with these knots. Any piecewise polynomial of order k, degree k-1, with continuous (k-2)th derivative is a weighted sum of functions B ik from the set:

22 Computer Graphics Inf4/MSc 23/10/2007Lecture 1022 Parametric B-Spline curves B-Spline functions are used as blending functions: f i (t) = B i,k (t) Given control points: x 1 … x n And B-Splines: B i,k where i = 1 … n Then: Support of function X is t n < t < t n+k ie. the range over which X is non-zero.

23 Computer Graphics Inf4/MSc 23/10/2007Lecture 1023 Parametric B-Splines Also works for closed curve, ie. wrapped-round set of n knots.

24 Computer Graphics Inf4/MSc 23/10/2007Lecture 1024 What does a B-Spline look like? t0t0 t1t1 t2t2 t3t3 t4t4 1 They look rather like the shape above and there is one starting at each t. The one above is a cubic B-Spline with a support of 4 knot intervals. Thus within one interval there are portions of 4 splines which have influence.

25 Computer Graphics Inf4/MSc 23/10/2007Lecture 1025 B-Spline blending functions for one interval. t 1 1/6 4/6 f(t) Here again the functions hold the Convex Hull property. They are non-negative. There are four of them and therefore another 4x4 matrix as we’ve seen.

26 Computer Graphics Inf4/MSc 23/10/2007Lecture 1026 Uniform Non-rational B-Splines. For each i  4, there is a knot between Q i-1 and Q i at t = t i. Initial points at t 3 and t m+1 are also knots, so we have a total of m-1 knots. Knot. Control point. m = 9 (P 0..P 9 ) m-1 knots m+1 control points m-2 curve segments

27 Computer Graphics Inf4/MSc 23/10/2007Lecture 1027 Uniform Non-rational B-Splines. First segment Q 3 is defined by point P 0 through P 3 over the range t 3 = 0 to t 4 = 1. Knot. Control point. P1 P2 P3 P0 Q3Q3

28 Computer Graphics Inf4/MSc 23/10/2007Lecture 1028 Uniform Non-rational B-Splines. Second segment Q 4 is defined by point P 1 through P 4 over the range t 4 = 1 to t 5 = 2. Knot. Control point. Q4Q4 P1 P3 P4 P2

29 Computer Graphics Inf4/MSc 23/10/2007Lecture 1029 Reading for this lecture Foley et al. Chapter 11, section 11.2 up to and including Introductory text Chapter 9, section 9.2 up to and including section 9.2.4


Download ppt "Computer Graphics Inf4/MSc Computer Graphics Lecture 10 Curves and Surfaces I."

Similar presentations


Ads by Google