Fundamentals of Computer Graphics Lecture 3 Parametric curve and surface Yong-Jin Liu liuyongjin@tsinghua.edu.cn
Smooth curve and surface
Design criteria of smooth curve and surface Smooth and continuity Ability to control the local shape Stability Is it easy to draw
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
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
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
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
Different parameters will get different derivative vector! (0,2) ) (1 ) 2(1, ) (1 4 )) ( ), ( ( (0,1) )) ),cos( sin( ( )) ( ), ( ( 2 2 2 2 2 t t t t t y t x u u u y u x
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
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.
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.
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 3.1.7 continuous of two curves
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)
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
Design criteria of smooth curve and surface Smooth and continuity Ability to control the local shape Stability Is it easy to draw
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 0 1 1 u u i n i i n i T
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
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?
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
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
f ( u) a a u a u 0 1 2 2 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
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
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)!
Bernstein based representation of polynomial curve Have clear geometry meaning Why there exists control polygon effect when use Bernstein based representation?
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
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
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
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
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)!
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
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 2 2 0 1 2 (1 u)((1 u) P up ) u((1 u) P up ) 0 1 1 2
2 order Bezier curve 2 C( u) B ( u) P i0 i,2 i (1 u) P 2 u(1 u) P u P 2 2 0 1 2 (1 u)((1 u) P up ) u((1 u) P up ) 0 1 1 2 Is this property general?
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)!
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 )
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
Smooth curve and surface in 3D space
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
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)
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
n m S( u, v) B ( u) B ( v) i0 j0 2D Bernstein base P i, n j, m i, j
Computation method of Bezier curve Geometry drawing algorithm decasteljau algorithm
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
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?
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
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
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
Ability of local shape change
Ability of local shape change
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
Some extensions of NURBS curve and surface Free form deformation (FFD) Subdivision surface
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
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
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
Free deformation of parametric curve and surface (FFD) 1D curve 2D surface 3D solid Further expansion?
Free deformation of parametric curve and surface (FFD) 1D curve 2D surface 3D solid Further expansion?
Extended Free Form Deformation
Selective Course Project 6 Try to program the following shape using GDI+:
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);