Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Graphics Lecture 38

Similar presentations


Presentation on theme: "Computer Graphics Lecture 38"— Presentation transcript:

1 Computer Graphics Lecture 38

2 CURVES IV Taqdees A. Siddiqi cs602@vu.edu.pk

3 Bezier Curves

4 The Bezier curve is an important part of almost every computer-graphics illustration program and computer-aided design system in use today

5 It is used in many ways, from designing the curves and surfaces of automobiles to defining the shape of letters in type fonts.

6 Because it is numerically the most stable of all the polynomial-based curves used in these applications, the Bezier curve is the ideal standard for representing the more complex piecewise polynomial curves.

7 In the early 1960s, Peter Bezier began looking for a better way to define curves and surfaces one that would be useful to a design engineer

8 A Geometric Construction

9 We can draw a Bezier curve using a simple recursive geometric construction. Let’s begin by constructing a second-degree curve.

10 We select three points A, B, C so that line AB is a tangent to the curve at A, and BC is tangent at C. The curve begins at A and ends at C.

11 Figure 1: Geometric Construction of a second-degree Bezier curve.

12 For any ratio, ui, we construct points D and E such that:
Equation 1

13 On DE we construct F so that DF/DE = uj. Point F is on the curve.
Repeating this process for other values of ui, we produce a series of points on a Bezier curve.

14 Figure 1: Geometric Construction of a second-degree Bezier curve.

15 Note that we must be consistent in the order in which we sub-divide AB and BC.
For example here first, AB is divided into AD & DB And then BC into BE & EC And finally DE into DF & FE

16 To define this curve in a coordinate system, let point
A = (xA, yA), B = (xB, yB)

17 Then coordinates of points D and E for some value of ui are
Equation 2

18 And Equation 3

19 The coordinates of point F for some value of ui are
Equation 4

20 To obtain xF and yF in terms of the coordinates of points A, B and C, for any value of ui in the unit interval, we substitute appropriately from Equation 2 and 3 into equation 4 of plane curve. After rearranging terms to simplify, we find

21 Equation 5

22 We generalize this set of equations for any point on the curve using the following substitutions:

23 Equation 6

24 And we let Equation 7

25 Now we can rewrite Equation 5 as

26 This is the set of second-degree equations for the coordinates of points on Bezier curve based on our construction

27 We express this construction process and Equations 8 in terms of vectors with the following substitutions.

28 Let the vector po represent point A, p1 point B, and p2 point C.

29 Form vector geometry we have , and
, if we let we see that

30 Equation 9

31 We rearrange terms to obtain a more compact vector equation of a second degree Bezier curve:

32 Equation 10

33 Where the points p0, p1 and p2 are called control points, and p is the point on the curve. The ratio u is the parametric variable that takes its value in the range [0,1]

34 Later we will see that this equation is an example of a Bernstein polynomial.

35 Similar constructions apply to Bezier curves of any degree
Similar constructions apply to Bezier curves of any degree. In fact the degree of a Bezier curve is equal to n-1, where n is the number of control points.

36 Figure 2 shows the construction of point on a cubic Bezier curve, which requires four control points A, B, C, and D to define it. The curve begins at point A tangent to the, AB, and ends at D and tangent to CD. We construct points E, F, and G such that

37 Equation 11

38 Figure 2: Geometric Construction of a cubic Bezier curve.

39 On EF and FG we locate H and I, respectively, such that
Equation 12

40 Finally on HI we locate J such that
Equation 13

41 We can make no more subdivisions, which means that point J is on the curve. If we continue this process for a sequence of points, then their locus defines the curve.

42 If points A, B, C, and D are represented by the vectors p0 p1, p2 and p3 respectively, then expressing the construction of the intermediate points E, F, G, H, and I in terms of these vectors to produce point J, or P(u), yields

43 Equation 14

44 This awkward expression simplifies nicely to
Equation 15

45 The geometric construction of a Bezier curve shows how the control points influence its shape. The curve begins at the first point and ends at the last point.

46 It is tangent to the lines connecting the first two points and the last two points. The curve is always contained within the convex hull of the control points.

47 An Algebraic Definition

48 Bezier began with the idea that any point p(u) on a curve segment should be given by an equation such as the following:

49 Equation 16

50 where and vectors pi are the control points (Figure 3).
 Equation 16 is a compact way to express the sum of several similar terms because what it says is this:

51 Figure 3: Bezier curves and their control points.

52 Equation 17

53 Of which Equation 10 and 15 are specific examples, for n=2 and n=3, respectively.
The n+1 functions, that is the fi(u) must produce a cure that has certain well-defined characteristics. Here are some of the most important ones:

54 The curve must start on the first control point, p0, and end on the last, pn. Mathematically, we say that the functions must interpolate these two points. The curve must be tangent to the line given by p1 – p0 at p0 and to pn – pn-1 at pn.

55 The functions fi(u) must be symmetric with respect to u and (1-u)
The functions fi(u) must be symmetric with respect to u and (1-u). This lets us reverse the sequence of control points without changing the shape of the curve.

56 Some Characteristics of Bezier Curves:
- End Point Interpolation Affine Invariance (transform ctrl points and redraw – curve keeps shape) Convex Hull Property Linear Precision (ctrl points in st. line) Variation Diminishing

57 Figure 4: Three different sequences of four control points.

58 Problem of Local Control
Figure 5: Modifying the shape of a Bezier curve

59 A family of functions called Bernstein polynomials satisfies these requirements. They are the basis functions of the Bezier curve (Other curves, such as the NURBS curves, use different, but related, basis functions).

60 Figure 6: Bezier curve basis functions

61 We rewrite Equation 16 using these basis functions as:

62 Were the basis functions are given as:
Equation 19

63 The term is the binomial coefficient function from probability theory and statistics, defined as

64 Equation 20

65 The symbol. is the factorial operator. For example, 3. = 3 x 2 x 1, 5
The symbol ! is the factorial operator. For example, 3! = 3 x 2 x 1, 5! = 5 x 4 x 3 x 2 x 1, so forth. We use the following conventions when evaluating Equation 20; If i and u equal zero, then ui = 1 and 0! = 1.

66 We see that for n+1 control points, the basis functions produce an nth-degree polynomial.

67 Expanding Equation 18 for a second degree Bezier curve (When n=2 and there are three control points) produces

68 Equation 21

69 From Equation 20, we find Equation 22

70 Equation 23 and Equation 24

71 These are the basis functions for a second-degree Bezier curve
These are the basis functions for a second-degree Bezier curve. Substituting them into Equation 21 and rearranging terms, we find

72 Equation 25

73 This is the same expression we found from the geometric construction, Equation 10. The variable u is now called the parametric variable. Now, let’s expand Equation 18 for a cubic Bezier curve, where n=3:

74 Equation 26

75 And from Equation 20 we find

76 Equation 28

77 Equation 29

78 Equation 30

79 Substituting these into Equation 26 and rearranging terms produces

80 Equation 31

81 Bezier curve equations are well suited for expression in matrix form
Bezier curve equations are well suited for expression in matrix form. We can expand the cubic parametric functions and rewrite Equation 31 as

82 Equation 32

83 Equation 33

84 If we let Equation 34

85 Equation 35

86 Equation 36

87 Then we can write Equation 33 even more compactly as

88 Note that the composition of the matrices U, M, and P varies according to the number of control points (that is, the degree of the Bernstein polynomial basis functions).

89 Computer Graphics Lecture 38


Download ppt "Computer Graphics Lecture 38"

Similar presentations


Ads by Google