View
2
Download
0
Category
Preview:
Citation preview
Computer Graphics (CS 543): Curves
Prof Emmanuel Agu
Computer Science Dept. Worcester Polytechnic Ins7tute (WPI)
So Far…
! Dealt with straight lines and flat surfaces ! Real world objects include curves ! Need to develop:
! Representa?ons of curves ! Tools to render curves
Curve Representa<on: Explicit
! One variable expressed in terms of another ! Example:
! Works if one x-‐value for each y value ! Example: does not work for a sphere
! Rarely used in CG because of this limita?on
),( yxfz =
22 yxz +=
Curve Representa<on: Implicit
! Represent 2D curve or 3D surface as zeros of a formula ! Example: sphere representa?on
! May limit classes of func?ons used ! Polynomial: func?on which can be expressed as linear
combina?on of integer powers of x, y, z ! Degree of algebraic func?on: highest power in func?on ! Example: mx4 has degree of 4
01222 =−++ zyx
Curve Representa<on: Parametric
! Represent 2D curve as 2 func?ons, 1 parameter
! 3D surface as 3 func?ons, 2 parameters
! Example: parametric sphere
))(),(( uyux
)),(),,(),,(( vuzvuyvux
φφθ
θφφθ
θφφθ
sin),(sincos),(coscos),(
=
=
=
zyx
Choosing Representa<ons
! Different representa?on suitable for different applica?ons
! Implicit representa?ons good for: ! Compu?ng ray intersec?on with surface ! Determing if point is inside/outside a surface
! Parametric representa?on good for: ! Breaking surface into small polygonal elements for
rendering ! Subdivide into smaller patches
! Some?mes possible to convert one representa?on into another
Con<nuity
! Consider parametric curve
! We would like smoothest curves possible ! Mathema?cally express smoothness as con?nuity (no jumps)
! Defn: if kth deriva?ves exist, and are con?nuous, curve has kth order parametric con?nuity denoted Ck
TuzuyuxuP ))(),(),(()( =
Con<nuity
! 0th order means curve is con?nuous ! 1st order means curve tangent vectors vary con?nuously, etc
Interac<ve Curve Design
! Mathema?cal formula unsuitable for designers ! Prefer to interac?vely give sequence of points (control points)
! Write procedure: ! Input: sequence of points ! Output: parametric representa?on of curve
Interac<ve Curve Design ! 1 approach: curves pass through control points (interpolate) ! Example: Lagrangian Interpola?ng Polynomial ! Difficulty with this approach:
! Polynomials always have “wiggles” ! For straight lines wiggling is a problem
! Our approach: approximate control points (Bezier, B-‐Splines)
De Casteljau Algorithm
! Consider smooth curve that approximates sequence of control points [p0,p1,….]
! Blending func?ons: u and (1 – u) are non-‐nega?ve and sum to one
10)1()( uppuup +−= 10 ≤≤ u
De Casteljau Algorithm
! Now consider 3 points ! 2 line segments, P0 to P1 and P1 to P2
1001 )1()( uppuup +−= 2111 )1()( uppuup +−=
De Casteljau Algorithm
)()1()( 1101 uuppuup +−=
22
102 ))1(2()1( pupuupu +−+−=
202 )1()( uub −=
Blending functions for degree 2 Bezier curve
)1(2)(12 uuub −=2
22 )( uub =
)(02 ub )(12 ub )(22 ub
Substituting known values of and )(01 up )(11 up
Note: blending functions, non-negative, sum to 1
De Casteljau Algorithm
! Extend to 4 control points P0, P1, P2, P3
! Final result above is Bezier curve of degree 3
32
21
20
3 ))1(3())1(3()1()( upuupuupuup +−+−+−=
)(23 ub)(03 ub )(13 ub )(33 ub
De Casteljau Algorithm
! Blending func?ons are polynomial func?ons called Bernstein’s polynomials
333
223
213
303
)(
)1(3)(
)1(3)(
)1()(
uubuuubuuub
uub
=
−=
−=
−=
32
21
20
3 ))1(3())1(3()1()( upuupuupuup +−+−+−=
)(23 ub)(03 ub )(13 ub )(33 ub
De Casteljau Algorithm
! Wri?ng coefficient of blending func?ons gives Pascal’s triangle
1
4
1
1
1
1
1
2
4
3
6
1 3
1
1
32
21
20
3 ))1(3())1(3()1()( upuupuupuup +−+−+−=
31 3 1
4 control points
3 control points
5 control points
De Casteljau Algorithm
! In general, blending func?on for k Bezier curve has form
! Example
iikik uu
ik
ub −−⎟⎟⎠
⎞⎜⎜⎝
⎛= )1()(
300303 )1()1(
03
)( uuuub −=−⎟⎟⎠
⎞⎜⎜⎝
⎛= −
De Casteljau Algorithm
! Can express cubic parametric curve in matrix form
⎥⎥⎥⎥
⎦
⎤
⎢⎢⎢⎢
⎣
⎡
=
3
2
1
0
32 ],,,1[)(
pppp
Muuuup B
where
⎥⎥⎥⎥
⎦
⎤
⎢⎢⎢⎢
⎣
⎡
−−
−
−=
1331036300330001
BM
Subdividing Bezier Curves
! OpenGL renders flat objects ! To render curves, approximate with small linear segments
! Subdivide surface to polygonal patches ! Bezier curves useful for elegant, recursive subdivision
Subdividing Bezier Curves
! Let (P0… P3) denote original sequence of control points ! Recursively interpolate with u = ½ as below ! Sequences (P00,P01,P02,P03) and (P03,P12,P21,30) define
Bezier curves also ! Bezier Curves can either be straightened or curved recursively
in this way
Bezier Surfaces
! Bezier surfaces: interpolate in two dimensions ! This called Bilinear interpola?on ! Example: 4 control points, P00, P01, P10, P11, 2 parameters u
and v ! Interpolate between
! P00 and P01 using u ! P10 and P11 using u ! P00 and P10 using v ! P01 and P11 using v
))1(())1)((1(),( 11100100 uppuvuppuvvup +−++−−=
Bezier Surfaces
! Expressing in terms of blending func?ons
11111101011101000101 )()()()()()(),( pubvbpubbvbpubvbvup ++=
Generalizing
∑∑= =
=3
0
3
0,3,3, )()(),(
i jjiji pubvbvup
Problems with Bezier Curves ! Bezier curves are elegant but too many control points ! To achieve smoother curve
! = more control points ! = higher order polynomial ! = more calcula?ons
! Global support problem: All blending func?ons are non-‐zero for all values of u
! All control points contribute to all parts of the curve ! Means afer modelling complex surface (e.g., a ship), if one control point is moves, recalculate everything!
B-‐Splines ! B-‐splines designed to address Bezier shortcomings ! B-‐Spline given by blending control points ! Local support: Each spline contributes in limited range ! Only non-‐zero splines contribute in a given range of u
∑=
=m
iii puBup
0
)()(
B-spline blending functions, order 2
NURBS
! Encompasses both Bezier curves/surfaces and B-‐splines ! Non-‐uniform Ra?onal B-‐splines (NURBS) ! Ra?onal func?on is ra?o of two polynomials ! Some curves can be expressed as ra?onal func?ons but not as
simple polynomials ! No known exact polynomial for circle ! Ra?onal parametriza?on of unit circle on xy-‐plane:
0)(12)(
11)(
2
2
2
=+
=
+
−=
uzuuuy
uuux
NURBS
! We can apply homogeneous coordinates to bring in w
! Using w, we get we cleanly integrate ra?onal parametriza?on ! Useful property of NURBS: preserved under transforma?on
2
2
1)(0)(2)(1)(
uuwuz
uuyuux
+=
=
=
−=
Subdivision Surfaces
! hips://3dcrea?veworld.wordpress.com/2015/01/20/subdivision-‐surface-‐modelling/
Recommended