CS-184: Computer Graphics Lecture #12: Curves and Surfaces Prof. James O Brien University of California, Berkeley V2007-F-12-1.0
Today General curve and surface representations Splines and other polynomial bases
Geometry Representations Constructive Solid Geometry (CSG) Parametric Polygons Subdivision surfaces Implicit Surfaces Point-based Surface Not always clear distinctions i.e. CSG done with implicits
Geometry Representations Object made by CSG Converted to polygons
Geometry Representations Object made by CSG Converted to polygons Converted to implicit surface
Geometry Representations CSG on implicit surfaces
Geometry Representations Point-based surface descriptions Ohtake, et al., SIGGRAPH 2003
Geometry Representations Subdivision surface (different levels of refinement) Images from Subdivision.org
Geometry Representations Various strengths and weaknesses Ease of use for design Ease/speed for rendering Simplicity Smoothness Collision detection Flexibility (in more than one sense) Suitability for simulation many others...
Parametric Representations Curves: x = x(u) x R n u R Surfaces: x = x(u, v) x R n u, v R x = x(u) u R 2 Volumes: x = x(u, v, w) x = x(u) x R n u, v, w R u R 3 and so on... Note: a vector function is really n scalar functions
Parametric Rep. Non-unique Same curve/surface may have multiple formulae 3 3 2 2 1 1 0 0-1 -1 0 1 2 3-1 -1 0 1 2 3 x(u) = [u, u] x(u) = [u 3, u 3 ]
Simple Differential Geometry Tangent to curve t(u) = x u u Tangents to surface tu(u, v) = x u u,v Normal of surface ˆn = t u tv tu tv tv(u, v) = x v Also: curvature, curve normals, curve bi-normal, others... Degeneracies: x/ u = 0 or tu tv = 0 u,v
Discretization Arbitrary curves have an uncountable number of parameters 3 2 1 0-1 -1 0 1 2 3 i.e. specify function value at all points on real number line
Discretization Arbitrary curves have an uncountable number of parameters Pick complete set of basis functions Polynomials, Fourier series, etc. Truncate set at some reasonable point x(u) = i=0 c i φ i (u) x(u) = 3 i=0 c i φ i (u) = 3 i=0 c i u i Function represented by the vector (list) of c i The c i may themselves be vectors x(u) = 3 i=0 c i φ i (u)
Power Basis x(u) = Polynomial Basis d i=0 c i u i x(u) = C P d C = [c 0, c 1, c 2,..., c d ] P d = [1, u, u 2,..., u d ] The elements of P d are linearly independant i.e. no good approximation u k c i u i i k Skipping something would lead to bad results... odd stiffness
Specifying a Curve Given desired values (constraints) how do we determine the coefficients for cubic power basis? tu(u 0 ) For now, assume u 0 = 0 u 1 = 1 x(u 0 ) x(u 1 ) tu(u 1 ) u 0 u 1
Specifying a Curve Given desired values (constraints) how do we determine the coefficients for cubic power basis? x(0) = c 0 = x 0 tu(u 0 ) x(1) = c i = x 1 x (0)= c 1 = x 0 x (1)= i c i = x 1 x(u 0 ) tu(u 1 ) x(u 1 ) 0 1
Specifying a Curve tu(u 0 ) tu(u 1 ) x(u 0 ) x(u 1 ) Given desired values (constraints) how do we determine the coefficients for cubic power basis? 0 1 x 0 x 1 x 0 x 1 = 1 0 0 0 1 1 1 1 0 1 0 0 0 1 2 3 c 0 c 1 c 2 c 3 p = B c
Specifying a Curve tu(u 0 ) tu(u 1 ) x(u 0 ) x(u 1 ) Given desired values (constraints) how do we determine the coefficients for cubic power basis? 0 1 c = β H p β H = B 1 = 1 0 0 0 0 0 1 0 3 3 2 1 2 2 1 1
Specifying a Curve Given desired values (constraints) how do we determine the coefficients for cubic power basis? c = β H p β H = B 1 = 1 0 0 0 0 0 1 0 3 3 2 1 2 2 1 1 tu(u 0 ) tu(u 1 ) x(u 0 ) x(u 1 ) 0 1 x(u) = P 3 c = P 3 β H p = 1 + 0u 3u 2 + 2u 3 0 + 0u + 3u 2 2u 3 0 + 1u 2u 2 + 1u 3 0 + 0u 1u 2 + 1u 3 p
Specifying a Curve Given desired values (constraints) how do we determine the coefficients for cubic power basis? c = β H p x(u) = 1 + 0u 3u 2 + 2u 3 0 + 0u + 3u 2 2u 3 0 + 1u 2u 2 + 1u 3 0 + 0u 1u 2 + 1u 3 p Hermite basis functions x(u) = 3 tu(u 0 ) x(u x(u 0 ) 1 ) tu(u 1 ) 0 1 i=0 p i b i (u)
Specifying a Curve Given desired values (constraints) how do we determine the coefficients for cubic power basis? tu(u 0 ) Probably not to scale. x(u 0 ) x(u 1 ) tu(u 1 ) 0 1 Hermite basis functions x(u) = 3 i=0 p i b i (u)
Hermite Basis Specify curve by Endpoint values Endpoint tangents (derivatives) Parameter interval is arbitrary (most times) Don t need to recompute basis functions These are cubic Hermite Could do construction for any odd degree (d 1)/2 derivatives at end points
Cubic Bézier Similar to Hermite, but specify tangents indirectly x 0 = p 0 x 1 = p 3 x 0 = 3(p 1 p 0 ) x 1 = 3(p 3 p 2 ) Note: all the control points are points in space, no tangents.
Cubic Bézier Similar to Hermite, but specify tangents indirectly 1 0 0 0 1 1 1 1 0 1 0 0 0 1 2 3 c = 1 0 0 0 0 0 0 1 3 3 0 0 0 0 3 3 p x 0 = p 0 x 1 = p 3 x 0 = 3(p 1 p 0 ) x 1 = 3(p 3 p 2 ) c = 1 0 0 0 3 3 0 0 3 6 3 0 1 3 3 1 p c = β Z p
Cubic Bézier Plot of Bézier basis functions 1 0.8 0.6 0.4 0.2 0.2 0.4 0.6 0.8 1
Changing Bases Power basis, Hermite, and Bézier all are still just cubic polynomials The three basis sets all span the same space Like different axes in Changing basis R 3 R 4 c = β Z p Z c = β H p H p Z = β 1 Z β H p H
Useful Properties of a Basis Convex Hull All points on curve inside convex hull of control points i b i (u) = 1 b i (u) 0 u Ω Bézier basis has convex hull property
Useful Properties of a Basis Invariance under class of transforms Transforming curve is same as transforming control points x(u) = p i b i (u) T x(u) = (T p i )b i (u) i i Bézier basis invariant for affine transforms Bézier basis NOT invariant for perspective transforms NURBS are though...
Useful Properties of a Basis Local support Changing one control point has limited impact on entire curve Nice subdivision rules Orthogonality ( ) Fast evaluation scheme Interpolation -vs- approximation Ω b i(u)b j (u)du = δ ij
DeCasteljau Evaluation A geometric evaluation scheme for Bézier error... u = 0 u =.25 u =.5 u =.75 u = 1
Adaptive Tessellation Midpoint test subdivision Possible problem Simple solution if curve basis has convex hull property If curve inside convex hull and the convex hull is nearly flat: curve is nearly flat and can be drawn as straight line Better: draw convex hull Works for Bézier because the ends are interpolated Recall...
Bézier Subdivision Form control polygon for half of curve by evaluating at u=0.5 Repeated subdivision makes smaller/flatter segments Also works for surfaces...
Joining a C 0 b = b C 1 b a = c b b G 1 b a b a = c b c b c If you change a, b, or c you must change the others But if you change a, b, or c you do not have to change beyond those three. *Local Support*
Hump Functions Constraints at joining can be built in to make new basis
Tensor-Product Surfaces Surface is a curve swept through space Replace control points of curve with other curves x(u, v) = i p i b i (u) i q i (v) b i (u) q i (v) = j p ji b j (v) x(u, v) = ij p ij b i (u)b j (v) b ij (u, v) = b i (u)b j (v) x(u, v) = ij p ij b ij (u, v)
Hermite Surface Bases 1 0.75 0.5 0.25 0 0 0.2 0.4 0.4 0.6 1 0.8 0.6 0.8 1 0 0.2 0.15 0.1 0.05 0 0 0.2 0.4 0.4 0.6 1 0.8 0.6 0.8 1 0 0.2 Plus symmetries... 0.02 0.015 0.01 0.005 0 0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 1 0.8
Hermite Surface Hump Functions 1 0.75 0.5 0.25 0 0 0.2 0.4 0.4 0.6 1 0.8 1 0.75 0.5 0.25 0-1 -0.5 0 0.5 1-1 0-0.5 1 0.5 Plus symmetries... 0.1 0-0.1-1 -0.5 0.6 0.8 0 1 0 0.2 0.5 1-1 0.15 0.1 0.05 0 0 0.2 0.4 0.6 0.8 0-0.5 1 0.5 1 0 0.2 0.4 0.6 1 0.8 0.02 0.01-0.01 0-0.02-1 -0.5 0 0.5 0.02 0.015 0.01 0.005 0 0 0.2 0.4 0.6 0.8 1-1 0-0.5 1 0 0.2 1 0.5 0.4 0.6 1 0.8
Adaptive Tessellation Given surface patch If close to flat: draw it Else subdivide 4 ways
Adaptive Tessellation Avoid cracking Passes flatness test Fails flatness test
Adaptive Tessellation Avoid cracking Cracks may be okay in some contexts... Crack in the surface
Adaptive Tessellation Avoid cracking
Adaptive Tessellation Avoid cracking Test interior and boundary of patch Split boundary based on boundary test Table of polygon patterns May wish to avoid slivers