Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Curves and Surfaces

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 72

Curves and Surfaces

Rendering Pipeline
Hardware

Modelling Transform Visibility

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:

• T is said to be the monomial basis


© Machiraju/Zhang/Möller
15
Derivatives and continuity
• 1st-order derivative of (x(t), y(t)): (x’(t), y’(t)) –
tangent

• 2nd-order derivative: (x’’(t), y’’(t)) – related to


curvature
• Parametric continuity of a curve (smoothness of
motion):
– C0 continuous: curve is joined or connected
– C1: requires C0 & 1st-order derivative is continuous
– C2: requires C0 & C1 & 2nd-order derivative is cont.
© Machiraju/Zhang/Möller
– C : requires C & … & Cn–1 & nth derivative cont.
n 0 16
Continuity of piecewise
polynomials
• A single polynomial segment is always C∞
• But we mostly deal with piecewise polynomial
curves
• Key: what happens at the joints between segments
– C0: curve segments are connected
– C1: C0 & 1st-order derivatives agree at joints
– C2: C0 & C1 & 2nd-order derivative agree at joints, etc.
• If Ci is not possible to enforce, can relax a bit
– “Visual” smoothness: direction of tangents stays the
same but magnitude (speed) may change
© Machiraju/Zhang/Möller
17
Geometric continuity
• geometric continuity
– G0 cont.: curve segments are connected (same as C0)
– G1: G0 & 1st-order derivatives are proportional at joints.
– Note:
• Proportional = same direction but may have different
magnitudes
• Weaker than C1
– G2: G1 & 2nd-order derivative proportional at joints
• Example: p(t) = (3t, t3) and q(t) = (4t+3, 2t2+4t+1)
with t ∈ [0, 1] for each. Is this C0, G1, and/or C1?
– p(1)=q(0)=(3,1), so G0; p’(1)=(3,3) and q’(0)=(4,4), so
© Machiraju/Zhang/Möller
G1 not C1 18
On to curve design
• We want to design piecewise cubic polynomial curves
that satisfy certain design constraints, e.g.,
– Curve should pass through certain points
– Curve should have some given derivatives at specific points
– Curve should be smooth: G1, C1, C2, or …
– Curve must be contained in certain area, or has at most this
length, etc.
• Need proper basis functions to facilitate design process
• These basis functions or blending functions blend
together the individual contributions of the control
points
© Machiraju/Zhang/Möller
19
Basis of cubic polynomials
• Monomial basis: {1, t, t2, t3}, is only one
possibility
• Recall basis:
x(t) = P1b1(t) + P2b2(t) + P3b3(t) + P4b4(t)
• From design point of view, want P1, P2, P3, and P4
to represent observable quantities, e.g.,
– Position: for interpolation
– Derivatives: to control direction and smoothness, etc.
• i.e., they are control points
• Control points are blended by the basis functions;
© Machiraju/Zhang/Möller
they control the shape of the curve 20
Ex. 1: Hermite curves
• Defined by two points (P1 and P4) and two
tangents (R1 and R4) R 1
P
• Aim: Achieve C1 or G1 continuity 4

• Want cubic curve x(t), P 1


R 4

t ∈ [0, 1], such that Let us note that the


(y and z are similar) control “points” P1,
P4, R1, and R4 are
– x(0) = P1 all observable
– x(1) = P4 quantities and they
control the shape of
– x’(0) = R1 the curve

– 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

• So G = BA and thus A = B–1G


• It follows that x(t) = TA = TB–1G = HG
© Machiraju/Zhang/Möller
22
Hermite curves
• How to interpret this: x(t) = TA = TB–1G = HG
– G is a vector of observables or control points
– H is vector of cubic Hermite bases (blending
polynomials)

– For any G, use H to blend four control points to get


curve x(t)
– The matrix Mhermite = B–1 is really a change of basis
matrix: it changes the monomial basis T into the
Hermite basis H
– Hermite curves are completely determined by
© Machiraju/Zhang/Möller
Mhermite 23
The cubic Hermite matrix

© 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

• Each segment parameterized over [0, 1], as


usual
© Machiraju/Zhang/Möller
25
Today
• Polynomials
• Parametric representation
• Fairness vs. smoothness
• Parametric vs. geometric continuity
• Hermite spline
• Bezier spline
• B-Spline
• Surfaces
• Subdivision © Machiraju/Zhang/Möller 26
Ex. 2: Cubic Bézier curve
• Defined by four control points P0, P1, P2, and P3
– x(0) = P0
– x(1) = P3
– x’(0) = 3(P1 – P0)
– x’(1) = 3(P3 – P2)
• Convex hull property: Bézier curve lies within
the convex hull of the four control points –
good control
• Convex hull of a set of points on the plane:
tightest convex polygon enclosing the set
© Machiraju/Zhang/Möller
27
Convex hull property
• A cubic curve satisfies the convex hull property if
it lies within the convex hull of its four control
points
• Convex hull property is satisfied if and only if the
basis polynomials B1(t), B2(t), B3(t), B4(t) satisfy:
– 1. 0 ≤ B1(t), B2(t), B3(t), B4(t) ≤ 1 for t ∈ [0, 1], and
– 2. B1(t) + B2(t) + B3(t) + B4(t) = 1
• Then each point of the curve is a convex
combination of the control points
• The basis Bi(t) form a partition of unity
© Machiraju/Zhang/Möller
28
The cubic Bézier matrix

© 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

• Also an example of the more general class of


tensor-product surfaces
© Machiraju/Zhang/Möller
35
Tensor-product (TP) surfaces
• The curve to sweep:
• Control point ai goes through a curve

• The resulting surface is a tensor-product


surface

• Surface is controlled by the grid of control


points Pij
© Machiraju/Zhang/Möller
36
Ex. 1: TP cubic Bézier patch

• The Bi(u)Bj(v)’s form a basis for bi-cubic


polynomials
• They also form a partition of unity — the patch lies
within the convex hull of the 16 control points Pij
• Patch can be seen as generated by sweeping a
Bézier curve where each point on the curve sweeps
out a Bézier curve
• The four corner vertices are interpolated (easy to
© Machiraju/Zhang/Möller
see?) 37
Cubic Bézier surface patch

[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

Collinear control points


© Machiraju/Zhang/Möller
near patch boundary 40
Smoothness of B-spline
surface
• C2 continuity is achieved if adjacent patches
share control points

© 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

Consider left half l(u) and right half r(u)


© Machiraju/Zhang/Möller
44
l(u) and r(u)
• Since l(u) and r(u) are Bezier curves, we
should be able to find two sets of control
points {l0, l1, l2, l3} and {r0, r1, r2, r3} that
determine them

© 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 )

• Matching slopes, taking into account that l(u)


and r(u) only go over half the distance as p(u)
l’(0) = 3(l1 - l0) = p’(0) = 3/2(p1 - p0 )
l’(1) = 3(l3 – l2) = p’(1/2) = 3/8(- p0 - p1+ p2 + p3)
• Symmetric equa©tMioachnirasju/h old for r(u)
Zhang/Möller
47
Efficient Form

l0 = p0
r3 = p3
l1 = ½(p0 + p1)
r1 = ½(p2 + p3)
l2 = ½(l1 + ½( p1 + p2))
r1 = ½(r2 + ½( p1 + p2))
l3 = r0 = ½(l2 + r1)

Requires only shifts and adds!

© 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

• Equating and solving, we find


© Machiraju/Zhang/Möller
p=M -1
B MI
49
Matrices

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

Bezier Interpolating B Spline

© 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

original and kept


© Machiraju/Zhang/Möller
new
– 52
Second Subdivision

16 final points for


1 of 4 patches created
© Machiraju/Zhang/Möller
53
Normals
• For rendering we need the normals if we
want to shade
– Can compute from parametric equations

– Can use vertices of corner points to determine


– OpenGL can compute automatically

© 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:

• first idea - go step by step, i.e.:

© Machiraju/Zhang/Möller
56
Subdivision Schemes
• Same for surfaces:

• How can we find those new points?


• What about triangles/arbitrary polygons?

© 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

Edge Rule Vertex Rule

© 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

You might also like