Fundamentals of Computer Graphics. Lecture 3 Parametric curve and surface. Yong-Jin Liu.

Save this PDF as:
 WORD  PNG  TXT  JPG

Size: px
Start display at page:

Download "Fundamentals of Computer Graphics. Lecture 3 Parametric curve and surface. Yong-Jin Liu."

Transcription

1 Fundamentals of Computer Graphics Lecture 3 Parametric curve and surface Yong-Jin Liu

2 Smooth curve and surface

3 Design criteria of smooth curve and surface Smooth and continuity Ability to control the local shape Stability Is it easy to draw

4 Smooth and continuity Regard the curve as the orbit of point changing with its parameter u C( u) y( u) zu ( ) 2 n x( u) a0 a1u a2u anu Regard the differential of one point as the its speed along the orbit, the direction of speed is the tangent direction of this point x( u) a1 2a2u nanu C( u) y( u) z ( u) n1

5

6 C n metric of curve smooth Differentiability of function:if parametric curve has continuous derivative until n order at any point in the interval [a, b],i.e. n order continuous differentiable, then the curve is n order parametric continuous in the interval [a, b]. Polynomial curve has infinite order parametric continuous C Polynomial curve of n order p n (x)=a 0 +a 1 x+a 2 x 2 +a n x n

7 Consider two curves with a common point Differentiability of function:if parametric curve has continuous derivative until n order at any point in the interval [a, b],i.e. n order continuous differentiable, then the curve is n order parametric continuous in the interval [a, b]. C 0 continuous C 1 continuous

8 C n curve continuity Differentiability of function:if combined parametric curve has continuous derivative until n order at the joint point, it is called C n or n-order parametric continuous. Is there any thing wrong? The same curve can have different parameters. circle: 1 t xt () x( u) cos( u) or 1 t y( u) sin( u) 2t yt () 1 t 2 2 2

9 Different parameters will get different derivative vector! (0,2) ) (1 ) 2(1, ) (1 4 )) ( ), ( ( (0,1) )) ),cos( sin( ( )) ( ), ( ( t t t t t y t x u u u y u x

10 C(u), u [a, b] C(t), t [0, 1], t u b a a dc( u) dc( t) dt 1 dc( t) 1 C( u) C( t) du dt du b a dt b a

11 Two continuity definitions Differentiability of function:if combined parametric curve has continuous derivative until n order at the joint,i.e. n order continuous differentiable, such smooth is called C n or n order parametric continuous. Geometry continuity:if the direction of derivative vector of combined curve at the joint is equal, then it is n order geometry continuous, denoted by G n.

12 If require G 0 or C 0 continuous at the joint, that is to say two curves are continuous at the joint. If require G 1 continuous at the joint,that is to say two curves are G 0 continuous at the joint, and have the common derivative vector P (1)=aQ (0). when a=1,g 1 continuous is also C 1 continuous If require G 2 continuous at the joint,that is to say two curves are G 1 continuous at the joint, and have common curvature vector.

13 Curvature formula P(1) P (1) Q(0) Q (0) 3 3 P(1) Q(0) This equation can be wrote as : Q a P bp 2 (0) (1) (1) a, b is arbitrary constant. When a=1,b=0,g 2 continuous is also C 2 continuous. P(0) P(t) P(1) Q(0) Q(t) Q(1) Figure continuous of two curves

14 Arc length parameterization of curve The same curve can have different parameter If u(s) is a monotonic function,then C(s)=C(u(s)) is a new parameterization about s of the curve Compute the length L(u) of curve C(u) If there exists parameter s, so that L(s)=s, s 0? s = 0 Length L(s) Parameter s Curve C(s)

15 Arc length parameterization of curve ds Let C( u) du u s C( u) du L( u) 0 u s L s 1 ( ) ( ) dc( s) dc( u( s)) du 1 v( s) C( u) ds du ds C ( u ) vs ( ) 1

16

17 Design criteria of smooth curve and surface Smooth and continuity Ability to control the local shape Stability Is it easy to draw

18 Power based representation of polynomial curve n order polynomial curve C n (u)=a 0 +a 1 u+a 2 u 2 ++a n u n C( u) ( x( u), y( u), z( u)) a u a ( x, y, z ) i i i i C( u) n i0 a a a a u u u i n i i n i T

19 See from the aspect of human computer interaction n order polynomial curve C n (u)=a 0 +a 1 u+a 2 u 2 ++a n u n 1 order polynomial curve: a 1 +a 0 a 1 u+a 0 a 0

20 n order polynomial curve C n (u)=a 0 +a 1 u+a 2 u 2 ++a n u n 2 order polynomial curve: a 2 u 2 +a 1 u+a 0 a 1 a 0 a 2 +a 1 +a 0 2a 2 +a 1 Parabola, ellipse, hyperbola?

21 n order polynomial curve C n (u)=a 0 +a 1 u+a 2 u 2 ++a n u n 3 order polynomial curve: a 3 u 3 +a 2 u 2 +a 1 u+a 0

22 Power based representation of polynomial curve n order polynomial curve C n (u)=a 0 +a 1 u+a 2 u 2 ++a n u n The representation and control ability is very bad Bernstein based representation of polynomial curve Beizer curve Bernstien polynomial n C( u) pibi, n( u) i0 n! i Bin, ( u) u (1 u) i!( n i)! ni

23 f ( u) a a u a u u 2 a 2 p 2 B 2,2 a 0 a 1 u p 0 p 1 1 B 0,2 B 1,2 f ( u) C( u) p B p B p B 0 0,2 1 1,2 2 2,2

24 Bernstein based representation of polynomial curve have clear geometry meaning n C( u) p B ( u) B ( u) p i i, n i, n i i0 i0 n

25 Bernstein based representation of polynomial curve Have clear geometry meaning n C( u) p B ( u) B ( u) p, u [0,1] i i, n i, n i i0 i0 Interpolation of endpoints n n C(0) p B (0) p i0 n i0 i i, n 0 C(1) p B (1) p i i, n n n! i ni Bin, ( u) u (1 u), u [0, 1] i!( n i)!

26 Bernstein based representation of polynomial curve Have clear geometry meaning Why there exists control polygon effect when use Bernstein based representation?

27 1 order Bezier curve n C( u) B ( u) p B ( u) p B ( u) p i0 i, n i 0,1 0 1,1 1 n! i ni Bin, ( u) u (1 u), u [0, 1] i!( n i)! u=0 u=1

28 2 order Bezier curve n C( u) B ( u) p B ( u) p B ( u) p B ( u) p i0 i, n i 0,2 0 1,2 1 2,2 2 n! i ni Bin, ( u) u (1 u), u [0, 1] i!( n i)! u=0 u=1

29 3 order Bezier curve n C( u) B ( u) p B ( u) p B ( u) p B ( u) p B ( u) p i0 i, n i 0,3 0 1,3 1 2,3 2 3,3 3 n! i ni Bin, ( u) u (1 u), u [0, 1] i!( n i)! u=0 u=1

30 9 order Bezier curve 9 C( u) B ( u) p i0 i, n i n! i ni Bin, ( u) u (1 u), u [0, 1] i!( n i)! u=0 u=1 u=0.5

31 Properties of Bezier curve and Bernstein base 1. B i,n (u) 0, for all i, n and 0 u 1 2. Partition of unity n i=0b i,n (u) = 1, 0 u 1 3. B 0,n (0) = B n,n (1) = 1 4. B i,n (u) has and only has a maximum value in the interval [0,1], it is at u=i/n 5. Base set {B i,n (u)} is symmetry about u=1/2 n! i ni Bin, ( u) u (1 u), u [0, 1] i!( n i)!

32 Computation method of Bezier curve Method 1: 9 C( u) B ( u) p i0 i, n n! i ni Bin, ( u) u (1 u), u [0, 1] i!( n i)! Method 2:geometry drawing i

33 Computation method of Bezier curve Method 2 (geometry drawing, ruler drawing): example 2 order Bezier curve 2 C( u) B ( u) P i0 i,2 i (1 u) P 2 u(1 u) P u P (1 u)((1 u) P up ) u((1 u) P up )

34

35

36 2 order Bezier curve 2 C( u) B ( u) P i0 i,2 i (1 u) P 2 u(1 u) P u P (1 u)((1 u) P up ) u((1 u) P up ) Is this property general?

37 Properties of Bezier curve and Bernstein base 6. recursive definition: B i,n (u) = (1u)B i,n1 (u) +ub i1,n1 (u) with B i,n (u) 0, if i < 0 or i > n 7. derivative: B i,n (u) = db i,n (u) /du = n(b i1,n1 (u) B i,n1 (u) ) with B 1,n1 (u) B n,n1 (u) 0 n! i ni Bin, ( u) u (1 u), u [0, 1] i!( n i)!

38 Denote n order Bezier curve as C n (P 0,,P n ), then we have C n (P 0,,P n )=(1u)C n1 (P 0,,P n-1 )+uc n1 (P 1,,P n )

39

40

41 Geometry drawing algorithm n order Bezier curve has C n (P 0,,P n )=(1u)C n1 (P 0,,P n-1 )+uc n1 (P 1,,P n ) denote P i as P 0,i P k,i (u)=(1u)p k1,i (u)+up k1,i+1 (u) k = 1,,n i = 0,,nk decasteljau algorithm

42 Smooth curve and surface in 3D space

43 1D to 2D Regard the curve as the orbit of point changing with its parameter u C( u) y( u) zu ( ) 2 n x( u) a0 a1u a2u anu

44 Tensor product surface Tensor product surfaces S( u, v) ( x( u, v), y( u, v), z( u, v)) n m i0 j0 f ( u) g ( v) b i j i, j [ f ( u)] [ b ][ g ( v)] T i i, j j Base function Geometry coefficient Point S(u 0, v 0 ) Isoparametric lines C(u) = S(u, v 0 ) and C(v) = S(u 0, v)

45

46 Tensor product Bezier surface n m S( u, v) B ( u) B ( v) Point S(u 0, v 0 ) i0 j0 i, n j, m i, j Isoparametric lines C(u) = S(u, v 0 ) and C(v) = S(u 0, v) P

47

48

49 n m S( u, v) B ( u) B ( v) i0 j0 2D Bernstein base P i, n j, m i, j

50 Computation method of Bezier curve Geometry drawing algorithm decasteljau algorithm

51 Computation method of Bezier curve decasteljau algorithm n S( u, v) B ( u) B ( v) P i0 j0 i0 m i, n i, n j, m i, j n m Bi, n ( u) Bj, m( v) Pi, j i0 j0 n B ( u) Q i v u

52

53 Design criteria of smooth curve and surface Smooth and continuity Ability to control the local shape Stability Is it easy to draw Is Bezier curve perfect?

54

55 Beizer curve The representation and control ability of local shape is bad if interpolate many (n+1) discrete point s, then require a high order (n) Bezier curve. How to improve? Splicing many Bezier curve segments n order polynomial curve C n (u)=a 0 +a 1 u+a 2 u 2 ++a n u n

56 Design of B-spline curve Determine the order of continuity p Determine node vector U = {u 0, u 1,, u m }; Determine a set of control points {P 0, P 1,, P n }; The form of B-spline curve is n C( u) Ni, p( u) i0 P i

57 B-spline surface Tensor product surface n m S( u, v) N ( u) N ( v) p1 q1 i0 j0 P i, p j, q i, j r1 U {0,,0, u,, u,1,,1} p1 r p1 s1 q1 sq1 p1 V {0,,0, u,, u,1,,1} q1 r n p 1 and s m q 1

58

59 Ability of local shape change

60 Ability of local shape change

61 The reason is the local scope of basic function P n m S( u, v) N ( u) N ( v) i0 j0 P i, p j, q i, j N ( u) N ( v) [ u, u ) [ v, v ) i, j i, p j, q i i p1 j jq1

62

63 Some extensions of NURBS curve and surface Free form deformation (FFD) Subdivision surface

64 Free deformation of parametric curve and surface (FFD) 1D curve n C( u) Ni, p( u) p1 i0 m1 U {0,,0, u,, u,1,,1} P p1 m p1 i p1 2D surface 3D solid

65 Free deformation of parametric curve and surface (FFD) 1D curve 2D surface n m S( u, v) N ( u) N ( v) p1 q1 3D solid i0 j0 P i, p j, q i, j r1 U {0,,0, u,, u,1,,1} p1 r p1 s1 q1 sq1 p1 V {0,,0, u,, u,1,,1} q1

66 Free deformation of parametric curve and surface (FFD) 1D curve 2D surface 3D solid n m l S( u, v, w) N ( u) N ( v) N ( v) P i0 j0 k0 i, p j, q k, r i, j, k o1 U {0,,0, u,, u,1,,1} p1 r p1 p1 p1 s1 V {0,,0, u,, u,1,,1} q1 sq1 q1 q1 t1 W {0,,0, u,, u,1,,1} r1 tr1 r1 r1

67

68

69

70 Free deformation of parametric curve and surface (FFD) 1D curve 2D surface 3D solid Further expansion?

71

72 Free deformation of parametric curve and surface (FFD) 1D curve 2D surface 3D solid Further expansion?

73 Extended Free Form Deformation

74

75

76

77

78 Selective Course Project 6 Try to program the following shape using GDI+:

79 Tips: The following code constructs a complicated region using two spline curves using namespace Gdiplus; Graphics graphics( pdc->m_hdc ); Pen pen(color::blue, 3); Point point1( 50, 200); Point point2(100, 150); Point point3(160, 180); Point point4(200, 200); Point point5(230, 150); Point point6(220, 50); Point point7(190, 70); Point point8(130, 220); Point curvepoints[8] = {point1, point2, point3, point4, point5, point6, point7, point8}; Point* pcurvepoints = curvepoints; GraphicsPath path; path.addclosedcurve(curvepoints, 8, 0.5); PathGradientBrush pthgrbrush(&path); pthgrbrush.setcentercolor(color(255, 0, 0, 255)); Color colors[] = {Color(0, 0, 0, 255)}; INT count = 1; pthgrbrush.setsurroundcolors(colors, &count); graphics.drawclosedcurve(&pen, curvepoints, 8, 0.5); graphics.fillpath(&pthgrbrush, &path);