Curves and Surfaces
Curves and Surfaces
Curves and Surfaces
Rendering Pipeline
Hardware
Illumination +
Shading
Texture/
Perception,
Color Realism
Inter
Reading
• Angel – Chapter 10
• Foley et al. - Chapter 11
© Machiraju/Zhang/Möller
3
Today
• Polynomials
• Parametric representation
• Fairness vs. smoothness
• Parametric vs. geometric continuity
• Hermite spline
• Bezier spline
• B-Spline
• Surfaces
• Subdivision 4
Filling a gap …
• So far, we have focused on lines, flat
polygons, and simple objects, e.g., spheres
• Missing: freeform curves and surfaces
• Although smooth curves and surfaces are
converted to polygonal curves and meshes
when rendered, they still provide a good
option for modeling
• We follow the text loosely
[Zorin 01]
5
Why curves and surfaces?
• Natural to use for mod eling of smooth shapes,
e.g.,
– Body of an automobile
– Shape of cartoon characters (Shrek)
– Motion curves in animation, etc.
• Smoothness can often b e http://www.shrek2.com/
guaranteed analytically
• Compact (analytical) representation
• Theory of smooth curves and surfaces, e.g.,
from calculus and differential geometry, is well-
6
developed
Polynomial curves and surfaces
• In computer graphics, we prefer curves and
surfaces represented by polynomials
– Approximation power: Can approximate any
continuous function to any accuracy
(Weierstrass’s Theorem)
– Can offer local control for shape design through
the use of piecewise polynomials
– All derivatives and integrals are available
(infinitely smooth) and easy to compute
– Compact representation
– Efficient evaluation – e.g., Horner’s rule
© Machiraju/Zhang/Möller
7
Horner’s rule
• Consider a cubic polynomial
b(t) = at3 + bt2 + ct + d
• Straightforward way to evaluate b(t) takes 6
multiplications and 3 additions
• Horner’s Rule:
b(t) = ((a * t + b) * t + c) * t + d
• It takes 3 additions and 3 multiplications. In
general, n +’s and n *’s for polynomial with
degree = n. © Machiraju/Zhang/Möller
8
Curve & surface representation
• Explicit: y = f(x), z = f(x, y)
• Implicit (level-set): f(x,y) = 0, f(x, y, z) = 0
• Parametric:
– 2D planar curve segment:
(x(t), y(t)), t ∈[0, 1]
– 3D space curve segment:
(x(t), y(t), z(t)), t ∈[0, 1]
– 3D parametric surface patch:
(x(u, v), y(u, v), z(u, v)), u, v ∈[0, 1]
© Machiraju/Zhang/Möller
9
Basis Functions
http://terpconnect.umd.edu/~petersd/interp.html
© Machiraju/Zhang/Möller
10
Piecewise polynomial curves
• Consider the problem of polynomial
interpolation:
High-degree
interpolation
Piece-wise cubic
interpolation
© Machiraju/Zhang/Möller
11
Today
• Polynomials
• Parametric representation
• Fairness vs. smoothness
• Parametric vs. geometric continuity
• Hermite spline
• Bezier spline
• B-Spline
• Surfaces
• Subdivision 12
Fairness vs. smoothness
• Smoothness of curves and surfaces:
– Local property: often achieved by design
– Related to existence and continuity of various
derivatives,
– e.g., f(x) = 3x100 – 9x2 + … + 1 is infinitely smooth,
but is it “visually pleasing”?
• Fairness (often appears in CAGD literature)
– Global property: often achieved by some form of
energy minimization
– Related to the “energy” of a curve or surface
– e.g., f(x) = 3x100 – 9x2 + … + 1 has high bending
energy, and is not© Machiraju/Zhang/Möller
very visually pleasing 13
Parametric cubic curves
• Let us focus on parametric curves for now
• Generalization to surfaces is quite straightforward
• Questions: what degree (of the polynomials) to
use?
– Degree 0 – 2 (constant, linear, or quadratic): often has
too little flexibility
– High-degree: unnecessarily complex and easy to
introduce undesirable wiggles (most objects we want
to model using curves and surfaces are somewhat
fair) – fairness vs. smoothness
– Most commonly used in graphics: parametric cubic
© Machiraju/Zhang/Möller
(degree-3) curves and surfaces 14
Parametric cubic segment
• Consider a single piece:
x(t) = a3t3 + a2t2 + a1t + a0
y(t) = b3t3 + b2t2 + b1t + b0
z(t) = c3t3 + c2t2 + c1t + c0
• In matrix form:
– x’(1) = R4 © Machiraju/Zhang/Möller
21
Cubic Hermite curves
• x(t) = TA = a3t3 + a2t2 + a1t + a0, where T =
[t3 t2 t 1] and A = [a3 a2 a1 a0]T. We want
© Machiraju/Zhang/Möller
24
Piecewise Hermite curves
• Can obviously enforce C1 or G1 continuity
at the joints
R1 R’4
P4 = P’1
P’4
P1
R4 = kR’1
© Machiraju/Zhang/Möller
29
Bézier basis polynomials
– B0(t) = (1 – t)3, B1(t) = 3t(1 – t)2,
– B2(t) = 3t2(1 – t), B3(t) = t3
• Well known as the Bernstein Polynomials of
degree 3
• Bernstein polynomials of degree n
• We have
• Partition of unity easy to see:
Σi Bi(t) = [t + (1 – t)]n
© Machiraju/Zhang/Möller
30
Piecewise Bézier curves
• How to ensure C1 or G1 continuity for a
piecewise Bézier curve?
• Each segment is parameterized over [0, 1]
as usual P2
P6
P1
P3
P0 P5
P4
http://www.cs.princeton.edu/~min/cs426/jar/bezier.html
© Machiraju/Zhang/Möller
31
Ex 3. Cubic B-Spline curves
• Most popular choice in computer graphics
• They are C2 continuous – this beats Hermite
and Bézier curves in terms of smoothness
• The theory of B-splines is very rich
• NURBS: nonuniform rational B-splines
– Each component is rational: x(t)/w(t), etc.
– Can be used to specify circles, etc.
© Machiraju/Zhang/Möller
32
Cubic B-Spline curves
• Each cubic B-spline segment is specified by
four control points
• Has the convex hull property
• The cubic B-spline matrix:
© Machiraju/Zhang/Möller
33
Piecewise cubic B-splines
• Two consecutive segments share three control
points
• m control points → m – 3 segments
• Each segment parameterized over [0, 1] as usual
• Exercise: what if control points repeat? P8
P6 C5
P2 P4 C3
P1 C1 P5 C4 P7
C2
P3
•
© Machiraju/Zhang/Möller
http://www.cs.technion.ac.il/~cs234325/Applets/applets/bspline/GermanApplet.html 34
From curves to surfaces
• One easy way: sweep a curve whose control
points also trace out some curves, e.g., bilinear
interpolation
• Fit the simplest surface
between four points
• Sweep a straight line and each
bilinear interpolation
point on the line traces a
straight line
• Example of a ruled surface
[Angel 02]
In matrix form:
http://www.math.psu.edu/dlittle/java/parametricequations/beziersurfaces/index.html
© Machiraju/Zhang/Möller
38
Ex. 2: TP cubic B-spline
surfaces
• Analogues extension
of B-spline curves
• N(u) and N(v) are the
cubic B-spline bases
• 16 control points per
bi-cubic B-spline patch
• Satisfy the convex hull
property
© Machiraju/Zhang/Möller
39
Smoothness of Bézier surface
• G1 continuity: make 2-sets of 4 control
points on either side of an edge collinear
• C1 continuity: collinear and equally spaced
© Machiraju/Zhang/Möller
41
Today
• Polynomials
• Parametric representation
• Fairness vs. smoothness
• Parametric vs. geometric continuity
• Hermite spline
• Bezier spline
• B-Spline
• Surfaces
• Subdivision © Machiraju/Zhang/Möller 42
deCasteljau Recursion
• We can use the convex hull property of
Bezier curves to obtain an efficient
recursive method that does not require any
function evaluations
– Uses only the values at the control points
• Based on the idea that “any polynomial and
any part of a polynomial is a Bezier
polynomial for properly chosen control
data”
© Machiraju/Zhang/Möller
43
Splitting a Cubic Bezier
• p0, p1, p2, p3 determine a cubic Bezier
polynomial and its convex hull
© Machiraju/Zhang/Möller
45
Convex Hulls
• {l0, l1, l2, l3} and {r0, r1, r2, r3} each have a convex hull that
that is closer to p(u) than the convex hull of {p0, p1, p2, p3}
This is known as the variation diminishing property.
• The polyline from l0 to l3 (= r0) to r3 is an approximation to
p(u). Repeating recursively we get better approximations.
© Machiraju/Zhang/Möller
46
Equations
• Start with Bezier equations p(u)=uTMBp
• l(u) must interpolate p(0) and p(1/2)
l(0) = l0 = p0
l(1) = l3 = p(1/2) = 1/8( p0 +3 p1 +3 p2 + p3 )
l0 = p0
r3 = p3
l1 = ½(p0 + p1)
r1 = ½(p2 + p3)
l2 = ½(l1 + ½( p1 + p2))
r1 = ½(r2 + ½( p1 + p2))
l3 = r0 = ½(l2 + r1)
© Machiraju/Zhang/Möller
48
Every Curve is a Bezier Curve
• We can render a given polynomial using the
recursive method if we find control points
for its representation as a Bezier curve
• Suppose that p(u) is given as an
interpolating curve with control points q
p(u)=uTMIq
• There exist Bezier control points p such that
p(u)=uTMBp
Interpolating to Bezier
B-Spline to Bezier
© Machiraju/Zhang/Möller
50
Example
• These three curves were all generated from
the same original data using Bezier
recursion by converting all control point
data to Bezier control points
© Machiraju/Zhang/Möller
51
Surfaces
• Can apply the recursive method to surfaces if we
recall that for a Bezier patch curves of constant u (or
v) are Bezier curves in u (or v)
• First subdivide in u
– Process creates new points
– Some of the original points are discarded
original and discarded
© Machiraju/Zhang/Möller
54
Utah Teapot
• Most famous data set in computer graphics
• Widely available as a list of 306 3D vertices
and the indices that define 32 Bezier patches
© Machiraju/Zhang/Möller
55
Subdivision Schemes
• In order to draw a curve we need to find
points on it:
© Machiraju/Zhang/Möller
56
Subdivision Schemes
• Same for surfaces:
© Machiraju/Zhang/Möller
57
Subdivision Schemes (2)
© Machiraju/Zhang/Möller
58
Loop
• Guaranteed to be smooth everywhere except
at extraordinary vertices
• Face Split
• Triangular
meshes
• approximating
© Machiraju/Zhang/Möller
59
Loop (2)
© Machiraju/Zhang/Möller
60
Loop - Boundary
• Subdivision Mask for
Boundary Conditions
© Machiraju/Zhang/Möller
61
Modified Butterfly
• Face Split
• Triangular
meshes
• interpolating
© Machiraju/Zhang/Möller
62
Catmull-Clark
• Face Split
• Quad. Meshes
(extents to
arbitrary)
• approximating
• Masks for odd vertices
© Machiraju/Zhang/Möller
63
Catmull-Clark (2)
• Face Split
• Quad. Meshes
(extents to
arbitrary)
• approximating
• Masks for even vertices
© Machiraju/Zhang/Möller
64
Catmull-Clark (2)
FACE
EDGE
VERTEX
© Machiraju/Zhang/Möller
65
Kobbelt
• Face Split
• Quad. Meshes
• interpolating
© Machiraju/Zhang/Möller
66
Kobbelt (2)
• Mask for face vertex
adjacent to an
extraordinary vertex.
• Two steps
– The edge vertices
– The face vertex
• the edge odd control
point adjacent to an
extraordinary vertex
© Machiraju/Zhang/Möller
67
Doo-Sabin
• Vertex Split
• Quad. Meshes
• interpolating or approximating??
© Machiraju/Zhang/Möller
68
Mid-Edge
• Midedge, the simpler version of Doo-Sabin
scheme.
© Machiraju/Zhang/Möller
69
Doo-Sabin & Mid-Edge
• The interior rules can be decomposed into a
sequence of averaging steps.
Doo-Sabin scheme
Midedge scheme
© Machiraju/Zhang/Möller
70
Subdivision Schemes
Loop Butterfly
Catmull-
Doo-Sabin
Clark
© Machiraju/Zhang/Möller
71
Modeling with Subdivision
• Subdivision produces smooth continuous
surfaces.
• How can “sharpness” and creases be controlled
in a modeling environment?
• ANSWER: Define new subdivision rules for
“creased” edges and vertices.
– Tag Edges sharp edges.
– If an edge is sharp, apply
new sharp subdivision rules.
– Otherwise subdivide with
normal rules. © Machiraju/Zhang/Möller 72