Upcoming SlideShare
×

# Curves

2,639 views

Published on

0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total views
2,639
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
130
0
Likes
0
Embeds 0
No embeds

No notes for slide

### Curves

1. 1. Unit 2 Bezier Curves & Surfaces© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63 1 Learning Objectives In this unit, we will cover the following topics: Curves Problems with complex curve Bezier Curve Advantages Cubic Bezier Curves B Splines More About B Splines Knot Vector Kinds of Knot Vector Exercise Summary© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 2 Curves? Straight lines are easy to store in a computer’s memory. The computer only has to remember the first and the last point. But what about curved lines?© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 3
2. 2. Computers can’t draw curves Curves are just lots of small straight lines joined up The more points/line segments that are used the smoother the curve.© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 4 Curve representation The basic problem we face is to represent the curve EASILY and EFFICIENTLY.© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 5 Curve representation (contd.) Storing a curve as many small straight line segments doesn’t work well when scaled inconvenient to have to specify so many points need lots of points to make the curve look smooth© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 6
3. 3. Curve representation (contd.) working out the equation that represents the curve difficult for complex curves moving an individual point requires re-calculation of the entire curve© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 7 Complex Curves SOLUTION ???© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 8 Solution For Complex Curves INTERPOLATION APPROXIMATION© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 9
4. 4. Interpolation vs. Approximation Curves Interpolation Approximation curve must pass through control curve is influenced by control points points© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 10 Review of Interpolation A method of constructing a function that crosses through a discrete set of known data points.© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 11 Interpolation vs. Approximation Curves© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 12
5. 5. Solution - Interpolation Define a small number of points Use a technique called “interpolation” to invent the extra points for us. Join the points with a series of (short) straight lines© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 13 Interpolation Curves Curve is constrained to pass through all control points Given points P0, P1, ... Pn, find lowest degree polynomial which passes through the points x(t) = an-1tn-1 + .... + a2t2 + a1t + a0 y(t) = bn-1tn-1 + .... + b2t2 + b1t + b0© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 14 Bezier Curves An alternative to interpolation splines M. Bezier was a French mathematician who worked for the Renault motor car company. He invented his curves to allow his firm’s computers to describe the shape of car bodies.© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 15
6. 6. Curves & Control Points Bezier curves are used in computer graphics to produce curves which appear reasonably smooth at all scales. Bezier curves use a construction due to Sergei Bernstein, in which the interpolating polynomials depend on certain control points.© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 16 Example : Curves & Control Points Each set of four points P0, P1, P2, P3 we associate a curve with the following properties: It starts at p0 and ends at p3. When it starts from p0 it heads directly towards p1, and when it arrives at p3 it is coming from the direction of p2. The entire curve is contained in the quadrilateral whose corners are the four given points© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 17 Bezier Curves© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 18
7. 7. Bezier Curves- Properties Not all of the control points are on the line – Some just attract it towards themselves Points have “influence” over the course of the line “Influence” (attraction) is calculated from a polynomial expression© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 19 Bezier Curves N+1 control points designated by the vectors pk = (xk,yk,zk) k=0,…n Thr order n Bezier Curve P(u) is given by P(u) = ∑pk Bk,,n(u) k= 0 to n© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 20 Problems with Bezier Curves A similar but different problem: Controlling the shape of curves. Problem: given some (control) points, produce and modify the shape of a curve passing through the first and last point. http://www.ibiblio.org/e-notes/Splines/Bezier.htm© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 21
8. 8. Solution Idea: Build functions that are combinations of some basic and simpler functions. Basic functions: B-splines Bernstein polynomials© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 22 Bernstein Polynomials Bernstein polynomials of degree n are defined by: For v = 0, 1, 2, …, n, In general there are N+1 Bernstein Polynomials of degree N. For example, the Bernstein Polynomials of degrees 1, 2, and 3 are: 1. B0,1(t) = 1-t, B1,1(t) = t; 2. B0,2(t) = (1-t)2, B1,2(t) = 2t(1-t), B2,2(t) = t2; 3. B0,3(t) = (1-t)3, B1,3(t) = 3t(1-t)2, B2,3(t)=3t2(1-t), B3,3(t) = t3;© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 23 Deriving the Basis Polynomials Write 1 = t + (1-t) and raise 1 to the third power for cubic splines (2 for quadratic, 4 for quartic, etc…) 1^3 = (t + (1-t))^3 = t^3 + 3t^2(1-t) + 3t(1-t)^2 + (1-t)^3 The basis functions are the four terms: B0(t) = (1-t)^3 B1(t) = 3t(1-t)^2 B2(t) = 3t^2(1-t) B3(t) = t^3© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 24
9. 9. Using the Basis Functions To use the Bernstein basis functions to make a spline we need 4 “control” points for a cubic. (3 for quadratic, 5 for quartic, etc…) Let (x0,y0), (x1,y1), (x2,y2), (x3,y3) be the “control”points The x and y coordinates of the cubic Bezier spline are given by: x(t) = x0B0(t) + x1B1(t) +x2B2(t) + x3B3(t) y(t) = y0B0(t) + y1B1(t) + y2B2(t) + y3B3(t) Where 0<= t <= 1.© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 25 Bernstein Polynomials Given a set of control points {Pi}Ni=0, where Pi = (xi, yi). A Bezier curve of degree N is: P(t) = Ni=0 PiBi,N(t), Where Bi,N(t), for I = 0, 1, …, N, are the Bernstein polynomials of degree N. P(t) is the Bezier curve Since Pi = (xi, yi) x(t) = Ni=0xiBi,N(t) and y(t) = Ni=0yiBi,N(t) The spline goes through (x0,y0) and (x3,y3) The tangent at those points is the line connecting (x0,y0) to (x1,y1) and (x3,y3) to (x2,y2). The positions of (x1,y1) and (x2,y2) determine the shape of the curve.© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 26 Bernstein Polynomials Example Find the Bezier curve which has the control points (2,2), (1,1.5), (3.5,0), (4,1). Substituting the x- and y-coordinates of the control points and N=3 into the x(t) and y(t) formulas on the previous slide yields x(t) = 2B0,3(t) + 1B1,3(t) + 3.5B2,3(t) + 4B3,3(t) y(t) = 2B0,3(t) + 1.5B1,3(t) + 0B2,3(t) + 1B3,3(t)© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 27
10. 10. Bernstein Polynomials Example Substitute the Bernstein polynomials of degree three into these formulas to get x(t) = 2(1 – t)3 + 3t(1 – t)2 + 10.5t2(1 – t) + 4t3 y(t) = 2(1-t)3 + 4.5t(1 – t)2 + t3 Simplify these formulas to yield the parametric equation: P(t) = (2 – 3t + 10.5t2 – 5.5t3, 2 – 1.5t – 3t2 + 3.5t3) where 0 < t < 1 P(t) is the Bezier curve© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 28 Cubic Bézier Curve 4 control points Curve passes through first & last control point Curve is tangent at P1 to (P1-P2) and at P4 to (P4-P3)© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 29 Cubic Bézier Curve© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 30
11. 11. Cubic Bézier Curve© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 31 Higher-Order Bézier Curves > 4 control points Bernstein Polynomials as the basis functions Bin(t) is Blending Function Every control point affects the entire curve – Not simply a local effect - More difficult to control for modeling© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 32 Composite Bezier Curves In practice, shapes are often constructed of multiple Bezier curves combined together. Allows for flexibility in constructing shapes. (Consecutive Bezier curves need not join smoothly.)© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 33
12. 12. Parametric equations for x(t),y(t)© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 34 Higher-Order Bézier Curves© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 35 Properties of Bezier Curves The degree of the bezier curve is one less than the number of control point defining it. N=control point-1 The curve generally follows the shape of the defining polygon (i.e. polygon formed by connecting the control points.)© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 36
13. 13. Advantages of Bezier Curves The Bezier Curve is always contained within the convex hull of its control points. This is extremely useful for collision detection, because a bounding box to the Bezier curve’s control points can be created very fast.© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 37 More About Bezier If we map every point on the Bezier curve with an affine map, the resulting points also form a Bezier curve. This is extremely useful in computer graphics, because if we have a curve in 3D-space and need to project it on a surface, the only thing we have to do is to project each control point. The same goes for rotation, mirroring, skewing etc.© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 38 More About Bezier (Cont’d) If we change a control point, the curve will mostly change around that control point. The other parts of the curve will change very little. This is one reason Bezier curves are used in CAD. If you change one control point a little, you don’t want the whole drawing to change.© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 39
14. 14. B SPLINE CURVES© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 40 An Introduction to B-Spline Curves Most shapes are simply too complicated to define using a single Bezier curve. A spline curve is a sequence of curve segments that are connected together to form a single continuous curve. Example, a piecewise collection of Bezier curves, connected end to end, can be called a spline curve© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 41 History behind Splines The word “spline” comes from the ship building industry, where it originally meant a thin strip of wood which draftsmen would use like a ﬂexible French curve. Metal weights (called “ducks”) were placed on the drawing surface and the spline was threaded between the ducks as in Figure .© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 42
15. 15. Splines Smooth curve defined by some control points Moving the control points changes the curve© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 43 Definition A B-spline is defined by an ordered set of control points which determines what path the curve will follow and consequently how the curve will look. A longer B-spline is actually made up of several curve segments, each one of which is defined by some number of control points in its vicinity© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 44 Spline (general case) Given n+1 distinct knots xi such that: with n+1 knot values yi find a spline function with each Si(x) a polynomial of degree at most n.© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 45
16. 16. Spline Interpolation Linear, Quadratic, Cubic Preferred over other polynomial interpolation More efficient High-degree polynomials are very computationally expensive Smaller error Interpolant is smoother© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 46 Natural Cubic Spline Interpolation Si(x) = aix3 + bix2 + cix + di 4 Coefficients with n subintervals = 4n equations There are 4n-2 conditions Interpolation conditions Continuity conditions Natural Conditions S’’(x0) = 0 S’’(xn) = 0© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 47 Natural Conditions© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 48
17. 17. Weighting factor in Splines A point on a particular curve segment is calculated by simply adding up the coordinate values of its defining control points after they have been multiplied by a weighting factor. The weighting factor is calculated using a set of parametric basis or blending functions.© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 49 Spline Notation A B-spline curve P(t), is defined by Where • the {Pi : i = 0, 1, ..., n} are the control points • k is the order of the polynomial segments of the B-spline curve. Order k means that the curve is made up of piecewise polynomial segments of degree k − 1 • The Ni, k(t) are the “normalized B-spline blending functions”. They are described by the order k and by a non-decreasing sequence of real numbers {ti : i = 0, ..., n + k}normally called the “knot sequence”.© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 50 Functions used in B Splines The Ni,k functions are described as follows and if k > 1© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 51
18. 18. Properties of B-Spline For n+1 control points the curve is described with n +1 blending functions. Each blending function Bk,d is defined over d subintervals of the total range of u, starting at knot value uk. The range of parameter u is divided into n + d ,subintervals by the n + d + 1 values specified in the knot vector.© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 52 Properties (Cont’d..) Each section of the spline curve ( between 2 successive knot values) is influenced by d control points. Any one control point can affect the shape of at most d curve sections.© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 53 CUBIC B SPLINE Iterative method for constructing BSplines© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 54
19. 19. Knot Vector A knot vector is a list of parameter values, or knots, that specify the parameter intervals for the individual Bezier curves that make up a B-spline. The knot vector can, by its definition, be any sequence of numbers provided that each one is greater than or equal to the preceding one.© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 55 Example : Knot Vector For example, the knot vector in Figure would be [t0, 1, 2, 3, 4, 5, 6, 7, 8, t9], where the values of t0 and t9 have absolutely no effect on the curve.© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 56 Uniform Knot Vector A B-spline curve whose knot vector is evenly spaced is known as a uniform B-spline. These are knot vectors for which For example:© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 57
20. 20. Open Uniform Knot Vector If any knot value is repeated,it is referred to as a multiple knot. Also known as open Uniform knot vector. For example:© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 58 Non-uniform Knot Vector If the knot vector is not evenly spaced, the curve is called a non- uniform B-spline . Here For example:© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 59 Example: 5 Control Points The picture below shows a set of 5 control points (so n+1=5), and two separate B-Spline curves through them. The red curve has k=3, while the blue curve has k=4. The knot vector used was uniform. In the case with k=3, there are n+k+1=8 knots: 0,1,2,3,4,5,6,7, while in the case with k=4, there are 9 knots: 0,1,2,3,4,5,6,7,8.© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 60
21. 21. Why use Bsplines B-spline curves require more information (i.e., the degree of the curve and a knot vector) and a more complex theory than Bezier curves. But, it has more advantages: B-spline curve can be a Bézier curve. B-spline curves satisfy all important properties that Bézier curves have. B-spline curves provide more control flexibility than Bézier curves can do. For example, the degree of a B-spline curve is separated from the number of control points. More precisely, we can use lower degree curves and still maintain a large number of control points.© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 61 Bézier Surfaces© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 62 Summary A Curve is specified by set of points called the control point. The shape of the curve should not get affected when the control points are measured. The control points control the shape interactively and hence a designer tries to manipulate the shape of the curve by moving the control points in a neighborhood. Most shapes are simply too complicated to define using a single Bezier curve. A spline curve is a sequence of curve segments that are connected together to form a single continuous curve. Blending functions are a set of functions which are used to represent curve. Knot Vector specify the parameter intervals for the individual Bezier curves that make up a B-spline.© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 63
22. 22. Exercise Q.1 Multiple Choice Questions a) The following knot vector [0, 0, 0, 0, 1 , 2, 2, 2, 2] represents (A) Bezier spline (B) open uniform B-spline (C) Periodic B-spline (D) Non-uniform B-spline b) A B-spline curve with (n+1) blending function has (A) n control points. (B) (n+1) control points. (C) (n-1) control points. (D) n2 control points. c) For which of the curves it is easier to compute basis functions. (A) Bezier curves. (B) open B-spline. (C) Uniform B-spline. (D) periodic B-spline© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 64 Exercise (Cont’d..) d) Which one of the following is one of the blending functions for Bezier curve (cubic)? (A) 3u2 (B) u2 (C) 3u3 (D) u (1-u)2 e) State True/False “For n + 1 control points, the B-spline curve is described with n blending functions”. f) For second order parametric continuity in Bezier curves with control points and where , we must have© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 65 Exercise (Cont’d..) Q.2 Attempt all questions: a.‘Bezier Curve do not allow for local control of the curve shape’. Justify. b. Give the blending functions for uniform quadratic B-spline with knot vectors [0, 1, 2, 3, 4, 5, 6] c. What are the boundary conditions for periodic cubic splines with four control points? d. What do you understand by C1 and C2 continuity between two cubic Bezier segments? Derive the conditions for the same in terms of control point of the two cubic Bezier curve segments. e. Define B-spline. What do you mean by knot vector?© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 66
23. 23. Exercise (Cont’d..) f. In computer graphics, why do we prefer parametric representation of curves? g. What do you mean by knot vector? What are various types of knot vectors? h. Give the general expression for B-spline curve defined by Cox- de-Boor. Give also the characterstics of B-spline curve. i. Write the blending functions of cubic Bezier curves. Draw their curves also. j Draw a Bezier curve by hand with four control points P1, P2, P3, P4© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63. 67