Você está na página 1de 169

CPSC 589/689 Course Notes

Faramarz Samavati ∗
Fall 2013

This document presents material that is covered in the modeling for computer graphics CPSC
589/689 at the University of Calgary. The original set of notes was taken and prepared by my
graduate students John Brosz and Reza Pakdel. The set of notes has been constantly modified
since that time.
*************************************************************************


Please notify amahdavi@ucalgary.ca of typos or mistakes.

I
Contents
1 Parametric Curves 1
1.1 3D Curves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 Tangent Vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.3 Normal Vectors for 2D Curves . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.4 Parametric Continuity Versus Geometric Continuity . . . . . . . . . . . . . . . . . 5
1.5 Polynomial Curves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

2 Bézier Curves 8
2.1 Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.2 Tangent Vector to Bézier Curve . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.3 Some Properties of Bézier Curves . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.4 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.5 de Casteljau Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.6 Geometric Interpretation of de Casteljau Algorithm . . . . . . . . . . . . . . . . . 13
2.7 Disadvantages of Bézier Curves . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.7.1 Lack of local control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.7.2 High Degree Curve . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.8 Properties of an Ideal Curve . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.8.1 Properties of an Ideal Basis Function . . . . . . . . . . . . . . . . . . . . 16

3 B-Spline Curve 17
3.1 Spline Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.1.1 Piecewise Polynomials . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.1.2 Definition of Spline Function . . . . . . . . . . . . . . . . . . . . . . . . 18
3.2 Polynomials of Order K . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.3 Polynomials as a Vector Space . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.3.1 Important Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.4 B-spline Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.4.1 Recursive Definition of the B-spline Basis . . . . . . . . . . . . . . . . . . 20
3.4.2 Definition of Knots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.4.3 1st Order B-splines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.4.4 2nd Order B-splines (Linear B-splines) . . . . . . . . . . . . . . . . . . . . 21
3.4.5 3rd Order B-splines (Quadratic B-splines) . . . . . . . . . . . . . . . . . . 23
3.4.6 4th Order B-splines (Cubic B-splines) . . . . . . . . . . . . . . . . . . . . 24
3.5 B-spline Basis Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.6 B-spline Curves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

II
3.7 Properties of B-spline Curves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.7.1 Affine Invariance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.7.2 Convex Hull Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.7.3 Local Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.8 Knot Sequences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.8.1 Non-uniform Knot Sequences . . . . . . . . . . . . . . . . . . . . . . . . 31
3.8.2 Multiple Knots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3.8.3 Interpolating Knot Sequence . . . . . . . . . . . . . . . . . . . . . . . . . 33
3.8.4 Bézier Curves as a special case of B-spline Curves . . . . . . . . . . . . . 36
3.9 Sums of B-splines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
3.9.1 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
3.9.2 Brute-force . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
3.9.3 δ index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
3.9.4 Order Reduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
3.10 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

4 Non-Uniform Rational B-Splines (NURBS) 42


4.1 Represenation of circles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
4.2 Basis Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
4.3 Basis Function Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
4.4 Curve Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
4.5 Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46

5 Parametric Surfaces 47
5.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
5.1.1 Normals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
5.1.2 Benefits of Parametric Surfaces . . . . . . . . . . . . . . . . . . . . . . . 50
5.2 Curve Based Surfaces(Common Surfaces) . . . . . . . . . . . . . . . . . . . . . . 53
5.2.1 Ruled Surfaces (Lofted Surfaces) . . . . . . . . . . . . . . . . . . . . . . 53
5.2.2 Bilinearly Blended Surfaces: Coons Patches . . . . . . . . . . . . . . . . . 56
5.2.3 Surfaces of Revolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
5.2.4 Rotational Blending Surface . . . . . . . . . . . . . . . . . . . . . . . . . 60
5.2.5 Sweep Surfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
5.2.6 Cross Sectional Blending Surfaces . . . . . . . . . . . . . . . . . . . . . . 65
5.3 Free Form Parametric Surface . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
5.3.1 Bézier Surface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
5.3.2 B-spline Surfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
5.3.3 NURBS Surfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75

III
5.3.4 Properties of Parametric Surfaces . . . . . . . . . . . . . . . . . . . . . . 76

6 Mesh 77
6.1 Neighborhood . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
6.2 Topology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
6.3 2D Manifolds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
6.4 Orientability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
6.5 Euler Characteristic Equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
6.6 Basic Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
6.6.1 Finding Normals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
6.6.2 Laplacian . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
6.6.3 Vertex Removal and Edge Collapse . . . . . . . . . . . . . . . . . . . . . 83
6.7 Data Structure for Polygonal Meshes . . . . . . . . . . . . . . . . . . . . . . . . . 86
6.7.1 Face-Vertex List representation . . . . . . . . . . . . . . . . . . . . . . . 86
6.7.2 Half-edge data structure . . . . . . . . . . . . . . . . . . . . . . . . . . . 87

7 Subdivision Methods: Curves and Tensor-Product Surfaces 90


7.1 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
7.2 Knot Insertion Process for Subdividing B-splines . . . . . . . . . . . . . . . . . . 90
7.2.1 Cubic B-spline Subdivision . . . . . . . . . . . . . . . . . . . . . . . . . 91
7.2.2 Filters For General B-spline Subdivision . . . . . . . . . . . . . . . . . . . 92
7.3 Matrix Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
7.4 Open and Closed Curves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
7.5 Subdivision Without Knot Insertion . . . . . . . . . . . . . . . . . . . . . . . . . 96
7.5.1 Analysis Of Subdivision Methods . . . . . . . . . . . . . . . . . . . . . . 96
7.6 Non B-spline Subdivision . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
7.6.1 Dyn-Levin Interpolating Subdivision Scheme . . . . . . . . . . . . . . . . 98
7.7 Tensor Product Surfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
7.7.1 Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
7.7.2 Volumetric data sets: 3D images . . . . . . . . . . . . . . . . . . . . . . . 101

8 Subdivision for Polygonal Meshes 103


8.1 Doo-Sabin Subdivision . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
8.1.1 Types of New Faces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
8.1.2 Subdivision Mask . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
8.1.3 Construction of the New Faces . . . . . . . . . . . . . . . . . . . . . . . . 106
8.1.4 Properties of Doo-Sabin Subdivision Surfaces . . . . . . . . . . . . . . . . 106
8.2 Loop Subdivision . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107

IV
8.2.1 Face Split . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
8.2.2 Repositioning by Masks . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
8.2.3 Boundaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
8.2.4 Sharp Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
8.2.5 Properties of Loop Subdivision . . . . . . . . . . . . . . . . . . . . . . . 113
8.3 Catmull-Clark Subdivision . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
8.3.1 Face split . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
8.3.2 Boundary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
8.3.3 Creases and Corners . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
8.3.4 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
8.4 Butterfly Subdivision . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
8.5 Adaptive Subdivision . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
8.5.1 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
8.5.2 Adaptive Loop Subdivision . . . . . . . . . . . . . . . . . . . . . . . . . . 116
8.5.3 Adaptive Catmull-Clark Subdivision . . . . . . . . . . . . . . . . . . . . . 119

9 Multiresolution, Wavelets, and Reverse Subdivision 121


9.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
9.2 Harr Wavelets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
9.2.1 Interpretation of D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
9.2.2 Decomposition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
9.3 Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
9.3.1 Data Transmission . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
9.3.2 Image Compression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
9.3.3 Video Compression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
9.4 Multiresolution Filter Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
9.5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
9.5.1 Local B-Spline Wavelets . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
9.6 Chaikin reverse subdivision . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
9.6.1 Boundary filters for quadratic B-Spline Wavelets . . . . . . . . . . . . . . 139
9.6.2 Efficient Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
9.7 Example Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
9.7.1 Curve by Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
9.7.2 Removing noise from Curves . . . . . . . . . . . . . . . . . . . . . . . . 144
9.7.3 Image Compression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
9.7.4 Terrain by Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146

V
10 Solid Modeling 147
10.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
10.2 Trivariate Hyper Patches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
10.3 Implicit Modeling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
10.3.1 Benefit of Implicit Modeling . . . . . . . . . . . . . . . . . . . . . . . . . 150
10.3.2 Normal to the Implicit Surface . . . . . . . . . . . . . . . . . . . . . . . . 150
10.3.3 Implicit Representation of Primitives . . . . . . . . . . . . . . . . . . . . 151
10.3.4 Point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
10.3.5 Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
10.4 Boolean Operations on Implicit Models . . . . . . . . . . . . . . . . . . . . . . . 153
10.5 Blending . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
10.5.1 Better Blending . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
10.6 Rendering Implicit Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
10.6.1 Ray-Sphere Intersection . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
10.6.2 Ray-Tracing for other primitives . . . . . . . . . . . . . . . . . . . . . . . 158
10.7 Constructive Solid Geometry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
10.8 Rendering CSG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160

11 Procedural modeling 163

VI
1 Parametric Curves
The goal of this section is to provide knowledge about parametric curves and to illustrate the key
properties of parametric curves.
A parametric curve is a mathematical formulation for describing objects. The two major ways
of mathematically representing curves are known as explicit and implicit. Each of these types of
representation has different advantages and disadvantages making them each more or less suitable
for different applications.
The explicit representation of a curve is the form we are probably most familiar with. In
this form, we directly define the curves from the mathematical description. Given an implicit
representation of a curve, membership function separates points on the curve from points not on
the curve. A typical implicit function for two dimensions has the form f (x, y) = 0. We will work
more with such functions later when we deal with implicit objects.
Parametric curves are important cases of explicit representation. Intuitively, it describes a con-
tinuous deformation of a line segment to a 2D or 3D curve. A typical two dimensional parametric
curve would have two independent component Q(u) = (x(u), y(u))
x(u) = Fx (u)
y(u) = Fy (u)

Example 1.1

3
The parametric equation of 4
of a circle with radius R.
3
Q(u) = (x(u), y(u)) = (R cos u, R sin u) 0≤u≤ π
2
Our parameter is u, the domain is I = [0, 23 π].

1
If we change the notation by replacing u with t, we obtain:

Q(t) = (x(t), y(t)), t ∈ I

We can think about this curve as a moving particle. Here, t represents the time and Q(t) will
then represent the path or trajectory of the particle. Parametric representation is not only a way
of modeling curved objects in graphics, but also can be used for moving objects and cameras in
animation.

1.1 3D Curves
Parametric curves can easily be extended from two dimensions to three dimensions as follows:

Q(u) = (x(u), y(u), z(u)), u ∈ I

Example 1.2

A spiral with a radius of one unit.

Q(u) = (cos u, sin u, u), u ∈ [0, 2πn]

2
Any curve can have many parametric representations. The particle can follow the same path but
with different speeds of movement. For example consider a basic line, we can have Q(u) = (u, u),
Q(u) = (2u, 2u), or Q(u) = (3u, 3u). The plot of each of the lines is the same, but the movement
along each line as the parameter changes is different.

Example 1.3

Two circles.
Q1 (t) = (cos u, sin u) 0 ≤ u ≤ 2π
Q2 (t) = (cos 2u, sin 2u) 0≤u≤π
These circles have the same path but different movement.

Example 1.4

An ellipse.
Q(u) = (a cos u, b sin u) 0 ≤ u ≤ 2π
1
a and b are 2
the length of the major and minor axes.

A major benefit of parametric curves is that they are exceedingly easy to draw algorithmically.
The following pseudo-code demonstrates this simplicity by approximating a parametric ellipse.
The value of inc can control the quality of the approximation.

3
Algorithm 1.1 Pseudo code for a parametric ellipse.
// input a, b, inc=0.1
for u = 0 to 2π step inc
x = a cos u
y = b sin u
plot(x,y)
end

1.2 Tangent Vectors


Finding the tangent vector of a parametric curve in two dimensions is quite simple. What we
require in mathematical form is:
 
dQ(u) dx(u) dy(u)
T (u) = = , = (x0 (u), y 0 (u))
du du du
We can evaluate this tangent function at any parameter value. We can think of this tangent function
as a vector value function where for any parameter value we enter a tangent vector for that point
of the curve. If u represents the time of a moving particle, T (u) shows the velocity vector at u.

Example 1.5

Tangent vector of an ellipse.

T (u) = (−a sin u, b cos u) 0 ≤ u ≤ 2π

T (π/2) = (−a, 0)

4
1.3 Normal Vectors for 2D Curves
To find the normal vector at a point on the curve (2D), we must remember that the normal vector
is the tangent rotated by 90◦ . We can find the normal vector by rotating T (u) with a 90◦ rotation
matrix.
 0
cos π2 − sin π2 −y 0 (u)
   
x (u)
N (u) = =
sin π2 cos π2 y 0 (u) x0 (u)

Example 1.6

Normal of an ellipse.
N (u) = (−b cos u, −a sin u)
π π
so at u = , N ( ) = (0, −a)
2 2

This rotation works when we are working in two dimensions. In 3D, the normal of a curve
is not described by a single vector. Rather the normal can be thought of as a plane perpendicular
(orthogonal) to the the curve. If a single vector is desired though, a π2 rotation along any axis will
obtain a vector normal to the curve.

1.4 Parametric Continuity Versus Geometric Continuity


Assume a curve Q(u) is used to describe how an object moves through time. The object can move
in an infinite variety of ways along a given path by starting, stopping, and accelerating at different
points along the path. All of these trajectories have the same shape but their parameterizations are
different. Although these ways of moving do not have any impact on the geometry of the path, they

5
affect the parametric definition and its derivatives. Parametric continuity indicates a smoothness
of motion. Geometric continuity indicates a smoothness of trajectory (i.e., the smoothness of
the curve).

Example 1.7

(cos t, sin t) 0≤t<π
Q(u) =
(cos(3t − 2π), sin(3t − 2π)) π ≤ t < 34 π
In this example the time is compressed by a factor of three in the second segment. With this
example, we have an important change from our original parametric equation for a circle. Let’s
examine the tangent at u = π:
T (u) = (− sin t, cos t)

Left tangent: T (π) = (0, −1).


Right tangent: T (π) = (−3 × 0, 3 × −1) = (0, −3).

At this point, we do not have continuity for the first derivative while we have a smooth curve
at u = π. Note that the directions of left and right tangents are equal. Thus, we can conclude
that parametric continuity indicates the smoothness of motion while geometric continuity
indicates the smoothness of the curve.

1.5 Polynomial Curves


Polynomials are fundamental mathematical expressions and are frequently used in computer graph-
ics. They are easy and efficient to compute. A polynomial of u in degree n has a standard repre-
sentation of: p(u) = a0 + a1 u + ... + an un where an 6= 0. This standard representation is based on
the standard basis. Polynomial curves of degree one are linear.

Example 1.8

A straight line (degree one polynomial):

Q(u) = (a0 + a1 u, b0 + b1 u) u0 ≤ u ≤ u1

6
Now for a second degree polynomial.
   
x(u) a0 + a1 u + a2 u2
Q(u) = =
y(u) b0 + b1 u + b2 u2
or
Q(u) = P0 + P1 u + P2 u2
where      
a0 a1 a2
P0 = , P1 = , P2 =
b0 b1 b2
And third degree polynomials.
   
x(u) a0 + a1 u + a2 u2 + a3 u3
Q(u) = = = P0 + P1 u + P2 u2 + P3 u3
y(u) b0 + b1 u + b2 u2 + b3 u3

There is an important issue here: can we assume that Pi s are points? If we are allowed to as-
sume this, we will have a good and intuitive user interface, points instead of equations, or numbers.
To check the correctness of this assumption, we must remember that any arbitrary combination of
points is not necessarily meaningful. We are just able to use an affine combination of points.
Unfortunately, the standard basis can not form an affine combination of the points (why?). To
introduce an alternative basis functions for polynomials , consider the following equality:

1 ≡ (1 − u + u)

therefore
1 ≡ (1 − u + u)2 =⇒ (1 − u)2 , 2u(1 − u), u2
1 ≡ (1 − u + u)3 =⇒ (1 − u)3 , 3u(1 − u)2 , 3u2 (1 − u), u3 )
.
Using these functions, the parametric curves can be defined accurately:

Q2 (u) = P0 (1 − u) + P1 [2u(1 − u)] + P2 (u2 )

Q3 (u) = P0 (1 − u) + P1 [3u(1 − u)2 ] + P2 [3u2 (1 − u)] + P3 (u3 )


These polynomials are called "Bernstein polynomials" and denoted by Bi,d (u)

B0,2 (u) = (1 − u)2 B0,3 (u) = (1 − u)3


B1,2 (u) = 2u(1 − u) B1,3 (u) = 3u(1 − u)2
B2,2 (u) = u2 B2,3 (u) = 3u2 (1 − u)
B3,3 (u) = u3

7
and in general  
d
Bi,d (u) = ui (1 − u)d−i
i
The resulting polynomial curve is called a Bezier curve when we consider [0,1] as the parameter
domain.
Xd
Qd (u) = Pi Bi,d (u) 0≤u≤1
i=0

2 Bézier Curves
2.1 Definition
Bézier curves are parametric curves based on Bernstein polynomials. This kind of curves was first
described in 1972 by Pierre Bézier1 . Bézier curve is defined as
d
X
Q(u) = Bi,d (u)Pi 0≤u≤1
i=0

   
d i d−i d d!
Bi,d (u) = u (1 − u) =
i i i!(d − i)!

Where Pi are given points that are called control points.

Example 2.1
Given control points P0 = (0, 0), P1 = (4, 2), P2 = (8, 0), find the Bézier curve values Q2 (0),
Q2 ( 12 ) and Q2 (1).
n
X
Q2 (u) = Bi,2 (u)Pi 0≤u≤1
i=0

Q2 (u) = (1 − u)2 P0 + 2(1 − u)uP1 + u2 P2


1
Pierre Etienne Bézier (1910 - 1999), born in Paris, obtained a degree in electrical engineering in 1931 at the
Ecole Superieure d’Electricite’, and a doctorate in 1977 in mathematics from the University of Paris. He worked for
Renault from 1933 - 1975, where he developed his UNISURF CAD/CAM system.

8
• Q2 (0) = (1 − 0)2 P0 + 2(1 − 0)0P1 + 02 P2 = P0 = (0, 0)

• Q2 ( 21 ) = 14 P0 + 12 P1 + 14 P2 = (0, 0) + (2, 1) + (2, 0) = (4, 1)

• Q(1) = 0P0 + 0P1 + P2 = P2 = (8, 0)

In this example, the resulting curve interpolates the first and last controls points, but not nec-
essarily the other controls points. In general, Bézier curves interpolate the first and last control
points.

2.2 Tangent Vector to Bézier Curve


Since Bézier curves are parametric curves, we again find their tangents by taking the derivative. In
the case of 2D curves, we have
dQ(u)
T (u) = = (x0 (u), y 0 (u))
du

Example 2.2

Calculate T (0) and T (1) of the Bézier curve in example 2.1.

T2 (u) = Q02 (u) = −2(1 − u)P0 + 2(1 − u)P1 − 2uP1 + 2uP2

9
• T2 (0) = −2P0 + 2P1 = 2(P0 − P1 )

• T2 (1) = −2P0 + 2P2 = 2(P2 − P1 )

Hence, the vector P1 − P0 shows the direction of tangent of Q2 (u) at u = 0 and the vector P2 − P1
shows the directions of the tangent at u = 1.

For the general degree d, we have

T (0) = d(P1 − P0 ), T (1) = d(Pd − Pd−1 )

2.3 Some Properties of Bézier Curves


• Qd (u) interpolates control points P0 and P1 .

• P1 − P0 is the tangent vector of curve Qd (u) at u = 0.

• Pd − Pd−1 shows the direction of tangent of curve Qd (u) at u = 1.

• d + 1 control points produce curve of degree d. If more control over the curve is required,
the number of control points must be increased resulting in a higher degree curve.

2.4 Implementation
Algorithm 2.1 shows pseudo-code for implementation of Bézier curves by directly using the defi-
nition.

Algorithm 2.1 Brute-force implementation of Bézier curve.


1 // Input P[i], d
2 // P[i]:control point, d:degree, u:parameter
3 for u=0 to 1 step 0.01
4 for i=0 to d
5 b = Bernstein(i, d, u)
6 q = q + b * P[i]
7 end
8 plot(q)
9 end

10
The disadvantage of this algorithm is that many redundant computations are performed. For
example B2,5 (u) and B3,5 (u) are two basis functions evaluated independently in line 5, while we
know    
5 2 3 5
B2,5 (u) = u (1 − u) B3,5 (u) = u3 (1 − u)2
2 3
The term u2 (1 − u)2 is commonly used in both B2,5 (u) and B3,5 (u), but it is redundantly com-
puted when they are evaluated. Algorithm 2.1 is a divide-and-conquer algorithm with a top-down
design and it suffers from redundant computations. An alternate approach is to use a dynamic
programming algorithm such as the de Casteljau algorithm.

2.5 de Casteljau Algorithm


Consider the second degree Bézier curve Q2 (u) for a given u and control points P0 , P1 , P2 . The
value of the curve, P02 , can be found from figure 2.1.

P02 = (1 − u)P01 + uP11 = (1 − u)


P02 = (1 − u) [(1 − u)P0 + uP1 ] + u [(1 − u)P1 + uP2 ]
P02 = (1 − u)2 P0 + 2u(1 − u)P1 + u2 P2

Figure 2.1: de Casteljau algorithm with example of P02

11
Example 2.3

Find Q2 (0) and Q2 ( 12 ) using de Casteljau algorithm.

The de Casteljau algorithm is a column-by-column updating algorithm that starts from control
points P0 , P1 , . . . , Pd . The rule Pjnext = (1 − u)Pjcurr + uPj+1
curr
is used to create a new smaller
column of control points. After d − 1 repeats of this rule, P0 will contain the curve value, Q(u).
Algorithm 2.2 shows the pseudo-code for the de Casteljau algorithm.

Algorithm 2.2 de Casteljau algorithm.


1 // input P[j], d, u
2 // P[j]: control point, d: degree, u: parameter
3 //output will be Q(u)
4 for i = 1 to d
5 for j = 0 to d-i
6 P[j] = (1-u)*P[j] + u*P[j+1]
7 end
8 end
output p[0]

12
Example 2.4

Compute Q3 ( 12 ) given the control points P0 = (4, 0), P1 = (8, 2), P2 = (0, 2), P3 = (0, 0).

2.6 Geometric Interpretation of de Casteljau Algorithm


A more intuitive method of following the de Casteljau algorithm is as follows:

• Draw a new point between P0 and P1 . This point will be uP0 + (1 − u)P1 .

• Draw a new point between P1 and P2 such that Pnew = uP1 + (1 − u)P2 .

• Repeat until there is a new point between all the old points.

• Discard all the old points, and repeat the previous steps until one point is left.

• The remaining point is Q(u).

Figure 2.2 shows the step by step process of finding P03 at u = 12 .

13
P2
1
P1
P1

1 P2 P03 P12 P02


P 0
0

P3
P0

Figure 2.2: Interpretation of de Casteljau algorithm.

2.7 Disadvantages of Bézier Curves


2.7.1 Lack of local control
Since Bézier curves are defined as a linear combination of all control points, a change to any of the
control point alters the entire curve. This is due to the nature of Bernstein polynomials which are
non-zero over the entire parametric domain (figure 2.4). The set of parameters in which the basis
function is active is called the support of the function. Figure 2.3 shows an example where one
control point is moved causing the whole curve to change.

14
Figure 2.3: Editing control points affect the whole Bézier curve.

Figure 2.4: Plot of Bernstein polynomials of degree 3. All of these polynomials are non-zero for
0 ≤ u ≤ 1.

15
2.7.2 High Degree Curve
From the definition of the Bézier curve, the degree of the curve directly depends on the number of
control points (number of control points = d + 1). For a detailed curve, a large number of control
points will be required. Having a large number of control points requires high polynomials to be
evaluated. This is expensive to compute and can be unstable due to numerical round-off.

2.8 Properties of an Ideal Curve


We would like to have a curve that is defined as sum of blending functions Bi,k (u) given the control
points P0 , P1 , . . . , Pd .
d
X
Q(u) = Pi Bi,d (u) a≤u≤b
i=0

The properties of curve Q(u) are the direct result of blending functions Bi,k (u). What would be
the properties of an ideal basis function then?

2.8.1 Properties of an Ideal Basis Function


Easy and efficient computation. To generate curves rapidly, we require computationally simple
and stable basis functions. These considerations lead us to choose low degree polynomials.

Sum to unity at every u. The basis functions must sum to 1 at u so the set of control points can
be linearly combined. We require linear combination of control points to have invariance under
affine transformations.

Local support for a ≤ u ≤ b. To have the local control property for the curve, the basis functions
should only be active (non-zero) within a small range. Polynomial functions cannot have local
support because a polynomial of degree d is zero in at most d + 1 distinct points. Functions with
local support must be zero at infinite points.

Have sufficient smoothness. The smoothness of curve Q(u) depends on the smoothness of the
basis functions. For example, if every basis function is C1 in [a, b], then Q(u) will also be C1 in
range [a, b].

16
3 B-Spline Curve
3.1 Spline Functions
3.1.1 Piecewise Polynomials
While polynomials do not satisfy our wish-list in section 2.8.1, piecewise polynomial functions
do. Figure 3.1 shows several examples of functions that are piecewise polynomial. Each function
consists of several polynomial segments. The points at which a pair of individual segments meet
are called joints. The value of u at which two segments meet is called a knot.
f2(u)
f1(u)

f(u) u2

u2
u f(u)

2
-u
0
u

{
2

{
u u>0 u2 u>0
f1(u)= f1(u)=
-u2 u<0 0 u<0
Segments: 2 Segments: 2
Degree: 2 Degree: 2
Smoothness(Continuity): 1 Smoothness(Continuity): 1

f4(u)
f3(u) f(u)
u2
2
u

f(u) u
-u2
u 5u
3u

{
u2 u>0
f1(u)=
3u u<0
Segments: 2
{ u2 u>0
f1(u)= -u2
5u u<0
0<u<1

Degree: 2 Segments: 3
Smoothness(Continuity): 0 Degree: 2
Smoothness at 1: -1
Smoothness at 0: 0

Figure 3.1: Piecewise polynomial functions.

17
3.1.2 Definition of Spline Function
For a given knot sequence, a nth-degree spline function is a piecewise polynomial of degree n
that is (n − 1) smooth (continuous) at each knot. Figure 3.2 shows a spline functions and its
components.

Joints
Segments

u0 u1 u2 u3 u4
Knots

Figure 3.2: A spline function.

3.2 Polynomials of Order K


We will focus on order k polynomials and splines. By this we mean polynomials having precisely
k coefficients (this includes coefficients equal to zero).

Example 3.1

General form of an order four polynomial:

p(u) = a0 + a1 u + a2 u2 + a3 u3 (ai = 0 or ai 6= 0)

This includes cases such as:

• p(u) = 1 + 5u − 2u2 + u3

• p(u) = 1 − 2u3

• p(u) = 5u (equivalent to p(u) = 0 + 5u − 0u2 + 0u3 )

18
• p(u) = 0 (equivalent to p(u) = 0 + 0u − 0u2 + 0u3 )

but not the case p(u) = 6u4 .

As a consequence, 4th order polynomials are the polynomials having at most degree 3. This
means that the k th order polynomials include all polynomials up to and including those of degree
k − 1.

3.3 Polynomials as a Vector Space


Actually all polynomials of order k, Pk , form a vector space.

• {1, u, u2 , ..., uk−1 } is the standard basis of Pk .

• Bernstein polynomials B0,k−1 (u), B1,k−1 (u), ..., Bk−1,k−1 (u) form another basis of Pk .

We can represent any k th order polynomial as a linear combination of basis elements.

Example 3.2

Standard and Bernstein basis.

{1, u, u2 , u3 } and {(1 − u)3 , 3u(1 − u)2 , 3u2 (1 − u), u3 } are two basis sets of P4 .

Consider p(u) = 1 − 3u + 3u2 − 2u3 = (1 − u)3 − u3 .

p(u) is represented by (1, −3, 3, −2) using the standard basis and (1, 0, 0, −1) using Bernstein
basis.

3.3.1 Important Questions


• What is a good basis for spline space?

• Or, what kind of functions can be swapped with the Bernstein functions?

19
3.4 B-spline Functions
Our goal is to replace the Bernstein basis with a set of basis functions for splines. "B-spline"
functions form a very good basis set for splines. Although the literature offers many different
approaches to formulating B-splines, there is a recursive relation that fits to our approach.

3.4.1 Recursive Definition of the B-spline Basis


For a given knot sequence {u0 , u1 , u3 . . .}, the first order B-spline is:

1 ui ≤ u ≤ ui+1
Ni,1 (u) =
0 otherwise

and for higher order B-splines (r>1)


u−ui ui+r −u
Ni,r (u) = N
ui+r−1 −ui i,r−1
(u) + N
ui+r −ui+1 i+1,r−1
(u)

This equation is known as the deBoor-Cox recursion. It specifies how to construct an order r
function from two B-spline functions of order r − 1.

3.4.2 Definition of Knots


Knots are the parameter values where the polynomial functions that compose splines join one
another. Therefore, they have a direct impact on the basis functions.
In order to understand these functions, we study B-splines of orders one, two, three and four in
the next section.

3.4.3 1st Order B-splines


We will first start with a simple uniformly spaced knot sequence as shown in figure 3.3.

u0 u1 u2 u3 u4 u5 u6
0 1 2 3 4 5 6

Figure 3.3: A uniform knot sequence.

This knot sequence generates a uniform B-spline. We will later change the knot sequence and
generate non-uniform B-splines. Consider 1-D points of {2, 3, 1, 4, 0.5, 2.5} to form a piecewise
constant function as the first order spline function

20
B(u) = 2N0,1 (u) + 3N1,1 (u) + 1N2,1 (u) + 4N3,1 (u) + 0.5N4,1 (u) + 2.5N5,1 (u).
We graph S(u) as

3
2.5
2

1
0.5

0 1 2 3 4 5 6

Figure 3.4: A first order B-spline curve: Piecewise constant functions.

Notice that how the "spline" function can be expressed by "B-spline" basis functions. It is also
important to note that the parametric space for a first order B-spline looks like:

2
N0,1(u) N1,1(u) N2,1(u) N3,1(u) N4,1(u) N5,1(u)
1

0 1 2 3 4 5 6 7

Figure 3.5: First order B-spline basis functions.

First order B-splines produce box functions that are useful in representing pixel values of im-
ages.

3.4.4 2nd Order B-splines (Linear B-splines)


Once again we will use the uniform knot sequence shown in figure 3.3. Our first task is to evaluate
our basis functions.
u − ui ui+2 − u
Ni,2 (u) = Ni,1 (u) + Ni+1,1 (u)
ui+1 − ui ui+2 − ui+1

21
This gives us
  
 u 0≤u<1  u−1 1≤u<2  u−2 2≤u<3
N0,2 (u) = 2 − u 1 ≤ u < 2 N1,2 (u) = 3 − u 2 ≤ u < 3 N2,2 (u) = 4−u 3≤u<4
0 otherwise 0 otherwise 0 otherwise
  

Notice that N0,2 , N1,2 , and N2,2 are merely shifted versions of one another. We can generalize
the formulas for these splines to
 u−ui
 ui+1 −ui ui ≤ u < ui+1
ui+2 −u
Ni,2 (u) = ui+1 ≤ u < ui+2
 ui+2 −ui+1
0 otherwise

. Figure 3.6 shows some of these basis functions.

0 1 2 3 4 5 6

Figure 3.6: Second order B-Spline basis functions.

Using the formula of Ni,2 (u), we can easily show that the sum of all basis functions over any u
in the range [1,5] is one. Notice the first interval [0,1] and the last interval [5,6] are "extra-ordinary"
cases. If we add up the value of the basis functions in these intervals, we find that in this section
of parametric space the basis functions do not add to one. Since we must have unit summation for
every point of the curve (in order to have affine transformation properties), we must restrict the
domain of u to areas that have unit summation.
As we examine the basis functions, we notice that we have produced "hat" functions. Such hat
functions produce linear interpolation between the control points.

22
0 1 2 3 4 5 6

Figure 3.7: A second order B-spline curve.

Second order B-splines result in piecewise linear functions (also called polylines). It is also
important to notice that such curves have C 0 continuity. Therefore, they are continuous functions.

3.4.5 3rd Order B-splines (Quadratic B-splines)


Again we assume equispaced knots in determining the shape of N0,3 (u).

u−0 3−u u 3−u


N0,3 = N0,2 (u) + N1,2 (u) = N0,2 (u) + N1,2 (u)
2−0 3−1 2 2
 u2
0≤u<1
 32


− (u − 32 )2 1≤u<2
N0,3 (u) = 4
1
(3 − u)2 2≤u<3
 2


0 otherwise
. With our uniform knot sequence, we can produce our other basis functions by shifting N0,3 .

Ni,3 (u) = N0,3 (u − i)

Note that this equation only works for the uniform knot sequence and not an arbitrary knot se-
quence. The recursive formula is correct for both cases.

23
Figure 3.8: Third order B-Spline basis functions.

The resulting B-spline curve is of order 3, degree 2, and has C 1 continuity. That is, the curve
is continuous and also has a continuous derivative at each and every knot.

3.4.6 4th Order B-splines (Cubic B-splines)


Once again we assume a uniformly spaced integer sequence of knots giving us the formula:
u−0 4−u u 4−u
N0,4 = N0,3 (u) + N1,3 (u) = N0,3 (u) + N1,3 (u)
3−0 4−1 3 3
 1 3

 6
u 0≤u<1
1 3 2
(−3(u − 1) + 3(u − 1) + 3u − 2) 1 ≤u<2


 6
1 3 2
N0,4 (u) = 6
(3(u − 2) − 6(u − 2) + 4) 2≤u<3
1 3
(4 − u) 3≤u<4


 6


0 otherwise
As before, we can produce the other basis functions N1,4 (u), N2,4 (u), ..., Nm,4 (u), by shifting
the indices of N0,4 (u). It is important to remember that the above equation only is correct for a
uniform knot sequence.

24
Figure 3.9: Fourth order B-Spline basis functions(Ni,4 ) .

Our resulting B-spline curve is of order 4, degree 3, and has C 2 continuity. That is, the curve is
continuous and also has a continuous first and second derivative at each knot. Fourth order B-spline
are used quite often in many applications as the human visual system has difficulty recognizing
anything more than C 2 continuity.

3.5 B-spline Basis Properties


Consider N0,k (u), N1,k (u), . . ., Nm,k (u) on the knot sequence {u0 , u1 , u3 . . .}.

• The set of all k th order B-spline functions forms a basis set for k th order splines.

Ni,k (u) > 0 ui < u < ui+k

Ni,k (u) = 0 otherwise
This yields both positivity (i.e., Ni,k is always greater than 0) and compact support (i.e.,
the basis function only affects the curve over the range [ui , ui+k ]).

• At every point within parameter space ([uk−1 , um+1 ]), we have unit summation (that is, the
sum of all basis functions is one). This can be proven using mathematical induction on the
recursive formula.

3.6 B-spline Curves


The definition of B-Spline curves is very similar to Bezier curve’s. The only difference is that we
use B-Spline basis functions as blending functions (instead of Brenstein functions):
m
X
Q(u) = Pi Ni,k (u).
i=0

25
So to create a curve with the B-spline basis, we must keep in mind:

• We are given P0 , P1 , ..., Pm control points.


• The number of controls points : m + 1.
• We associate the control point Pi to the B-spline Ni,k (u)
• We need a set of knot values {u0 , u1 , . . . , um+k }.
• The parametric range is uk−1 ≤ u ≤ um+1 .

Knot Sequence
It is clear that the user should provide m + 1 control points. In order to evaluate Ni,k (u), a knot
sequence is also necessary. A knot sequence is a set of non-decreasing real numbers. The first basis
function N0,k (u) needs u0 , u1 , . . . , uk and the last basis function Nm,k (u) needs um , um+1 , . . . , um+k .
An example for third order B-splines is shown in figure 3.10.

...
u0 u1 u2 u3 um um+k-2um+k-1 um+k

Figure 3.10: Required B-spline basis functions for a third order B-Spline curve.

Parameter Range
As a first guess, we might suspect that [u0 , um+k ] should be the parameter range. As mentioned
before, this has a serious problem in that we can only guarantee unit summation over the range
of [uk−1 , um+1 ]. This is due to the lack of enough basis functions at the beginning and end of the
range. To solve this problem, we make [uk−1 , um+1 ] the range of our parameter. Therefore we have
m
X
Q(u) = Pi Ni,k (u) uk−1 ≤ u ≤ um+1
i=0

for the given Pi (these may be 2D or 3D) and a fixed knot sequence {u0 , u1 , ..., um+k }. The clear
advantage of the B-spline basis is that m is not coupled with k. This gives us effective control over
the shape of the curve together with piecewise polynomials of a low degree.

Note that we have two different spaces:

26
• Parameter Space: this space is a subset of a real line that covers knot values. The basis
functions are defined in this space (see figure 3.10).

• Curve Space: this is the space of the control points. Consequently, this is an affine space
and usually is a two or three dimensional space. However, our construction method allows
us to use control points of any dimension.

Figure 3.11: The curve space for a third order B-spline.

Q(u) is a piecewise polynomial curve because the basis functions Ni,k (u) are piecewise polyno-
mials. The notation Qi (u) refers to the segment of the curve Q(u) that defines

Qi (u) = Q(u) ui ≤ u < ui+1

Q(ui) Qi(u)

Q(ui+1)

ui ui+1

Figure 3.12: The segment of the curve corresponding to the basis function Ni,k (u).

27
3.7 Properties of B-spline Curves
3.7.1 Affine Invariance
To avoid re-computation, it is desirable that transforming control points does not change the shape
of the B-spline curve. Let A be an arbitrary affine transformation including any combinations of
translation, rotation, shear and scaling. B-spline curves are invariant under affine transformations
(Figure 3.1):

Figure 3.13: Affine invariance property of B-Spline curves.

An affine transformation A can be written as

A(P ) = M P + v

where M is an n ∗ n matrix, v is an n-dimensional vector, and P is an n-dimensional point. Let


QA (u) represents the B-spline curve after transforming the control points
m
X
QA (u) = A(Pi )Ni,k (u)
i=0

, then we want to prove that


QA (u) = A(Q(u))
Using the definition of a B-spline curve and an affine transformation:
m
X m
X
QA (u) = A(Pi )Ni,k (u) = (M Pi + v)Ni,k (u)
i=0 i=0

28
m
X m
X
QA (u) = M Pi Ni,k (u) +v Ni,k (u)
i=0 i=0
| {z } | {z }
Q(u) 1

QA (u) = M Q(u) + v

QA (u) = A(Q(u))

Note that this property is one of the results of the basis functions having unit summation. If the
basis functions do not have the unit summation property, the resulting curve will change after an
affine transformation, say rotation. Since Bernstein basis functions also have the unit summation
property, Bézier curves are also invariant under affine transformations.

3.7.2 Convex Hull Property


A convex set is a collection of points in which the line connecting any pair of points is contained
within the set. Below, the set on the left is a convex set while the set on the right is not.

Figure 3.14: A convex set on left and a non-convex set on right.

The Convex Hull of a set of points is the smallest convex polyhedra that includes all the points.
The convex hull of the above sets are shown below

29
Figure 3.15: Convex hull of set of points

Intuitively, imagine that the points are a set of nails on a wall. We can find the convex hull of
the set of nails by fitting a rubber band around them. The convex hull of a pair of points is their
line segments; the convex hull of three points is a triangle. Mathematically, given a set of points
P = {P0 , P1 , . . . , Pm }:
( m m
)
X X
C(P) = P |P = ci Pi ; ci ≥ 0; ci = 1
i=0 i=0

the B-spline curve defined by control points P0 , P1 , . . . , Pm is contained inside their convex hull.
B-spline curves also meet the strong convex hull property, that is if u ∈ [ui , ui+1 ], then Q(u) is in
the convex hull of the control points Pi−k+1 , Pi−k+2 , . . . , Pi .

Figure 3.16: Convex hull property of B-splines

30
3.7.3 Local Control
The B-spline curve from set of points P0 , P1 , . . . , Pm only changes within the interval (ui , ui+k )
when point Pi is moved. This follows from the fact that Ni,k (u) = 0 when u ∈ / (ui , ui+k ).

Figure 3.17: Local control property of B-splines

3.8 Knot Sequences


Up to this point, we have used knots that are equidistant from each other. We can attain a greater
control over the shape of the B-spline curve by varying the spacing between the knots.

3.8.1 Non-uniform Knot Sequences


It is important to note that the exact knot values have no effect on the curve’s shape, although these
values do affect the range of the parameter (u). It is the relative spacing between the knots that
changes the curve. By reducing the space between two knots, we force the curve to place more
weight on the corresponding control points.

31
3.8.2 Multiple Knots
While the definition of B-spline curves allow us to change the spacing between knots, what happens
if there is no space between them? Consider the following sequence u = {0, 1, 1 + , 2, 3} in
Figure 3.18. The space within the interval [1, 1 + ) is squeezed to a narrow band.

Figure 3.18: Squeezing the interval by moving the knots close to each other.

If  is set to zero, then this space will vanish and we will have multiple knots at u = 1. We
then refer to this knot as having a multiplicity of 2. The multiplicity of knot ui is represented by
µi . The multiplicity is the number of the knots in the sequence with a value equal to ui .
Multiple knots cause the denominator in the fraction of the recursive formula of B-spline basis
functions to become zero. In this case, we define the whole fraction as zero. Figure 3.19 shows
an example of multiple knot sequences and the resulting changes to the basis functions in the
parameter space.

Example 3.3

Given the knot sequence u = {0, 1, 2, 3, 3, 4, 4, 4, 5, 5, 6, 7} the multiplicity of each u is µ0 =


1, µ1 = 1, µ2 = 1, µ3 = 2, µ4 = 2, µ5 = 3, µ6 = 3, µ7 = 3, µ8 = 2, µ9 = 2, µ10 = 1, and
µ11 = 1.

The result of multiple knots is a reduction in the smoothness or continuity of the resulting curve.
More precisely, the B-spline curve of order k has continuity k − 1 − µi at knot ui . Another effect of
multiple knots is stronger attraction towards the governing control point. By setting µi = k − 1 the

32
corresponding control points are interpolated rather than approximated. Adjusting the multiplicity
of each knot allows designers to change the shape of the B-spline curve. Figure 3.20 shows the
effect of multiple knots step by step.

(1) (1) (1) (1) (1) (2) (1) (1) (1)

(1) (2) (1) (1)


(1) (1) (2) (1)

(1) (1) (1) (2) (3) (1) (1)

(1) (3) (1) (1) (1) (3)

(4) (1) (1) (4)

Figure 3.19: Different multiple knot sequences. The numbers in brackets (e.g., (1)) indicate the
multiplicity of the knot.

3.8.3 Interpolating Knot Sequence


One special choice of knot sequence has become a standard for curve design and has some interest-
ing properties. This knot sequence starts and ends with a knot of multiplicity k and uses uniform
spacing for the remaining knots. The resulting B-spline curve interpolates the first and last control

33
points.

2
u={0,1,2,3,4,5,6,7,8,9,10,11,12,13} m=9,k=4 [u3,u10) 7 segments, C
B4,4(u)B5,4(u) v3 v4 v8 v7

v0 v9

v2 v1 v5 v6

1
u={0,1,2,3,4,5,5,6,7,8,9,10,11,12} 5
=2 6 segments, C
B4,4(u)
B5,4(u) v3 v4 v8 v7

v0 v9

v2 v1 v5 v6
0
u={0,1,2,3,4,5,5,5,6,7,8,9,10,11} 5
=3 5 segments, C
B4,4(u)
v3 v4 v8 v7
B5,4(u)
v0 v9

v2 v1 v5 v6

-1
u={0,1,2,3,4,5,5,5,5,6,7,8,9,10} 5
=4 4 segments, C
B4,4(u) B5,4(u)
v3 v4 v8 v7

v0 v9

v2 v1 v5 v6

Figure 3.20: The effect of multiple knot on cubic B-spline curve (k = 4).

34
Example 3.4

The knot sequence:


( )
u= 0 , |{z}
|{z} 0 , |{z}
0 , |{z}
0 , |{z}
1 , |{z}
2 , |{z}
3 , |{z}
4 , |{z}
5 , |{z}
5 , |{z}
5 , |{z}
5
u0 u1 u2 u3 u4 u5 u6 u7 u8 u9 u10 u11

is the interpolating knot sequence for k = 4 and m = 7. The parameter range is from [uk−1 , um+1 ] =
[0, 5]. The basis functions are shown in the figure below.

A better case is if the knot sequence is bound within [0, 1]. We call this standard or interesting
knot sequence.

Example 3.5

Find the standard knot sequence for k = 3 and m = 5

u = {0, 0, 0, ..., 1, 1, 1}

Remember that we need a knot sequence [u0 , um+k ] or [u0 , u8 ]. So, we need 9 knots. We already
have 6, so 3 more knots are required. Since the distribution of these 3 knots is uniform, 4 intervals
between [0, 1] are needed, making each 14 in length. So the knot sequence is
1 1 3
u = {0, 0, 0, , , , 1, 1, 1}
4 2 4
35
1
In general, the uniform step size is m−k+2
.

3.8.4 Bézier Curves as a special case of B-spline Curves


We can convert designs created by old software that used Bézier curves to use B-spline curves
instead. For example, we can convert meta-fonts to True-type fonts. If we use the standard knot
sequence without any non-boundary knots, the resulting curve will be a Bézier curve.

Example 3.6

For k = 3, the knot sequence {0, 0, 0, 1, 1, 1} gives a Bézier curve of degree 2.


For k = 4, the knot sequence {0,0,0,0,1,1,1,1} gives a Bézier curve of degree 3.

In general, we can show that Ni,k (u) = Bi,d (u), where k is the order of the B-spline curve and
d = k − 1 is the degree of the Bézier curve.

3.9 Sums of B-splines


3.9.1 Motivation
Since the B-spline curve
   Pm 
x(u) i=0 x i Ni,k (u)
Q(u) =  y(u)  =  Pm
P
i=0 yi Ni,k (u)

m
z(u) i=0 zi Ni,k (u)

evaluation of linear combinations of basis function is our primary concern in interactive rendering
of B-spline curves and surfaces. We use the following general notation of linear combinations:
m
X
S(u) = Ei Ni,k (u)
i=0

where Ei is given information. Note that Ei can play the role of xi , yi , zi or even Pi . The same
notation will reappear in evaluation of B-spline surfaces and NURBS. Hence, an efficient algorithm
for evaluation of S(u) is required.

36
3.9.2 Brute-force
Initially we use the brute-force method as outlined in algorithm 3.1. This algorithm has a number
of flaws. Firstly, there is an overlap of computations. For example to compute N3,5 , we must
compute N3,4 and N4,4 and to compute N4,5 , we must compute N4,4 again and N5,4 . Secondly, we
do not take the local support of basis functions into account. For example, if m = 1000 and k = 4,
for any given u there are only 4 non-zero basis functions, but our program will compute each of
them.

Algorithm 3.1 Brute force method of calculating S(u)


1 // E is global
2 function S(u,k,m)
3 s=0
4 for i=0 to m
5 s=s+E[i]*N(i,k,u)
6 end
7 return s
8 // knot sequence U is global
9 function N(i,k,u)
10 if k>1 return recursive
11 else if u>U[i] and u<U[i+1] return 1
12 return 0

3.9.3 δ index
To use the local support property of B-spline basis functions, we only compute those basis func-
tions that are non-zero. We know that Ni,k (u) is non-zero when u ∈ [ui , ui+1 ]. So we choose an
index δ , the index of focus, such that Nδ,1 (u) is non-zero. Meaning

uδ ≤ u < uδ+1

Example 3.7

u = [0, 1, 2, 3, 3, 4, 5, 5, 5, 6}, k = 3, m = 6
δ(2.8) = 2, δ(3) = 4, δ(3.1) = 4, δ(5) = 8

37
Algorithm 3.2 shows a very simple pseudo-code that finds δ from a given u.

Algorithm 3.2 Calculating δ index from u


1 // knot sequence U is global
2 function delta(u,m,k)
3 for i=0 to m+k-1
4 if u>=U[i] and u<U[i+1] return i
5 end
6 return -1

Note that this may not be very efficient and can be improved by using an incremental way as
illustrated in the Figure 3.21. In this method, when we increase u to traverse the entire parameter
range, we check whether it is passing a knot value; If so, then we add the current δ with µ.

Figure 3.21: Different multiple knot sequences. The numbers in brackets (e.g., (µ)) indicate the
multiplicity of the knot.

3.9.4 Order Reduction


As the second optimization step, we want to avoid redundant computations of basis functions
Ni,k (u). To do so, we can reduce the order from k to k − 1 in
m
X
S(u) = Ei Ni,k (u)
i=0

First we expand Ni,k (u)


m m
X u − ui X ui+k − u
S(u) = Ei Ni,k−1 (u) + Ei Ni+1,k−1 (u)
i=0
ui+k−1 − ui i=0
ui+k − ui+1

now shift i + 1 to i in the second summation:

38
m+1 m+1
X u − ui X ui+k−1 − u
S(u) = Ei Ni,k−1 (u) + Ei−1 Ni,k−1 (u)
i=0
ui+k−1 − ui i=0
ui+k−1 − ui

where the values of E−1 and Em+1 are taken to be zero.

[1]
Figure 3.22: Top table: computing Eδ from set of input Ei . Bottom image: one step of recurrence.

Then we factor Ni,k−1 (u)


m+1
X 
u − ui ui+k−1 − u
S(u) = Ei + Ei−1 Ni,k−1 (u).
i=0
ui+k−1 − ui ui+k−1 − ui

[k−1]
We have a new Ei as a linear combination of Ei and Ei−1 :
m+1
X δ
X
[k−1] [k−1]
S(u) = Ei Ni,k−1 (u) = Ei Ni,k−1 (u)
i=0 i=δ−k+2

39
If we keep repeating this process we will eventually arrive at
X [1]
S(u) = Ei Ni,1 (u).
i

Using the δ index, we can break the summation down to


[1]
S(u) = Eδ Nδ,1 (u) + 0 + 0 + 0 + . . . .
Using the fact that Nδ,1 = 1, we obtain
[1]
S(u) = Eδ .
[1]
To compute Eδ , we use the recursive formula
[r−1] u − ui [r] ui+r−1 − u [r]
Ei = Ei + E
ui+r−1 − ui ui+r−1 − ui+1 i−1
r = k, k − 1, k − 2, . . . , 2 i = δ, δ − 1, δ − 2, . . . , δ − r + 2
[1]
Figure 3.22 shows how Eδ can be iteratively computed from a set of input Ei . Algorithm 3.3
gives the pseudo-code for this.
[1]
Algorithm 3.3 Computing Eδ from set of input Ei .
1 // k: order of B-spline
2 // m: number of control points
3 // E: coefficient vector (control points), global
4 // U: knot sequence, global
5 // u: fixed parameter value
6 function E_delta_1(k, m, u)
7 d=delta(u,m,k)
8 for i=0 to k-1
9 c[i]=E[d-i]
10 end
11 for r=k to 2 step -1
12 i=d
13 for s=0 to r-2
14 omega=(u-U[i])/U[i+r-1]-U[i])
15 c[s]=omega*c[s]+(1-omega)*c[s+1]
16 i=i-1
17 end
18 end
19 Output c[0]

40
3.10 Exercises
1. Find an example of a curve which is C 1 but not G1 .

2. Show that Bézier curves are invariant under affine transformations.

3. Show that Bernstein polynomials Bi,d (u) and B-Spline basis functions are indeed Splines.
What is the Spline degree? Where are the knots?
i
4. Show that the Bernstein polynomial Bi,d (u) attains its maximum at u = d
. What is this
maximum value?

5. Use the de Casteljau algorithm to design a curve of degree 4 that has its middle control point
on the curve. i.e. P2 = P04 at u = 12 .

6. What happens if you replace a knot sequence {u0 , u1 , ..., un } by the reverse knot sequence
{un , ..., u1 , u0 } but leave the control points in their original ordering?

7. Show that if control points of a Bézier or B-Spline curve be co-planar, the curve will also be
planar.

8. For the case of a planar Spline curve, does symmetry of the control polygon with respect to
the y-axis imply the same symmetry for the curve?

9. Show that the nth order Bernstein polynomials can always be formed from the (n − 1)th
order versions using Bi,d (u) = (1 − u)Bi,d−1 (u) + uBi−1,d−1 (u) where B0,0 (u) = 1 and
Bj,d (u) = 0 when j isn’t in the range [0, n]
Hint:      
n n−1 n−1
= +
i i i−1

10. Show that Bézier curves are a special case of B-spline curves.

41
Figure 4.1: Approximation of circle by changing the order of B-Spline curves.

4 Non-Uniform Rational B-Splines (NURBS)


It is slightly hard to produce a perfect circle with B-Splines. Circles and arcs are important not
only as significant curve examples but also as a mojor structure for making surfaces such as surface
of revolution. Using non-uniform knot sequence and higher order B-Splines helps to have a better
approximation of circles (see Figure 4).
To have a even better approximation, a possible strategy is to change the weight or influence of
the control vertices: m
X
Qnew (u) = wi Pi Ni,k (u)
i=0

where wi shows the weight of the vertex Pi . We can change the influence of particular control
point directly through weights. This provides a very great flexibility to create arbitrary curves. For
instance, we increase the influence of the P 2 in the following example assigning weights:

Q(u) = w0 P0 N0,k (u) + w1 P1 N1,k (u) + w2 P2 N2,k (u) + w3 P3 N3,k (u)


w0 = w1 = w3 = 1, w2 = 2

The problem with this kind of weighted summation is that we no longer have the unit summation,
meaning that this formula results in a curve that is not affine. To resolve this issue, we can use
projective space. For better understanding the concept, we focus on 2D curves. In the first step,
we lift the 2D coordinates of control points Pi = (xi , yi ) to 3D Homoegenous representation
Pi = (xi , yi , 1). Using weights results non-affine control points wi Pi = (wi xi , wi yi , wi ). We

42
define associated 3D B-Spline curves as usual
m
X m
X m
X
Q(u) = ( wi xi Ni,k (u), wi yi Ni,k (u), wi Ni,k (u)).
i=0 i=0 i=0

In order to find the standard representation of this curve, we need to project it to the z = 1 plane
 Pm Pm 
i=0 w i x i Ni,k (u) i=0 wi yi Ni,k (u)
Q(u) = Pm , Pm ,1 .
i=0 wi Ni,k (u) i=0 wi Ni,k (u)

Figure 4 demonstrates this lift-project process. This normalization introduces rational terms in
the defention of the curve. This kind of curves is called Non-Uniform Rational B-Splines(NURBS).
To have a distinction with non-rational B-Splines we change the notation for NURBS curve from
Q(u) to R(u). So for the general case we have:
Pm
wi Pi Ni,k (u)
R(u) = Pi=0 m
i=0 wi Ni,k (u)

where wi is the weight of Pi and is non-negative. Notice the concept of lift-project also works for
higher dimensions.
Consider the case where all the weights are one. The curve simply becomes a B-spline curve.
This is also true anytime all the weights are constant. Figure 4.2 shows the curve’s attraction to
points with greater weights.

4.1 Represenation of circles


An advantage of NURBS is the possibility of exact representation of conic sections (especially
circles) by non-rational curves. For example the following setting
p p p p
(2) (2) (2) (2)
W = {1, , 1, , 1, , , 1, , 1},
2 2 2 2
1 1 1 1 3 3
U = {0, 0, 0, , , , , , , 1, 1, 1},
4 4 2 2 4 4
{Pi } = {(1, 0), (1, 1), (0, 1), (−1, 1), (−1, 0), (−1, −1), (0, −1), (1, −1), (1, 0)}
makes a perfect circle.

43
Figure 4.2: Lift-project process: (a) a regular 2D B-Spline. (b) the coresponding 3D view of (a).
(c) adding the weight of P2 . (d) The red curve shows the lifted 3D curve and the blue curve shows
its projection (NURBS).

4.2 Basis Functions


R(u) is not created using basis functions. We can represent R(u) with basis functions as follows:
w0 P0 N0,k (u) + w1 P1 N1,k (u) + ... + wm Pm Nm,k (u)
R(u) =
w0 N0,k (u) + w1 N1,k (u) + ... + wm Nm,k (u)

w0 P0 N0,k (u) w1 P1 N1,k (u) wm Pm Nm,k (u)


R(u) = Pm + Pm + ... + Pm
i=0 wi Ni,k (u) i=0 wi Ni,k (u) i=0 wi Ni,k (u)
w N (u)
R(u) = m
P
Pm i i,k
i=0 Pi Ri,k (u) where Ri,k (u) = j=0wj Nj,k (u)

44
W0=W1=W2=W3=W4=W5=W6=1 W0=W1=W2=W3=W4=W6=1 W5=2.5
P2 P4 P2 P4
P5 P5

P1 P1
P3 P3

P0 P6 P0 P6

Figure 4.3: Changes to a curve with changes to weights.

4.3 Basis Function Properties


From this point on we will deal solely with the standard (interesting) knot sequence.

Figure 4.4: The standard knot sequence.

The rational basis functions inherit the properties of B-spline functions:


• Non negativity: Ri,k (u) ≥ 0 for all i, k, u ∈ [0, 1].

• Unit summation: m
P
i=0 Ri,k (u) = 1 for all u ∈ [0, 1].

• R0,k (0) = Rm,k (1) = 1.

• Local support: Ri,k (u) = 0 for u ∈


/ (ui , ui+k ).
Another very useful property of NURBS is that if wi = 1 for all i, then Ri,k (u) = Ni,k (u).
Open Question: What if wi = a for all i and a is some real number?

4.4 Curve Properties


NURBS satisfy all curve properties such as:
• Interpolation of end points: R(0) = P0 , R(1) = Pm .

• Affine invariance.

45
• Strong convex hull property. Remember this means that if u ∈ [ui , ui+1 ] then R(u) lies with
the convex hull of the control points Pi−k , ..., Pi .

• Local control: if a control point, Pi , is moved or the weight, wi , is changed only the portion
of the curve on the interval u ∈ [ui , ui+k ] is affected.

• NURBS curves are also invariant under perspective projections.

We can see that NURBS offer a great deal of flexibility. They have control points to provide an
outline of the curve, they allow knot movement and multiple knots, and they offer weight control.
NURBS are also special in that they can produce exact conic sections (especially circles) that are
very useful for the CAD industry. B-splines and Bezier curves can be seen as specials cases of
NURBS.

4.5 Algorithm
To create an efficient algorithm for NURBS, the lift/project approach
Pm
wi Pi Ni,k (u)
R(u) = Pi=0m ,
i=0 wi Ni,k (u)

works better than the rational basis functions. We use the algorithm resulting from the order reduc-
tion of B-splines. It is clear to see that we now need to evaluate the sum of B-splines algorithms for
two times (for wi Pi , and wi ). In order to make this algorithm even more efficient, it is important to
notice that changes to the position of the control points result in no change to the denominator of
the equation.

46
5 Parametric Surfaces
5.1 Introduction
Earlier we found that a single parameter gives us great flexibility in creating curves. For surfaces,
our parameter space becomes two dimensional, thus we use two parameters. One parameter can
only cover a line, for a surface we must have a covering of 2D domains (two parameters). As a
side note, to parametrically define a volume, we would use a three dimensional parameter space.
We will mostly consider rectangular domain as parameter space.

3 2
 : A ⇒ E, A ⊆ E
Q(u, v)
X(u, v)
Q(u, v) = Y (u, v)  (u, v) ∈ A

Z(u, v)

Example 5.1
 
cos u
Q(u, v) =  sin u  0 ≤ u < 2π, 0 ≤ v < 1 defines a cylinder.
v

47
To display the cylinder or any other parametric surface we must, as with parametric curves,
discretize our parametric domain. We choose a discrete sample of our parameters (usually in a
uniform way). In our cylinder example we sampled 10 values for v from [0, 1] and 50 values for u
from [0, 2π]. For each u and v we have a 3D point on the surface. These points can then be used to
polygonize the surface.

Algorithm 5.1 Discretized sample of a surface’s parameter space.


π
1 for u=0 to 2π step 25
2 for v=0 to 1 step 0.1
3 point = Q(u,v)

Having Q(u, v) we can define two important sets of embedded curves. By letting v vary while
keeping u constant we generate a curve called a v-curve. Similarly, letting u vary while hold v
constant produces a u-curve.

Figure 5.1: A visualization of v-curves on a parametric surface.

48
Example 5.2
 
cos u
If we fix v = 0.2 then we get q(u) = Q(u, 0.2) =  sin u . This 3D curve is a u-curve.
0.2

Figure 5.2: u and v curves shown on a cylinder (u-curves are in blue, v-curves are in green).

5.1.1 Normals
The normal of a parametric surface is calculated from the tangents of u and v curves.
∂Q
• ∂u
is the tangent vector in the u direction.
∂Q
• ∂v
is the tangent vector in the v direction.

We then find the normal by taking the cross product of the tangents:
∂Q ∂Q
N (u, v) = ∂u
× ∂v
.

Example 5.3
Find the normal on the surface of a cylinder.

49
 
cos u
0 ≤ u ≤ 2π
Q(u, v) =  sin u 
0≤v≤1
 v   
− sin u 0
∂Q ∂Q
∂u
(u, v) =  cos u 
∂v
(u, v) = 0 

0 1
− sin u cos u 0

N (u, v) = 0 0 1 = i cos u + j sin u + 0k
i j k

5.1.2 Benefits of Parametric Surfaces


Although there are many different kinds of parametric surfaces, they all carry some common ben-
efits.
Texture Coordinates
Texture maps remain a popular technique for increasing detail in 3D modeling. Texture maps
can contain color information, information about the surface normal for use in bump maps, or any
other information useful to rendering. Parametric surfaces lend themselves immediately to texture
mapping, as the texture coordinates can usually be a function of the same two parameters that
define the surface. This function is usually just a very simple affine transformation.
For example, the parametric equations that describe a torus.

Q(u, v) = (x(u, v), y(u, v), z(u, v))


x(u, v) = (a + b cos(v)) cos(u)
y(u, v) = (a + b cos(v)) sin(u)
z(u, v) = b sin(v)

Here, a is the inner radius of the torus and b is the outer radius of the torus. The parameters u
and v range from zero to 2π. We can use texture coordinates where:

u
tx =

v
ty =

50
where tx and ty are the texture coordinates in the x and y directions. The u and v coordinates
are being divided by 2π because texture coordinates are typically required to be in the range [0, 1].
Figure 5.3 shows a torus texture mapped in this way.

Figure 5.3: Top Left: A 2D texture. The rest of the figure shows a torus from various angles. It has
been texture mapped according to Equation 1.

Varying Level of Detail


In some situations, we wish to conserve the number of polygons. For instance, in creating a
realtime application we must realize that only a certain number of triangles can be rasterized and
lit, texture mapped, etc, per second while keeping high frame-rates. In other situations, we might
want to use the highest quality models we can find. High quality models work best in situations
where we are pre-rendering. Movies can use pre-rendering, as we can render each frame to a series
of image files and then play all the image files one after the other while viewing the movie. Another
situation that calls for high quality models is when we take screenshots for printing in a book or
other manuscript.
Parametric surfaces can have varying levels of detail. That is, they can work well when you
need a high polygon count or a low count. This property stems from the fact that we can sample
the domain of the parametric function as many times as we wish, and use each of these samples as
parameters to the parametric function. The higher the sampling rate, the more accurate the surface
is. Lower sampling rates, on the other hand, reduce the number of polygons. Figure 5.4 uses the
torus example to illustrate this point.
Stripped Geometry
Strip geometry generally means having a sequence of triangles or quads share edges in a strip
like pattern. A series of triangles which all share vertices resembles a strip of triangles, see Fig-

51
(A) (B)

(C) (D)
Figure 5.4: A: A torus with only four samples in the u and v directions. B: A torus with eight
samples in the u and v directions. C: A torus with 16 samples in the u and v directions. D: A torus
with a high number of samples, 210 in both the u and v directions.

ure 5.5. A quad strip is similar to a triangle strip. Rendering a strip of n polygons is faster than
rendering the same n polygons separately. Another benefit of stripping geometry is that less data
needs to be stored and transferred. Sharing vertices can lead to a more efficient data structure be-
cause there are less redundant vertices. Furthermore, on modern graphics cards stripped geometry
renders much faster (about 66% faster), and this is of key interest because we wish to retain high
frame-rates.
Reduced Storage and Transmission
Although a parametric surface can be evaluated to have thousands of polygons, we need not
store all of these. Rather, we can just store certain model attributes. For instance, in a torus you
would need to store the radien a and b, and perhaps the number of evaluations you wanted in the u
and v directions. Compare this to storing every single polygon in the torus, which may number in
the thousands depending on the sampling rate of u and v. This argument extends to transmission

52
Figure 5.5: A strip of four triangles. Notice that there only six vertices in all if the triangles can
share vertices, but there are twelve vertices if the triangles can’t share the vertices. In a triangle
strip, the first and last triangles need to specify three vertices, however the triangles in the middle
only need to specify one vertex each. Quad strips are similar to triangle strips.

of data as well.
Regular Polygon Mesh
The tessellation in parametric surfaces tends to have a regular pattern. This is beneficial for
several reasons. When lighting is applied to the surface it tends to behave in a more uniform
fashion. It is also generally easier to store such a surface because we know the number of vertices
in each polygon in advance (for instance, if every polygon is a quad). Additionally, algorithms that
need to behave differently based on valence or the geometry of neighborhoods of polygons will
require less separate cases on regular geometry. In some cases, it is even possible to store such a
polygon mesh as a texture.

5.2 Curve Based Surfaces(Common Surfaces)


It is possible to create many types of parametric surfaces. This section outlines a few of the most
important types of parametric surfaces that are defined based on curves.

5.2.1 Ruled Surfaces (Lofted Surfaces)


This type of surface is created by moving a straight line between a pair of parametric curves. The
straight line is created by linear interpolation between points on the two curves. These straight
lines will be our v-curves.

Our v-curve is Q(v) = (1 − v)P0 + vP1 .

We get an entire surface by varying u, changing between our v-curves giving us:

53
Q(u, v) = (1 − v)P0 (u) + vP1 (u) 0 ≤ v ≤ 1 a ≤ u ≤ b (given by curve).

Note that both P0 (u) and P1 (u) have u as the parameter.


The resulting u-curves on this type of surface are new curves that are affine combinations of
P0 (u) and P1 (u).

Example 5.4
Creating a cylinder using a ruled surface.

P0 (u): a unit circle at z = 0 P0 (u) = (cos u, sin u, 0) 0 ≤ u ≤ 2π


P1 (u): a unit circle at z = 1 P1 (u) = (cos u, sin u, 1) 0 ≤ u ≤ 2π

Q(u, v) = (1 − v)P0 (u) + vP1 (u) = (cos u, sin u, v) 0 ≤ u < 2π, 0 ≤ v < 1

Special Cases of Ruled Surfaces


General Cones
To create a generalized cone one of the curves, P0 (u), is a single point forming the apex of the
cone, and P1 (u) is an arbitrary parametric curve. P1 (u) does not necessarily have to be a circle.
We can produce pyramids and other shapes by using different curves for P1 (u); this is why such
surfaces are called general cones.

Q(u, v) = (1 − v)P0 + vP1 (u) 0≤v≤1

Figure 5.6: Cones created by parametric ruled surfaces.

54
General Cylinders
Another special case of a ruled surface is a generalized cylinder. For these surfaces P1 (u) is a
translated version of P0 (u). That is, P1 (u) = P0 (u) + d for some vector d.

Q(u, v) = (1 − v)P0 (u) + v[P0 (u) + d] = P0 (u) + vd

Figure 5.7: Two generalized cylinders.

Bilinear Patches
These surfaces are simply interpolations between two straight lines. This means that our paramet-
ric curves, P0 (u) and P1 (u), are straight lines. Such surfaces can also be specified by their corners
(P00 , P01 , P10 , and P11 ).

Q(u, v) = (1 − v)P0 (u) + vP1 (u)


= (1 − u)(1 − v)P00 + (1 − v)uP01 + v(1 − u)P10 + uvP11
0 ≤ u, v ≤ 1

55
Figure 5.8: Two bilinear patches.

It is possible to make a Mobius strip with a ruled surface. This is notable because this is a difficult
task for other surface schemes to accomplish.

Figure 5.9: A Mobius strip (a one sided surface).(Image is taken and edited from wikipedia.)

5.2.2 Bilinearly Blended Surfaces: Coons Patches


Such surfaces are a very useful generalization of ruled surfaces. For these surfaces we use four
adjoining boundary curves (P0 (u), P1 (u), Q0 (v), and Q1 (v)) to define the surface.

56
The challenge of this scheme is to construct the interpolating points of such a surface, achieving a
smooth transition from each boundary curve to the other as u and v vary. An instinctive guess for
such an interpolation is to combine two ruled patches by adding them. This does not work because
it fails to interpolate the four curves and it is a non-affine operation. Consider the first corner point.
If we add up the two ruled surfaces we get:

P00 (ruled surface 1) +P00 (ruled surface 2) = 2P00 .

This is obviously not what we wish to be calculated, it also is a non-affine operation as we have
just added two points.

A good solution to this is to add the two surfaces and then subtract the bilinear patch formed by
the four corners. Again consider the first corner:

P00 (ruled surface 1) +P00 (ruled surface 2) −P00 (bilinear patch) = P00 .

This is the result we want. So, the formula for a Coon’s surface is:

Q(u, v) = [Q0 (v)(1 − u) + Q1 (v)u] (the first ruled surface)


+ [P0 (u)(1 − v) + P1 (u)v] (the second ruled surface)
− [(1 − u)(1 − v)P00 + u(1 − v)P01
+(1 − u)vP10 + uvP11 ] (the bilinear patch)
0 ≤ u, v ≤ 1

57
+ _ =

(a) (b) (c) (d)

Figure 5.10: A visualization of the construction of a Coons patch.

Let’s examine some the four corners:

Q(0, 0) = Q0 (0) + P0 (0) − P00 = P00 + P00 − P00 = P00


Q(0, 1) = Q0 (0) + P0 (1) − P01 = P01 + P01 − P01 = P01
Q(1, 0) = Q0 (1) + P0 (0) − P10 = P10 + P10 − P10 = P10
Q(1, 1) = Q0 (1) + P0 (1) − P11 = P11 + P11 − P11 = P11

Yes, the corners are interpolated properly.

Now, what do we want from Q(u, 0)? We should get P0 (u). Let’s check:

Q(u, 0) = Q0 (0)(1 − u) + Q1 (0)u + P0 (u) − P00 (1 − u) − P01 u


= P00 (1 − u) + P01 u + P0 (u) − P00 (1 − u) − P01 u
= P0 (u)

58
5.2.3 Surfaces of Revolution
To create a surface of revolution we perform a rotation sweep of the curve. Figure 5.11 gives some
examples of surfaces of revolution and their respective curves. So we take a two dimensional curve
C(v) = (x(v), z(v)), which could be B-spline or Bezier curve, and we rotate it around the z axis.
Then we simply form the surface as Q(u, v) = (x(v) cos u, x(v) sin u, z(v)) 0 ≤ u ≤ 2π (or a
subrange such as 0 ≤ u ≤ π), and the range of v is inherited from the curve. Notice in this for-
mulation we have used sin and cos to generate a circular intersection. It is possible to use NURBS
(c(u), s(u)) for approximation circles. In this case we define Q(u, v) = (x(v)c(u), x(v)s(u), z(v))
as the surface.

Figure 5.11: Surfaces of revolution and their generating curves.

Example 5.5
A Torus  
  cos v cos u
cos v
C(v) = Q(u, v) =  cos v sin u 
sin v
sin v

59
5.2.4 Rotational Blending Surface
This type of surface requires the user to enter in two curves (as shown in Figure 5.13). The curves
represent the silhouette edges of a 3D form. We combine the surface of revolution and the ruled
surface to find the parametric description of a rotational blending surface.
General Description
Let ql (u) and qr (u) be the co-planner 2D curves (strokes) defined by the user. We would like
to use ql (u) and qr (u) as the constructive curves (outlined form) of the rotational blending surface.
Let ℘ denote the plane of the curves and c(u) be the curve formed by the midpoint of ql (u) and
qr (u) at each u (Figure 5.12). Assume that tu (v), for fixed u, parameterizes the circle perpendicular
to ℘ with the center c(u) and passing through ql (u) and qr (u) at each u, as follows:

tu (0) = ql (u)
tu (π) = qr (u)
tu (2π) = ql (u).

Figure 5.12 illustrates how the curve tu (v) is generated from the constructive curves. The
desired surface is formed by moving this circle along c(u) by changing u

S(u, v) = tu (v). (1)


For fixed v and variable u, a set of rotational blending curves from ql (u) to qr (v) and vice versa
are generated (Figure 5.12, right). Note that surfaces of revolution can be generated by rotational
blending surfaces; for this, the second curve should be a rotated version of the first curve.
The rotational blending surface can create a variety of models, as shown in Figure 5.13. This
shows a good flexibility in comparison with other common surfaces. In addition, as an important

60
Figure 5.12: A rotational blending surface. The left and middle images show the constructive
curves (green), ql (u) and qr (u), the center curve c(u) (blue), and a circular slice of the surface,
denoted tu (v). The right image shows a completed surface overlayed with the blending curves
formed by holding v constant.

Figure 5.13: A variety of shapes is possible to generate using few strokes (top row) by using just
rotational blending surfaces. We created the pear in four strokes, the candle in eight and the laser
gun in six strokes.

61
advantage, the surface follows the input strokes. This shows that the surface is acting in a predicted
way and respects the user’s intention. Furthermore, when the constructive curves have corner
points or sharp feature, the final surface will also have sharp features and rotational creases, as
shown in the candle in Figure 5.13.
Mathematical Details
Let (x, y) be a coordinate system consisting of two orthogonal unit vectors in the plane ℘.
Recalling Section 5.2.4, ℘ is the plane in which the left and right constructive curves ql (u) and
qr (u) lie. Let z be x × y so that (x, y, z) forms a coordinate system for 3D space.
In order to define S(u, v) in a more formal way, we show that S(u, v) can be formed by a
series of affine transformations on the circular cross sections of a cylinder. Let Q(u, v) be the unit
cylinder in the 3D space
 
cos(v)
 u  0≤u≤1
Q(u, v) =   sin(v)  , 0 ≤ v ≤ 2π ,

and define

pl (u) = Q(u, π), (2)

pr (u) = Q(u, 0), (3)

1 1
pc (u) = pl (u) + pr (u). (4)
2 2
In our construction of S(u, v), pl (u) is mapped to ql (u), pr (u) to qr (u) and pc (u) to c(u). For
any fixed u, we have a unit circle in Q(u, v) and a general circle in S(u, v) and we wish to map
the unit circle to the general one (shown in Figure 5.14). This can be done by applying an affine
transformation Ms (u) to Q(u, v)

S(u, v) = Ms (u)Q(u, v). (5)


Notice Ms (u) consists of two affine transformations

Ms (u) = M2 (u)M1 (u)

where M1 (u) is a scaling about pc (u) with the following parameters:

62
Figure 5.14: A unit circle from the cylinder has been mapped via an affine transformation to the
pear. All rotational blending circles can be thought of as a cylinder where each circle in the cylinder
has undergone a transformation.

scalex = kqr (u) − ql (u)k


scaley = 1
scalez = kqr (u) − ql (u)k.
And M2 (u) is a frame transformation from (pc (u), x, y, z) to (c(u), x0 (u), y 0 (u), z) where x0 (u) =
qr (u)−ql (u)
kqr (u)−ql (u)k
, and y 0 (u) = z × x0 (u).

5.2.5 Sweep Surfaces


Rotational blending surfaces can be considered as a sweep surface although rotational blending
surfaces have a better interface. The idea of sweep surfaces is to generate surfaces by sweeping
a 2D curve (c(v)) along a 2D or 3D trajectory (t(u)). Figure refsweep illustrates a sweep surface
and its trajectory.

63
Figure 5.15: The curve, trajectory and the resulting sweep surface.

If the trajectory (t(u)) is a planar curve, it would be easy to form the surface using the tangent
and normal of t(u) as a local frame. In such a situation, (t(u), T (u), N (u)) defines the frame on
which the 2D curve c(v) lies. However, if t(u) is a 3D curve, an appropriate local frame have to
be defined. One way to define such a frame is to use Ferenet frames. As shown in Figure5.16, a
Ferenet frame has three components: Tangent, Normal and Binomral that are often called T (u),
N (u), and B(u). Mathematical equations of these components are presented in the following.

B
B T
T
B T B
N N

N N T

Figure 5.16: The curve, trajectory and the resulting sweep surface.

0
t (u)
T (u) = 0 (6)
kt (u)k
0 00
t (u) × t (u)
B(u) = 0 (7)
kt (u) × t00 (u)k

N (u) = T (u) × B(u) (8)

64
Ferenet frames need strong conditions like the existence of the first and second derivatives
of the all points of the trajectory curve. Moreover, to define the tangent to the first derivative of
the trajectory and to define binormal, both the first and second derivative of the trajectory must
be nonzero. These conditions do not happen for all curves. To overcome these issues, parallel
transport frames which are the extension of Ferenet frames can be used. The parallel transport
method tries to use a consistent frame with respect to the previous local frame for the problematic
points where B(u) = 0 (inflection points). The parallel transport algorithm is presented in the
following.

Algorithm 5.2 Parallel Transport Computation


0 //Input: A list of unit tangent vectors Ti , and initial normal
vector N0 , N0 ⊥ T0
1 for i=0 to M step=1
2 B = Ti × T i + 1
3 if kBk = 0 then
4 Ni+1 = N i
5 else
B
6 B = kBk
7 θ = arccos(Ti , Ti+1 )
8 Ni+1 = R(B, θ) ∗ Ni
9 end if
10 end for
11 //Output: A list of parallel transport normal vectors Ni ,
Ni ⊥ Ti

5.2.6 Cross Sectional Blending Surfaces


This type of surface requires the user to input three curves (see Figure 5.17). Cross Sectional
blending surfaces allow the user control the shape of surface by sketching on a cross section.
Although the rotational blending surface is a good selection for the default surface generator ,
and it is more flexible than other common surfaces, still it can not make every free-form surface by
its nature, as it only can create rounded objects. In order to increase the flexibility of our surface
generator as well as keeping the number of input strokes very small, we can use Cross Sectional
Blending surface. It is a simple modification of the rotational blending surface that allows the user
to change the shape of the cross section from circle to an arbitrary 2D curve. Mathematically,
this means that tu (v), for a fixed u, does not necessarily parameterize a circle anymore but the
curve which is provided by the user (see Figures 5.17, 5.18). Again, the surface can be defined by
changing u, or equivalently by moving tu (v) along c(u).

65
Figure 5.17: From left to right: sketching two constructive strokes (black), one cross sectional
stroke (red) and the resulting leaf model in front and side views.

Figures 5.17 and 5.18 shows the model of a leaf and a sword blade, respectively, created using
cross sectional blending surface. When we have more than two sections we need to use a kind of
smooth transition between them and this is well fitted to free-form surface modeling with B-Spline
surfaces, as described in the next section.
Cross Sections The user can draw a cross section connecting ql (u) to qr (u) at any u he chooses.
This is where the u subscript in tu (v) comes from. After the user draws on a cross section tu (v), it
is rotated by 90 degrees about the axis qr (u) − ql (u). By moving this rotated cross section to every
ql (u) to qr (u) paring, we get our final cross sectional surface. Since axis qr (u) − ql (u) varies for
every u, when moving the cross section to every ql (u) to qr (u) paring we will need to perform a
rotation and a scaling on the cross section, so that it lines up properly with the axis.
Consider the effect of drawing on various shaped cross sections. If the user draws a cross
section that simply connects qr (u) − ql (u) in a straight line, a flat, plane-like shape will result.
Drawing on a semi-circular cross section will result in the same shape of surface as we can create
with a rotational blending surface (Sec 5.2.4). Any sort of cross section is possible.

66
Figure 5.18: Modeling a sword blade using cross sectional blending surfaces. Top row, left to right:
drawing the constructive curves only (dotted lines) results in a perfectly rounded object. Sketching
the cross sectional outline (red line) results in a better, sharper, faceted blade. Bottom row: the
sword in a different view. Notice the final surfaces, with sharper features

5.3 Free Form Parametric Surface


Although the common surfaces can be easily defined and used, they are not flexible enough to
model free form shapes. We have to extend the way which we used for B-Splines. We can imagine
that the blending functions N0,1 (u), . . . , Nm,k (u) can "mix" the "zero dimensional" co-structured
objects P0 , P1 , . . . , Pm to generate a good "one dimensional" object (curve):
m
X
Q(u) = Pi Ni,k (u)
i=0

67
Notice after this blending we have a continuous representation, the "curve", for the given "dis-
crete" set of conrod points.
This concept can be extended to any "dimension". Assume that P0v , P1v , . . . , Pmv are given co-
structured (same parametrization) curves. Then the surface is defined by "mixing" these curves
X
Q(u, v) = Piv Ni,k (u).
i
if Piv are B-Splines too, then we have
XX
Q(u, v) = Pi,j Ni,k (u)Nj,k0 (v)
i j

Figure 5.19: Blending curves to form surfaces


This approach can be used for any kind of curve models including Bezier, B-Spline and
NURBS.
Similar to the curve case, this blending generates a "continuous" representation, the surface,
from the given "discrete" set of curves. Figure 5.19 demonstrate this idea. In the left, a set of
cubic B-Spline curves are given and in the right shows the result of "blending" this curves to form
a surface. Note that for any arbitrary v in the range, we can find a curve embedded on the surface.

5.3.1 Bézier Surface


If we use Bézier curves along the u and v curves, the obtained parametric surface is called Bézier
surface or patch. Given Pi,j , a net of control points, we obtain a surface with the following equa-
tion:
X d X d0
Q(u, v) = Pi,j Bi,d (u)Bj,d0 (v) 0 ≤ u ≤ 1 0 ≤ v ≤ 1.
i=0 j=0

68
Figure 5.20: Bezier Surface

Example 5.6

3th -degree Bézier patch


3 X
X 3
Q(u, v) = Pi,j Bi,3 (u)Bj,3 (v) 0≤u≤1 0≤v≤1
i=0 j=0

69
Figure 5.21: 3rd degree Bézier patch

The u and v-curves of the Bézier patch can be determined by fixing one of the curves and
computing the other. For example, to find the u-curves, we fix the v parameter to some value.
d0
d
!
X X
Q(u, v) = Pi,j Bj,d0 (v) Bi,d (u) 0 ≤ u ≤ 1 0 ≤ v ≤ 1
i=0 j=0
| {z }
Piv

d
X
Q(u, v) = Piv Bi,d (u)
i=0

This means that the u-curves are Bézier curves with the control points
d0
X
Piv = Pi,j Bj,d0 (v)
j=0

70
Rendering Bézier Surfaces
Once again we must move from our equation for a quadratic patch to an efficient rendering
algorithm. To consider how we can calculate the points on the surface, we first fix the v parameter.
2 X
X 2
Q(u, v) = Pi,j Bi,2 (u)Bj,2 (v) 0≤u≤1 0≤v≤1
i=0 j=0

1
fix v = 4 !
2 2
1 X X 1
Q(u, ) = Pi,j Bj,2 ( ) Bi,2 (u) 0≤u≤1 0≤v≤1
4 i=0 j=0
4
1
Q(u, ) = P0v B0,2 (u) + P1v B1,2 (u) + P2v B2,2 (u)
4
where
1 1 1
P0v = P0,0 B0,0 ( ) + P0,1 B0,1 ( ) + P0,2 B0,2 ( )
4 4 4
1 1 1
P1v = P1,0 B1,0 ( ) + P1,1 B1,1 ( ) + P1,2 B1,2 ( )
4 4 4
1 1 1
P2v = P2,0 B2,0 ( ) + P2,1 B2,1 ( ) + P2,2 B2,2 ( )
4 4 4
By changing the v values we obtain a class of u-curves that are Bézier curves. Repeat the same
process, but fixing u this time
d0 d
!
X X
Q(u, v) = Pi,j Bi,d (u) Bj,d0 (v) 0 ≤ u ≤ 1 0 ≤ v ≤ 1
j=0 i=0
| {z }
Pju

consequently, all v-curves are also Bézier curves. Knowing this property, we can employ deCastel-
jau algorithm to efficiently compute the v and u curves.
Two Dimensional Bernstein Basis Functions
We can view
d X
d 0
X
Q(u, v) = Pi,j Bi,d (u)Bj,d0 (v) 0≤u≤1 0≤v≤1
i=0 j=0

as a basis function summation


d X
X d0
Q(u, v) = Pi,j Bi,j,d,d0 (u, v) 0≤u≤1 0≤v≤1
i=0 j=0

71
where Bi,j,d,d0 (u, v) is a two dimensional basis function with the following definition

Bi,j,d,d0 (u, v) = Bi,d (u)Bj,d0 (v)

First Degree Bézier Surfaces


What kind of surface do we obtain when d = d0 = 1?
1 X
X 1
Q(u, v) = Pi,j Bi,1 (u)Bj,1 (v) 0≤u≤1 0≤v≤1
i=0 j=0

Q(u, v) = P0,0 uv + P0,1 u(1 − v) + P1,0 (1 − u)v + P1,1 (1 − u)(1 − v)


This is a bilinear patch (a special case of ruled surface).

Figure 5.22: Utah teapot consisting of 32 cubic Bézier patches

5.3.2 B-spline Surfaces


A B-spline surface is defined as
m X
m 0
X
Q(u, v) = Pi,j Ni,k (u)Nj,k0 (v) uk−1 ≤ u ≤ um+1 vk0 −1 ≤ v ≤ vm0 +1
i=0 j=0

where Pi,j is a point on the net of (m + 1) × (m0 + 1) control points. The set of knot sequences
{u0 , u1 , u2 , . . . , um+k } and {v0 , v1 , v, . . . , vm0 +k0 } are used correspondingly for u and v.

72
Example 5.7

5 X
X 6
Q(u, v) = Pi,j Ni,3 (u)Nj,3 (v)
i=0 j=0

with the standard knot sequence

{0, 0, 0, . . . , 1, 1, 1}
1 1 1
inc = → incu = , incv =
m−k+2 4 5
1 1 3
U = {0, 0, 0, , , , 1, 1, 1}
4 2 4
1 2 3 4
V = {0, 0, 0, , , , , 1, 1, 1}
5 5 5 5
Q(u, v) = P0,0 N0,3 (u)N0,3 (v) + P0,1 N0,3 (u)N1,3 (v) + . . . + P0,6 N0,3 (u)N6,3 (v) + . . .
+P5,0 N5,3 (u)N0,3 (v) + . . . + P5,6 N5,3 (u)N6,3 (v)
fix v !
5
X 6
X
Qv (u) = Pi,j Nj,3 (v) Ni,3 (u)
i=0 j=0
| {z }
Piv

5
X
Qv (u) = Piv Ni,3 (u)
i=0

Consequently, u-curves are B-spline curves. Similarly for v-curves we have


6 5
!
X X
Qu (v) = Pi,j Ni,3 (u) Nj,3 (v)
j=0 i=0
| {z }
Pju

73
This arrangement helps us obtain an efficient algorithm for rendering of B-spline surfaces.
Assume u, v are given
Xm X m0
Q(u, v) = Pi,j Ni,k (u)Nj,k0 (v)
i=0 j=0

m m 0 !
X X
Q(u, v) = Pi,j Nj,k0 (v) Ni,k (u)
i=0 j=0
| {z }
Piv

m
X
Q(u, v) = Piv Ni,k (u)
i=0

Algorithm 5.3 Computing sums of B-spline for tensor product surfaces


0 // input m,m’,P[i,j],u,v
1 for i=0 to m
2 Pv[i]=sum_of_bsplines(P[i,j],m’,v)
3 S=S+Pv[i]
4 end
5 // output is S

Note that by using δ (the index of focus) we can reduce the number of iterations in the "i" loop.

74
Figure 5.23: Parameter domain of B-spline tensor product surface

Two Dimensional B-spline Basis Functions


m X
m 0
X
Q(u, v) = Pi,j Ni,k (u)Nj.k0 (v)
i=0 j=0

m X
m 0
X
Q(u, v) = Pi,j Ni,j,k,k0 (u, v)
i=0 j=0

where
Ni,j,k,k0 (u, v) = Ni,k (u)Nj,k0 (v)

5.3.3 NURBS Surfaces


With NURBS we again require a net Pi,j of control points. Additionally we need a net of weights
wi,j . The surface patch is defined by
Pm Pm0
i=0 j=0 wi,j Pi,j Ni,k (u)Nj,k0 (v)
Q(u, v) = Pm Pm0 0 ≤ u, v ≤ 1
i=0 j=0 wi,j Ni,k (u)Nj,k0 (v)

75
or
m X
m 0
X wi,j Ni,k (u)Nj,k0 (v)
Q(u, v) = Ri,k (u, v)Pi,j where Ri,j (u, v) = Pm Pm0
i=0 j=0 i=0 j=0 wi,j Ni,k (u)Nj,k0 (v)

By using our sums of B-splines sub-algorithm we can obtain an efficient algorithm for NURBS
surfaces.

5.3.4 Properties of Parametric Surfaces


For B-splines and NURBS, if we focus on the interpolating knot sequence for both the u and v
sequences, we have the following properties

1. Corner point interpolation (Bézier, B-spline, NURBS)

Q(0, 0) = P0,0 , Q(1, 0) = Pm,0 , Q(0, 1) = P0,m0 , Q(1, 1) = Pm,m0

2. Affine invariance (Bézier, B-spline, NURBS)

3. Strong convex hull (Bézier, B-spline, NURBS)

4. Local control (B-spline, NURBS)

5. B-spline and Bézier surfaces are special cases of NURBS.

76
6 Mesh
Parametric surfaces provide a useful tool to represent graphical objects. However, to generate a
more variety of objects, we need a discrete setting that can represent general topological surfaces.
Polygonal meshes can provide such a setting in which the object is represented by a set of polygons
that are attached to each other. Formally, a mesh M consists of a set of vertices V capturing the
geometry (location) of the object and a set of faces denoted by F representing the connectivity
of the object. A face fi ∈ F connects n vertices vi0 , vi1 , ..., vin−1 in which vik ∈ V . If all faces
connect only three vertices, it is called a triangular mesh. In summary, mesh M can be represented
as the tuple M = (V, F ). However, to handle connectivity queries of a mesh, we typically work by
the set of edges that connect vertices. Set of all edges of M is denoted by E. Figure 6.1 illustrates
the set of vertices, edges and faces of a mesh representing the bunny.

Figure 6.1: (a) V , (b) E, (c) F .

6.1 Neighborhood
Each edge e in E connects two vertices vi and vj (Figure 6.2 (a)). These two vertices are called
neighbors. In general the set of all neighbors of vertex vi is called neighborhood and denoted
by N (vi ) (Figure 6.2 (b)). |N (vi )| refers to the number of vertices in the neighborhood of vi or
its valence. For instance, in Figure 6.2, the valence of vi is seven as it has seven vertices in its
neighborhood. Two faces fi and fj are neighbors if they share an edge e (Figure 6.2 (a)).

77
vi vi
e fj
e
fi
(a) vj (b) (c)
Figure 6.2: (a) vi and vj are neighbors, (b) Neighbors of vi are drawn in red (c) Faces fi and fj are
neighbors.

6.2 Topology
To simplify the concept of typology, imagine a space whose object are made by a flexible rubber
material. In this space, the operations such as stretch, shrink, smudge, push and pull do not change
the shapes and the resulting objects are called to be topologically isomorph. But the operations
such as cut, chop, slice, and making holes and gaps do change the shapes and their topology.
Figure 6.3 shows two pairs of isomorph surfaces but the first pair has different topology from the
second pair.

Figure 6.3: Two pairs of isomorph surfaces. The left pair is not isomorph to the right pair.

Meshes can be closed or open. If a mesh has boundaries, this means there exists edges in E
that belong to only one face, the mesh is open. A mesh without any boundary is a closed mesh.
Closed surfaces usually divide the space into inside and outside of the object. 2
2
Note that this statement is valid for orientable surfaces.

78
6.3 2D Manifolds
Polygonal meshes are usually used for representing 2D manifolds. A surface is 2D manifold if
any arbitrary point of the surface has a local neighborhood very similar to a plane. More precisely,
each point has a neighborhood isomorph to a disk (or half disk for the surfaces with boundaries).
Figure 6.4 demonstrates the definition of 2D manifolds. If the surface does not intersect itself it
is called simple. Spheres, donuts and polyhedra are important examples of closed and simple 2D
manifolds.

Isomorph

Figure 6.4: Left: a 2D manifold. Right: non-manifold.

6.4 Orientability
To define normal vectors for faces, we should be able to have a consistent orientation for faces.
If we are able to start with a face, orient it and orient all other faces accordingly, the surface is
orientable (see Figure 6.5 (a)). Otherwise, if there exists an inconsistency in the orientation of
faces, this means that there is an ambiguity in the direction of normals of some face. In this case,
the surface is non-orientable. Two examples of such surfaces are Klein bottle, and Möbius strip
(see Figure 6.5 (b)).

79
(a) (b)

Figure 6.5: (a) Determining an orientation for an orientable surface; (b) Möbius strip; a non-
orientable surface.

6.5 Euler Characteristic Equation


There is a connection among "numbers of edges, faces and vertices" in general meshes. Let
|E| , |F | and |V | be number of edges, faces and vertices respectively. Intuitively, |E| is almost
equal to |V | + |F |. In particular, there is exact equation, Euler equation, for polyhedra

|E| = |F | + |V | − 2.

For example, a cube has 12 edges, 8 vertices, and 6 faces.


For a closed simple mesh with G holes(genus), there is a more general equation(Euler-Poincare
equation):
|E| = |V | + |F | − 2(1 − G).
The genus of an object generally refers to the number of holes in the object. A cube or other
sphere-like object would be of genus zero. A torus would be of genus one. Notice that for the
analysis of algorithms, and counting for large number of faces we can assume O(|E|) = O(|F | +
|V |).

6.6 Basic Operations


6.6.1 Finding Normals
For smooth surfaces, the normal is the unit vector which is perpendicular to the surface at any
given point on the surface. This vector is important for shading objects. For meshes we can easily
find a constant normal vector to each face. For this, consider we would like to find the normal n at
the vertex P1 of the face P0 , P1 , P2 , . . ., as shown in the Figure 6.6 using cross product of (P2 − P1 )
and (P2 − P1 ).

80
Figure 6.6: Three successive vertices in a face.

Figure 6.7: (a) Smooth shading; (b) Flat shading.

Notice if we have a face with more than three vertices then the face might be non-planner.
Consequently, the above method can produces different normals for each vertex of the face. In this
case the average of all possible normals can be used as the normal of the face. Another strategy is
to split the face to a set of triangles.
Using a constant normal vector per face makes flat shading as shown in Figure 6.7 (b). This
kind of shading is not very desirable in most applications. To have a smooth result(see (a) in
Figure 6.7), a normal per vertex is defined. One way to determine the normal of vertices is to
calculate the normal of each face connected to a vertex and average them. As aPresult, if faces f0
n
N
to fn are connected to vertex v, normal vector of v denoted by Nv is Nv = Pni=0 Nfi in which
| i=0 fi |
Nfi is the normal vector of face fi connected to vertex v (see Figure 6.8). However, this type of
computing the normal of vertices disregards the variable contribution of faces to the normal vector
due to their different areas. In fact, a face with larger area should have a more impact on the normal
vectors of vertices. Therefor, we can use a weighted average for computing the normal vectors of
vertices. Consider faces f0 to fn with areas a0 to an are connected
Pn to vertex v, using the weighted
ai N fi
average, we can calculate the normal vector of v as: Nv = Pi=0 .
| ni=0 ai Nfi |

81
Nf5

Nf0
f5 a5
Nf4 v f0 v a0
f4 a4
f1 a1
f3 f2 a3 a2
Nf1

Nf3 Nf2
(a) (b)

Figure 6.8: (a) Faces connected to vertex v and their normals (b) Areas of faces in (a).

6.6.2 Laplacian
Having smooth meshes representing practical surfaces is very important in computer graphics.
However, man-made objects or scanned sampled surfaces are typically very coarse or noisy. As a
result, an approach that can smooth the surface is desired. One approach for smoothing meshes is
called Laplacian. The basic idea of laplacian is to average each point based on its neighborhood.
In fact, in Laplacian, each point is repositioned to the average location of its neighborhood (see
Figure 6.9). Formally, for each vertex vi in set V , vi is moved
P
vj
vj ∈N (vi )
v́i = .
|N (vi )|

Figure 6.10 illustrates applying Laplacian on a triangular mesh in successive levels.

82
vi

v’i vi

(a) (b) (c)

Figure 6.9: (a) vi and its neighborhood. (b) v́i which is the average-location of red vertices in
neighborhood of vi . (c) Moving vi to v́i .

Figure 6.10: Applying laplacian on bunny with noises. Removing the noise and smoothing the
surface is noticeable after two iterations of applying Laplacian..

6.6.3 Vertex Removal and Edge Collapse


To manipulate the mesh, we can use other operations that may change the topology, connectivity,
or geometry of the object. For instance, we can pick a point and change its position or we can
split an edge by inserting a vertex on it, and connect it to some vertices in its neighborhood (see
Figure 6.11). Among these operations, there exist two fundamental and important operations in
mesh processing called vertex removal and edge collapse that we describe them in the following.

83
Figure 6.11: We can apply basic modifications such as vertex repositioning (middle) and inserting
vertices and edges on to the mesh (Right).

Vertex Removal. This operation initially removes a vertex and all faces connected to it. After
doing this, a hole is created in the object. To fill the hole, it is triangulated by connecting the
vertices of faces that are removed. Figure 6.12 shows the process of vertex removal and Figure
6.13 shows its effect on a triangular mesh.

(a) (b) (c) (d)

Figure 6.12: The process of vertex removal. (a), (b) The vertex that needs to be removed is selected
along with all faces around it. (c) the vertex and connected faces are removed and a hole is created.
(d) The hole is filled using new triangles.

84
Figure 6.13: A mesh before and after vertex removal.

Edge Collapse. This operation removes an edge by repositioning the vertices making an edge.
Consider edge e connecting vertices vi , and vj . If both vi and vj are located at the same position,
edge e has zero length. Therefore, we can remove edge and keep one vertex vk instead of vi and vj .
To remove an edge, vertex vk can have the position of vi or vj , or it can be any point on e such as
the midpoint between vi and vj (see Figure 6.14). Figure 6.15 illustrates the result of edge collapse
on a triangular mesh.

vj vk vk
vi e vk

(a) (b) (c) (d)

Figure 6.14: The process of applying an edge collapse operation. (a) an edge connecting to vertices
vi and vj is selected. Possible scenarios for repositioning vi and vj to vk : (b) vk = vj (c) vk = vi ,
and (d) vk is on the midpoint of vi and vj .

85
Figure 6.15: Collapsing an edge on a triangular mesh.

Note that polygonal meshes are just a discrete representation of objects and they do not pro-
vide a modeling paradigm. We may make a coarse object using polygonal meshes by applying
discussed operations. However, making a smooth and detailed object needs a modeling paradigm
that guarantees specific properties for the resulting objects such as smoothness. We will later see
how subdivision schemes can provide such a modeling paradigm.

6.7 Data Structure for Polygonal Meshes


To handle queries of a general polygon mesh, we need to use an efficient data structure for meshes.
Meshes can be easily expressed as a sequence of faces. OpenGL and the most of the current API
are based on drawing a sequence of faces, usually triangles. Therefore, it is natural to use "face
list" as a standard way of representing a broad class of shapes in graphics.

6.7.1 Face-Vertex List representation


This simple representation is essence of some modern 3D formats and data-structures such as
obj format from Alias/Wavefront and MD2 format from id software. Fundamentally, it uses the
following lists
• vertex list: reports the locations of the distinct vertices (positional or geometrical informa-
tion)
• face list: indexes into the vertex list (connectivity or topological information).
The face list records the indices of the adjacent vertices by traversing them. The direction of this
traverse is important for finding the normals to the faces which are used for shading. Figure 6.16
shows a quad face with its adjacent vertices. There are two ways to traverse a polygon

86
Figure 6.16: A simple quad face example

• clockwise (5,8,7,6)

• counter-clockwise (5,6,7,8)

Either direction could be used, but the following convention is usually employed:
Right hand rule: Traverse the polygon counter-clockwise as seen from outside of the object (or
front side).
An efficient representation for normals is also helpful. For this, we use a normal list as the third
list for mesh representation. This list reports the directions of the distinct normal vectors. Again
face list just points to this list. Because finding the normal is straightforward, the normal list is an
optional structure for some 3d formats.

6.7.2 Half-edge data structure


Face-vertex list representation is efficient for OpenGL that needs a sequence of faces. However,
it is hard to do operations that changes the connectivity of the mesh (such as add vertices, find
the neighborhood.). This kind of operations are necessary for mesh processing and subdivision
methods.
For instance we need to traverse entire mesh to add just one vertex to a specific portion of the
mesh. Consequently, it is better to use a data structure that allows us to traverse all neighbors of
each vertex in an efficient way. There are several data structures that provide an efficient repre-
sentation. Half-edge is a very efficient data structure for meshes. In this data structure edges are
first class citizens!! All connectivity information assign to the edges. Faces and vertexes have just
pointer to one incident edge. Vertices have also a pointer to the 3D coordinates or perhaps normal
vectors. For each edge there are two ways of traversing even using counter-clockwise direction.
To reduce the symmetric ambiguity, each edge is split to half-edges and the necessary information
is divided and attached to each half-edge separately as illustrated in Figure 6.18.

87
Figure 6.17: Vertex and normal list.

A simple example is shown in Figure 6.19. Initialization of the half-edge data structure is more
complicated than Face-vertex list method. However, all necessary mesh processing operations can
be done efficiently. As an example , the algorithm 6.7.2 shows how efficient we can find all the
neighbors of a given vertex. This is a basic operation which is needed for inserting a new vertex or
removing a vertex and etc. Let n be the number of vertices adjacent to the input vertex v. The loop
in the algorithm is terminated at most after n iterations which is optimal for finding the neighbors.

Algorithm 6.1 A fast algorithm for finding all neighbors of a given vertex.
input v
e=v^.edge.^pair;
e0=e;
do
w=e^.source;
//do something with w
e=e^.next.^pair;
while( e != e0)

88
Figure 6.18: Half-edge data structure.

Figure 6.19: Half-edge data structure, a simple example.

89
7 Subdivision Methods: Curves and Tensor-Product Surfaces
7.1 Motivation
Consider a set of control points and the resulting quadratic B-spline. Is it possible to find a new set
with more control points that produces exactly the same curve?

It turns out that yes, this is possible. What then is the relationship between these two sets of
control points? How are the new control points related to the old control points?

7.2 Knot Insertion Process for Subdividing B-splines


We can insert midpoints as new knot values and keep the curve unchanged. This results in a
relationship between
P the two sets of control points. In a mathematical sense this is:
old: Q(u) = m i=0 Ci Ni,k (u) Ci is a coarse control point.

Pm0
new: Q̄(u) = j=0 Fj N̄j,k (u) Fj is a fine control point.

where N̄j,k (u) are the set of new B-spline


 basisfunctions over the finer knot values.
F1
If we set Q(u) = Q̄(u) then F = F 2  can be obtained. In the case of the quadratic B-

...
spline we obtain the following operations for the regular case (i.e., the areas of the curve where the
basis functions are evenly spaced according to the standard knot sequence).

Fj−1 = 43 Ci−1 + 14 Ci
Fj = 14 Ci−1 + 34 Ci

We can repeat this process of introducing new control points several times producing a finer and
finer sets of control points. These finer control points approach a limit where the points become a
quadratic B-spline. It should also be noted that each refinement operation is affine.

90
As we can see in the above figure, after several steps of the knot insertion process the control
polygon is a very good approximation of the curve. This simple method of generating a quadratic
B-spline is called "Chaikin subdivision".
Our filter values for Chaikin subdivision are 41 , 34 , 34 , 14 .

Example 7.1

An example of Chaikin subdivision

Three levels of subdivision are shown.

7.2.1 Cubic B-spline Subdivision


Using the same knot insertion approach, the following operations are obtained for cubic B-splines:

Fj−1 = 12 Ci−1 + 12 Ci
Fj = 18 Ci−1 + 34 Ci + 18 Ci+1
Fj+1 = 21 Ci + 12 Ci+1

Consequently our filter values for cubic b-spline subdivision are: 18 , 12 , 34 , 21 , 18 .

Figure 7.1: Cubic B-spline subdivision.

91
7.2.2 Filters For General B-spline Subdivision
In general we can derive filters for any order of regularly spaced b-splines. Table 1 shows the
relationship between the b-spline filter values and Pascal’s triangle.

Table 1: General B-spline subdivision filters.


Order Name Scale Pascal’s Triangle Filter Values
1 Harr 1 11 11
1 1
2 Faber 2
1 2 1 2
1 12
1 1 3 3 1
3 Chaikin 4
1331 4 4 4 4
1 1 1 3 1 1
4 Cubic B-spline 8
14641 8 2 4 2 8
1 1 5 10 10 5 1
5 ... 16
1 5 10 10 5 1 16 16 16 16 16 16

7.3 Matrix Notation


We can specify the subdivision operation in terms of a matrix. Given a column vector C j , the set
of coarse control points, a high resolution C j+1 set of control points is created via: C j+1 = P j C j
(note that j and j +1 are superscripts and not powers in this context) where P j is a m×n (m > n)
subdivision matrix and j refers to the level of subdivision. P j has a regular banded structure. The
following is the matrix for cubic B-spline subdivision.
1
 
8
0 0 0
1

 2
0 0 0 

3 1

 4 8
0 0 

 ... 1 1 0 0 ... 
 2 2 
Pj = 
1
8
3
4
1
8
0 

1 1

 0 2 2 0 

1 3 1

 0 8 4 8


1 1
 0 0 2 2 
1 3
0 0 8 4

The non-zero entries of each column are the filter values from table 1. These entries are shifted
from its predecessor’s by two rows. This shifting pattern is due to the midpoint knot insertion
scheme.
The direct consequence of this kind of insertion is that the number of new control points is
almost two times the number of old control points.

92
Figure 7.2: New knots are inserted midway between existing knots.

7.4 Open and Closed Curves

Figure 7.3: An example of an open curve being subdivided.

Up until this point we have not discussed what happens at the boundaries of the curve. If we
only consider the closed (periodic) case of curve we simply apply the regular filter over the entire
curve.
We would like to have open curves treated exactly as the result of the standard knot sequence.
That is, we would like the beginning and end control points to be interpolated and not have the
curve shrink as we apply levels of subdivision to it. This can be done by recalculating the knot
insertion process.
Consider a quadratic b-spline for the standard knot sequence. Let Fj denote the fine control
points obtaining from inserting midpoints to the knot sequence. From the resulting equation:
P P
Q(u) = Ci Ni,3 = Fj N̄ xj,3 (u)

93
We obtain some non-regular (extraordinary) filter values to be applied near the boundaries:

F 0 = C0
F1 = 12 (C0 + C1 )
F2 = 43 C1 + 14 C2
.
. (regular case)
.
F2n−3 = 34 Cn−1 + 41 Cn−2
F2n−2 = 12 (Cn + Cn−1 )
F2n−1 = Cn

The same knot insertion process gives us filters for cubic b-spline subdivision near the bound-
aries:

F0 = C0
F1 = 12 (C0 + C1 )
F2 = 43 C1 + 14 C2
3
F3 = 16 C1 + 11 C + 18 C3
16 2
1
F4 = 2 (C2 + C3 )

and as in the previous case if we change the order of the filter values, we obtain the values around
the end point.
Complete subdivision matrix of open B-splines of order 3, 4, and 5 are:

94
95
7.5 Subdivision Without Knot Insertion
The idea of the subdivision method is easy and simple enough to generalize for many curves and
surfaces. However, the knot insertion process only works for B-spline curves and tensor product
surfaces. The main advantages of the knot insertion process is to guarantee the properties:

• Convergence of successive refining.

• affine invariance

• Smoothness of the result.

For example, when we use midpoint knot insertion for the quadratic B-spline it is obvious that
the resulting Chaikin subdivision curve converges to a quadratic B-spline and generates a smooth
limit. However if we start a similar subdivision scheme with the filter values 13 , 23 , 23 , 13 we need
some method of showing such properties.
Good questions here can be raised: Is it possible to introduce subdivision methods without
using knot insertion process? Are there any non-Bspline subdivision methods?

7.5.1 Analysis Of Subdivision Methods


We would like to investigate the properties of {C j+1 } where C j+1 = P j C j . Although as we
perform several levels of subdivision the matrices P j are different matrices when j varies; however
they have a regular structure and are locally the same although with difference sizes. The important
fact is that properties such as convergence, continuity, and smoothness of the limit curve can be
checked locally. For example, if we only focus on five points in the cubic B-spline subdivision

Figure 7.4: Local cubic B-spline subdivision.

(see figure 7.4) then a constant and simple matrix, S, is all that is required. This matrix expresses
a portion of the subdivision matrix P j .

96
Figure 7.5: Local subdivision matrix for the Dyn-Levin subdivision scheme.

Therefore we can simply replace


C j+1 = P j C j
with
Lj+1 = SLj
where Lj+1 and Lj represent the two five element vectors in the levels j and j + 1 we are interested
in and S is the local subdivision matrix.
This gives us the result:

Lj+1 = SLj = S(SLj−1 ) = ... = S j+1 L0

where L0 refers to the initial set of control points and S j+1 is the power j + 1 of S. Consequently
all properties can be investigated using "powers" of S. The Eigenvalues and Eigenvectors of S are
very important tools in this analysis. A detailed discussion of this topic is beyond the scope of this
course, however two brief examples follow.

Example 7.2
Analysis of Chaikin The leading eigenvalues of S are:
1 1 1
eigs(S) : λ0 = 1, λ1 = , λ2 = , λ3 =
2 4 4
This arrangement of eignvalues can lead us to all the three properties that we mentioned in subsec-
tion 7.5.

97
7.6 Non B-spline Subdivision
The main advantages of the knot insertion process is to guarantee the properties:
• Convergence of successive refining.

• Smoothness of the result.


can be resulted from this process. In order to have a self-contained subdivision method both of
these properties must be guaranteed.

Figure 7.6: Different values for the subdivision filters may decrease continuity (middle) or result
in divergence (right).

7.6.1 Dyn-Levin Interpolating Subdivision Scheme


This is not a B-spline based subdivision. In fact this scheme is unique because it interpolates the
original control points. The filter values in this scheme are:
1 9 9 1
Fj−1 = − 16 Ci−2 + 16 Ci−1 + 16 Ci + − 16 Ci+1
F j = Ci
1 9 9 1
Fj+1 = − 16 Ci−1 + 16 Ci + 16 Ci+1 + − 16 Ci+2

Dyn-levin-Gregory Interpolating Curve Subdivision


The even points are exactly the original set of controls points. The odd control points use
1 9 9 1
− 16 , 16 , 16 , − 16 as the weights. These numbers of have been selected carefully to dictate smooth-
ness of the limited curve. This can be checked by the eigenvalues of the local subdivision matrix
S show in figure 7.5. After analysis we find that the leading eigenvalues are:
1 1 1
eigs(S) : λ0 = 1, λ1 = , λ2 = , λ3 =
2 4 4
98
Figure 7.7: Dyn-Levin subdivision from the coarse to the fine points.

These eigenvalues are exactly the same as Chaikin subdivision’s eigenvalues. Therefore, this sub-
division scheme also generates a smooth limit curve.

Figure 7.8: Cubic B-spline subdivision of a tensor produce surface.

99
7.7 Tensor Product Surfaces
We can use any subdivision curve schemes along u and v direction for a given net of control points.
This as demonstrated in the Figure7.8 rapidly increases quality and resolution of the control net.
Notice that the control net can be made up with closed u-curves and(or) v-curves. For these cases,
we can apply periodic subdivision rules as demonstrated in the Figure7.9.

Figure 7.9: Cubic B-spline subdivision of a tensor produce surface with closed u-curves and v-
curves.

7.7.1 Images
Images can be viewed as tensor-product surfaces where pixel intensities refer to the control ver-
tices. More precisely, let Pi,j denote the intensity of the pixel (i, j). Then
XX
f (u, v) = Pi,j Ni,k (u)Nj,k0 (v)
i j

represents a continuous representation of the image. Consequently, by using any B-Spline subdi-
visions, we can obtain a technique for enhancing the resolution of images. In this technique, we
just need to apply the curve subdivision scheme along rows and columns of the images. The effect
of smooth subdivision schemes on images is very similar to smoothing filters.

100
Figure 7.10: Using subdivision to increase the size of an image.

For a color image, we just need to use red, green and blue intensity values of the pixel as a 3D
coordinate Pi,j = (Ri,j , Gi,j , Bi,j ) .

7.7.2 Volumetric data sets: 3D images


Devices such as MRI and CT-SCAN generates a kind of data sets usually called 3D images. This
kind of data is a special case of Volumetric data sets that represents a regular 3d grid of small
volumes(see Figure7.11). This small volumes is called voxel and contains a number as intensity of
material at the corresponding area in the 3D object.

Figure 7.11: Using subdivision to increase the resolution of a CT-SCAN image.

101
Again we can use intensity of each voxel as control points of a trivariate B-Spline. The situation
is very similar to 2D images unless we have three independent directions(row, column, depth)
instead of two directions for images. Similar to 2D images, let Pi,j,k denote the intensity of the
voxel (i, j, k). Then
XXX
f (u, v, w) = Pi,j,k Ni (u)Nj (v)Nk (w)
i j k

represents a continuous representation of the 3D image. By using any B-Spline subdivision, we


can increase the resolution of 3D image as demonstrated in the Figure7.12 In this figure, Chaikin
subdivision has been used for increasing the resolution of the data set(left) along the three main
directions row, column and depth.

Figure 7.12: Using subdivision to increase the resolution of a CT-SCAN image.

102
8 Subdivision for Polygonal Meshes
Although it is useful to subdivide curves and tensor produce surfaces, subdivision becomes much
more powerful if we are able to subdivide arbitrary topologies where u-curves and v-curves are not
available. This chapter describes several of these 3D subdivision schemes.
For these 3D subdivision schemes a coarse mesh is taken as the input. The subdivision scheme
is then applied resulting in a refined mesh with many more faces.

8.1 Doo-Sabin Subdivision


The Doo-Sabin subdivision scheme is essentially a 3D corner cutting algorithm. It is an extension
of Chaikin subdivision.
Each step of Doo-Sabin subdivision can be divided to two stages. The first stage is imagined
as a contract of each face towards its centroid. In the second stage new faces are created to connect
the contracted faces(see figure 8.1).

Figure 8.1: A single step of Doo-Sabin subdivision on a cube.

8.1.1 Types of New Faces


By looking at figure 8.1 we can see that we have three types of new faces:

• FF: Face from face. These faces result from the contraction of a coarse face.

• FE: Face from edge. These faces appear where edges existed in the coarse mesh. It is
important to note that these faces appear between two FF faces.

103
• FV: Face from vertex. These faces appear where vertices existed in the coarse mesh. These
faces appear in the middle of FE faces.
The FE and FV faces are used to fill the holes caused by the contraction of the coarse faces.

8.1.2 Subdivision Mask


Similar to when we find filter values for a curve subdivision scheme, for our general scheme we
need to find filter values that determine how the fine control points should be evaluated from the
coarse set of control points. We need filter values that ensure affine invariance, continuity, and
smoothness.
The filter values for the regular case (a mesh of four sided faces) are shown in figure 8.2.

Figure 8.2: The Doo-Sabin filter values used to contract regular faces.

These filter values are derived from Chaikin subdivision. Figure 8.3 shows how the regular
mask of Doo-Sabin can be extracted from Chaikin filters.

Figure 8.3: A regular face in a tensor product surface being contracted.

104
This face is from a tensor product surface so we can apply Chaikin subdivision to the u-curves
to get Q0 and Q1 . We then apply Chaikin subdivision to the v-curve formed between Q0 and Q1 to
get R0 .

Example 8.1
3 1 3 1
Q0 = P0 + P2 Q1 = P1 + P3
4 4 4 4
3 1 3 3 1 1 3 1 9 3 3 1
R0 = Q0 + Q1 = ( P0 + P2 ) + ( P1 + P3 ) = P0 + P1 + P2 + P3
4 4 4 4 4 4 4 4 16 16 16 16

However since we often will have to deal with non-regular cases there is also a formula for
determining the filter values given that we are dealing with a n sided face.
1 5
α0 = +
4 4n
3 + 2 cos(2iπ/n))
αi =
4n
Where α0 denotes the weight of the corresponding coarse point to the current fine point(see figure
8.4).

Figure 8.4: The general Doo-Sabin filter values used to contract faces.

Where did these equations come from? Doo and Sabin determined the formula by using Eigen
analysis.

105
8.1.3 Construction of the New Faces
For the remaining stage of a Doo-Sabin subdivision step we now create the FE and FV faces.
We construct a FE face for every edge of the coarse mesh. To do this we must find the corre-
sponding new vertices used to contract the two faces adjoining the edge. Once we have found all
four vertices we construct a new face.

Figure 8.5: The vertices used to construct an edge face. The red line represents the original edge
in the coarse mesh.

To construct a FV face we must know the faces the coarse vertex was a part of. Once we
identify these faces, we find the modified corresponding vertices from each face and construct our
new face.

8.1.4 Properties of Doo-Sabin Subdivision Surfaces


This type of subdivision results in a surface that:
• is C 1 continuous(parametric) at regular vertices and G1 (tangent plane continuity) at extra-
ordinary vertices. Note that in the regular case, it is just a Bi-quadratic B-Spline. The mask
for extra-ordinary case can guarantee only tangent plane continuity.
• has the strong convex hull property.
• produces mostly four sided faces.
• is mostly made up of biquadratic B-splines.
Why are most of the faces four sided? This is due to the fact that all the EF faces produced will
have four sides. The Euler equation for simple polyhedra:
e=v+f −2

106
where e is the number of edges, v is the number of vertices, and f is the number of faces.

So what the Euler equation tells us is that after one step of the subdivision at least half the faces
are EF faces and consequently have four sides. Note that by repeating subdivision schemes any
four sided face is also mapped to a four sided face.Therefore when we implement this subdivision
scheme it is important to ensure that cases of four sided faces are handled as efficiently as possible.

Figure 8.6: Three examples of applying Doo-Sabin subdivision.

8.2 Loop Subdivision


This subdivision scheme was developed by Charles Loop as part of his Master’s research in 1987.
This scheme requires all the faces of the mesh to be triangular. The resulting subdivided mesh is
also triangular. This subdivision is done in two steps: face split and repositioning by masks.

107
Figure 8.7: On the left is the original model while the right image shows the result of applying
several steps of Loop subdivision.

8.2.1 Face Split


The first step of refinement is to split each triangular face into four new triangular sub-faces as
demonstrated in the figure 8.8.

Figure 8.8: Face Splitting of Loop Subdivision and types of vertices.

8.2.2 Repositioning by Masks


To create a smoother fine mesh, the vertices of the refined mesh are then repositioned using a
weighted average of the vertices of coarse mesh. Two types of vertices exist(see Figure 8.8):

108
• Vertex-vertex vertices (correspond to vertices in the input mesh and sometimes called even
vertices).
• Edge-vertex vertices (correspond to edges in the input mesh and sometimes called odd ver-
tices).
These two different types of vertices have different weighting masks applied to them. For edge
vertices a weighting of all the vertices in the two faces containing the edge in the coarse mesh is
used. Vertex vertices are repositioned based on the neighboring vertices in the coarse mesh. The
exact weights for both cases are given in figure 8.9.

Figure 8.9: Loop subdivision masks.

Example 8.2

Masks for Regular case


Due to tri-directional structure for triangular meshes, the regular vertices have six neighboring
vertices(valence of six). Therefore:
 
1 5 3 1 2π 2 1
α= − ( + cos ) =
6 8 8 4 6 16

109
5 1
and so the original vertex (v i ) is weighted by 8
(= 1 − 6 16 ) and the neighboring vertices receive
1
weights of 16 .

Figure 8.10: Mask of vertex-vertex for regular case of Loop subdivision.

8.2.3 Boundaries
Special rules must be employed to prevent the boundaries of a mesh (if any) from shrinking. This
is common for all subdivision schemes. When contracting a face that is on a boundary we:

• Displace the interior vertices (those not on the boundary) using the usual subdivision filters.

• Displace the boundary vertices using the related curve schemes.

In the case of boundary of Loop subdivision, the cubic B-spline curve subdivision mask is
applied as shown in Figure 8.11.

110
Figure 8.11: Loop subdivision masks for boundary case

8.2.4 Sharp Features


Not all objects are entirely smooth. Most objects have at least some sharp edges and corners. To
naively create a sharp edge or corner one would add a large number of triangles around the crease
or corner. This is not desirable because it increases the complexity of the mesh with minimal
effects. Instead to achieve corners and crease we will apply a different mask for creases to relax
tangent plane continuity across the sharp edge.
A crease is a sequence of tagged(sharp) edges at which the Loop subdivision surface is not
tangent plane smooth(see figure 8.12).

111
Figure 8.12: Creases and corners in Loop Subdivision

There are three vertex types depending on the number of sharp neighboring :

• Normal vertex: A vertex with no sharp edges. Apply normal masks of Loop subdivision.

• Crease: A vertex with two sharp edges. Apply cubic B-spline curve subdivision masks only
using the neighboring vertices on sharp edges.

• Corner: A vertex with more than two sharp edges. The vertex position remains unchanged
during subdivision process.

Note that each edge is replaced by two new edges in the subdivision process. If one edge is
tagged as sharp in the coarse level, the corresponding fine edges are tagged sharp too.

112
8.2.5 Properties of Loop Subdivision
Loop subdivision results in a surface that:

• is C 2 continuous everywhere except at extra-ordinary vertices (i.e., in the regular case).

• has tangent plane continuity(G1 ) at extra-ordinary vertices (i.e., in the irregular case).

• has the strong convex hull property.

8.3 Catmull-Clark Subdivision


Catmull-Clark subdivision was introduced in Computer Aided Design in 1978. It is generalization
of cubic B-spline subdivision to arbitrary surfaces. It produces a C 2 surface at ordinary vertices
with a smooth tangent at extra-ordinary points. An interesting feature of Catmull-Clark subdivision
is that it can handle faces with any number of edges, but after one level of subdivision all the faces
will have four sides.

Figure 8.13: Example of Catmull-Clark subdivision.

8.3.1 Face split


Three new types of vertices are created in Catmull-Clark subdivision.

• Face-vertex (fij )

• Edge-vertex (eji )

• Vertex-vertex (vij )

113
A set of new faces is created for each vertex of a coarse face. Each of these new faces consists of
a loop of four points:
vij → eji → fij → eji+1

e30
en0 V0 e31
fn1
V1 f21
e11 e21
1
e10 f 1 e20

Figure 8.14: Three types of vertices in Catmull-Clark subdivision.

The Face-Vertex Mask


A new face vertex coming from face i, fij+1 is simply the average of face i’s vertices (the centroid
of the vertices). More formally this is expressed as:
n
j+1 1X j
f = v
n k=1 k
where n is the number of vertices in face.
The Edge-Vertex Mask
To find the new edge vertices we take the average the two vertices of the edge and the centroids of
the two adjoining faces. More formally the mask for an edge-vertex in Catmull-Clark subdivision
is:
1
ej+1
i = (vaj + vbj + fi−1
j+1
+ fij+1 )
4
where vaj and vbj are the two vertices adjoining the edge in the coarse mesh and fi−1
j+1
and fij+1 are
the two adjoining faces.
The Vertex-Vertex Mask

114
The mask for vertex-vertices(see Figure 8.14) is:
n−2 i 1 X i 1 X i+1
v i+1 = v + 2 ej + 2 f
n n j n j j

where n is the number of vertices neighboring vertex i in the coarse mesh.

8.3.2 Boundary
Follow the same rules as in section 8.2.3. The subdivision of the vertices on the boundary produces
a cubic B-spline curve.

8.3.3 Creases and Corners


Follow the same rules as in section 8.2.4, but use Catmull-Clark masks for normal vertices.

Figure 8.15: Example of Catmull-Clark subdivision with crease. In the right some of edges are
tagged as sharp.

8.3.4 Properties
Similar to Loop subdivision surfaces, Catmull-Clark subdivision surfaces are C 2 away from ex-
traordinary vertices where they are only G1 . When the entire mesh is subdivided, edge-vertex
vertices always have valence four, whereas vertex-vertex vertices retain their valence throughout
the subdivision process. Face-vertex vertices are extraordinary if the face they are inserted in is not
quadrilateral. Since each subdivision step only produces quadrilateral faces, and there are more
edges than vertices and faces, the limit surface contains mostly ordinary vertices. Consequently,
Catmull-Clark surfaces are C 2 almost everywhere.

115
Catmull-Clark subdivision has the strong convex hull property because all the masks are posi-
tive and less than 1.

8.4 Butterfly Subdivision


Similar to Loop subdivision, Butterfly subdivision operates on triangles, but it is an interpolating
scheme, meaning that the limit surface interpolates the vertices of the control mesh. The name
of this subdivision algorithm stems from the butterfly shape of the odd vertex subdivision mask.
Since Butterfly subdivision is an interpolating scheme, even vertices are not repositioned during
subdivision. For more details about this subdivision see the siggraph 2000 course note.

8.5 Adaptive Subdivision


8.5.1 Motivation
Sometimes we don’t need to subdivide the whole model. A coarse object with 1000 faces will have
16000 faces after only two subdivision steps. Rather than subdividing the whole model, we can
choose to only subdivide faces that match our refinement criteria.

8.5.2 Adaptive Loop Subdivision


The problem with adaptive loop subdivision is cracks that are due to vertices with incomplete
neighborhoods.

Figure 8.16: Cracks when only some faces are subdivided.

116
Cracks can be avoided by connecting the odd vertices(T-vertex) on the boundary of selected
area to their opposite vertex(O-vertex). However, this causes the valence of these vertices to in-
crease when subdivision is repeated. In a new algorithm, incremental subdivision, suggested by
Reza Pakdel and Faramarz Samavati, the neighboring faces are also add to the selection to be
subdivided during refinement. This in effect creates vertices with proper neighborhood in the sub-
division area and, also limits subdivision depth difference between neighboring triangles to at most
one. Hence, the resolution of the subdivision area increases gradually from coarse to fine.

117
Figure 8.17: Comparison of conventional Loop subdivision to adaptive subdivision, and the incre-
mental algorithm.

118
Figure 8.18: Comparison of conventional Loop subdivision, simple adaptive subdivision and the
incremental adaptive algorithm.

8.5.3 Adaptive Catmull-Clark Subdivision


The same algorithm can be extended to Catmull-Clark subdivision. In adaptive Catmull-Clark
subdivision, it is possible to have two T-vertices in a face. In this case, a face-vertex is inserted
into the face and connected to the T-vertices and one vertex of the face such that three quads are
produced. By extending the selected subdivision area, T-vertices are kept outside the selected and
obtain a smooth surface that is the same as when the entire mesh is subdivided.

119
Figure 8.19: First row: regular Catmull-Clark subdivision, Second row: simple adaptive, Third
row: incremental adaptive subdivision.

120
9 Multiresolution, Wavelets, and Reverse Subdivision
9.1 Introduction
As we have discussed previously, it is possible to increase the resolution of the graphical mod-
els(curve, surface, image) using various subdivision schemes.

Figure 9.1: Subdivision of a closed curve.

Figure 9.2: Subdivision of a mesh with arbitrary topology.

121
Figure 9.3: Subdivision used to increase the resolution of an image.

However, in many applications both increasing and decreasing of the model’s resolution is
desired. A simple method to reduce the resolution would be simply removing every other point.
This is not a good solution. For a true multiresolution framework the following properties must be
considered:
• feasibility of reducing and increasing the model’s resolution.

• reconstruction of the fine model.

• efficiency of the method (a linear time algorithm is desired).

• efficiency of memory (a coarse model should not use more memory than a fine model).

• shape preservation (we would like the coarse model to be a good approximation of the fine
model).
So in the solution of removing every other point, the second and forth properties are contradicted.
To fix this, one might suggest to find a good coarse approximation (somehow) and then keep

122
in memory all the two resolutions (coarse and fine) of the model. This contradicts the memory
constraint.
So what is the right way to do this? Obviously in reducing the number of points in a curve
or a mesh, we are removing some information. We can look at this problem in terms of another
common graphics operation, projection. When we project a 3D model into 2D screen space we
lose depth information. Normally this operation is irreversible unless this depth information is
captured. If we have depth information, we can simply unproject the image and then add the depth
information. The conventual approach (wavelets) and our approach (reverse subdivision) are the
same; the model is coarsen and the missing details information are stored.

Figure 9.4: Multiresolution information for a model of an American penny.

The act of converting a fine model into a coarse approximation and the corresponding details
is called decomposition. The act of mapping the low resolution and the details to the original fine
resolution is called reconstruction. We start our discussion with a simple example of multiresolu-
tion based on Haar wavelets.

9.2 Harr Wavelets


Consider a row of a small picture:

[5, 7, 10, 14, 13, 13, 8, 6]

123
These values can also be considered as coordinates of a curve. This can also be represented by an
approximating function

f¯(x) = 5φ̄0 (x) + 7φ̄1 (x) + . . . + 6φ̄7 (x)

where φi is a box function with height one over the interval [i, i + 1]. The bar notation (i.e., f¯) is
used to mark the fact that we are referring to fine space.

Figure 9.5: The function approximating the row of a small picture.

A simple and good method for creating a coarse estimate is to use the average of every two
samples.

5+7
c0 = 2
=6 c1 = 10+14
2
= 12
13+13
c2 = 2
= 13 c3 = 8+6
2
= 7

C = [6, 12, 13, 6]

124
Figure 9.6: The coarse approximation of the row of a small picture.

This now leads us to our previous question of how we should return to the fine data from the
coarse data. Considering our data we find c0 from f0 and f1 , c1 from f2 and f3 and so on. The
details that we need to save are simply the difference between the average used for the coarse data
and the fine data value. So our detail value is: left fine value − average.

Figure 9.7: The details mark the difference between the fine point (circle) and the coarse point
(square).

d0 = 5 − 5+7
2
= −1 d1 = 10 − 10+14
2
= −2
d2 = 13 − 13+13
2
= 0 d 3 = 8 − 8+6
2
= 1

D = [−1, −2, 0, 1]

So our resulting multiresolution representation of the data is [6, 12, 13, 7, −1, −2, 0, 1].
This gives us two operations:

125
Decomposition:
F → C
& D
Reconstruction:
C →F
D %
F is the coefficient vector of the fine basis φ̄.
C is the coefficient vector of the coarse basis φ.
The question is, what is D a coefficient vector of?

9.2.1 Interpretation of D
Let’s find a basis function for the left and right operations.

left = a + 1 ∗ details
right = a − 1 ∗ details
therefore φ̄0 − φ̄1 = ψ0

1 x<a
ψ(x) =
−1 x > a

Figure 9.8: The Haar wavelet function (ψ).

D is the coefficient vector of the new basis ψ.

9.2.2 Decomposition
f¯(x) = f (x) + g(x)

F → C f¯(x) → f (x)
& D & g(x)

126
Figure 9.9: The decomposition process.

Remember that:

• f¯(x) is the high frequency function

• f (x) is the low frequency approximation

• g(x) is the high energy part of f¯(x) (the small variations)

We can apply this decomposition several times. So for our simple example this is:

[5, 7, 10, 14, 13, 13, 8, 6] −→ [6, 12, 13, 7, −1, −2, 0, 1] C k+1 → C k , Dk
We then repeat this for C k :
[6, 12, 13, 7] −→ [9, 12, −3, −3]
We can then represent all of our data as:

[5, 7, 10, 14, 13, 13, 8, 6] −→ [9, 12, −3, −3, −1, −2, 0, 1] C k+1 → C k−1 , Dk−1 , Dk

9.3 Applications
9.3.1 Data Transmission
A major application of wavelets is in data transmission. In sending a large amount of data through
a network we can first transform the data into a multiresolution wavelet representation and send
across a coarse representation (i.e., C 0 ) and then the levels of detail necessary to reach the final

127
fine level of detail (C k ). This allows the receiver of this data to view the coarse data as it comes it
to ensure that the desired data is being transmitted. This is much like the processes progressive jpg
encoding allows.

9.3.2 Image Compression


An image can be thought of as rows and columns of pixel values. These values can be used by
wavelets to decrease the resolution of the image. To do this we first decompose the rows of the
image.

Figure 9.10: The row decomposition of our image. The resulting coarse approximation is on the
left, the details are on the right.

Then we decompose the columns of the image and the row details.

128
Figure 9.11: The final resulting decomposition of our image. Notice that most details are close to
zero.

As can be seen in the figure above most of the details are close to zero, therefore we can simply
throw out some of the details and achieve a good compression rate.

9.3.3 Video Compression


A video is a sequence of frames (images). We can use wavelets to manipulate the resolution of
time. We can reduce the number of frames stored and, as in image compression, we throw out the
insignificant details to achieve compression.

129
Figure 9.12: A pixel in a sequence of frames that can be represented by wavelets.

In the figure below we can see that decomposition reduces the number of frames creating a
short, rough animation and some details.

Figure 9.13: The decomposition of a short animation.

As the video is played we use reconstruction to restore the original number of frames again
(without the details we have thrown out).

Figure 9.14: The reconstruction of the animation.

130
9.4 Multiresolution Filter Matrices
For Haar wavelets we can easily create the following matrices for decomposition and reconstruc-
tion. For the sake of simplicity, small size matrices have been used :
   
1 0 1 0
 Q =  −1 0 
 1 0   
P = 0 1   0 1 
0 1 0 −1
 1 1   1 −1 
2 2
0 0 2 2
0 0
A= B=
0 0 21 21 0 0 21 −1 2
So the decomposition is performed by:
 
F0

 F1 

1 1
  
C0 0 0 0 0 0 0 
2 2 F2 

 C1   0 0 1 1 0 0 0 0   F3 
2 2
 C2  =  0 0 0 0 1 1 0 0  
    
2 2  F4 

C3 0 0 0 0 0 0 21 21 
 F5 

 F6 
F7

 
F0
 F1 
−1
   1
 
D0 2 2
0 0 0 0 0 0  F2 
−1
1
 
 D1   0 0 0 0 0 0   F3 
2 2
 D2  =  0 −1
   1
 
0 0 0 2 2
0 0  F4 
−1
1
 
D3 0 0 0 0 0 0 2 2

 F5 

 F6 
F7

or more simply as C = AF and D = BF .

The next task to describe is reconstruction. Firstly, remember that

F0 = C0 + D0 , F1 = C0 − D0 , F2 = C1 + D1 , F3 = C1 − D1 , ...

131
We can do this reconstruction with the following matrices:
     
F0 1 0 0 0 1 0 0 0
 F1   1 0 0 0   −1 0 0 0 
       
 F 2   0 1 0 0  C0  0 1 0 0  D0
     
 F3   0 1 0 0   C1   0 −1 0 0  D1 
 F 4  =  0 0 1 0   C2  +  0
       
     0 1 0 
 D2 
 F 5   0 0 1 0  C3
   
 0
 0 −1 0 
 D3
 F6   0 0 0 1   0 0 0 1 
F7 0 0 0 1 0 0 0 −1

or more simply as F = P C + QD.

Mathematically, we can specify the multiresolution operations at a high level in terms of the
filter matrices An , B n , P n , and Qn of a specific scheme. Given a column vector C n of samples,
a lower-resolution level C n−1 is created via decomposition using the analysis filters An and B n .
The superscripts refer to the decomposition level, where n is the original, highest resolution. The
matrix An is used to down-sample the input, giving a coarsened approximation to C n :

C n−1 = An C n .

The details Dn−1 lost through the down-sampling are captured using B n :

Dn−1 = B n C n .

Recovering C n from the previous level’s points, is called reconstruction. It involves refinement of
the coarsened points C n−1 and details Dn−1 using the synthesis filters P n and Qn which reverses
the operations of An and B n :
C n = P n C n−1 + Qn Dn−1 .
The multiresolution operations are successively applied to each generated level creating a hierarchy
of details that gives us the original input when reconstructed. Although An , B n , P n , and Qn are
varied at different levels, they have a regular and repetitive structure. This fact is important for the
efficient implementation of these operations.
A very important property is that [ BA
][P |Q] = I, or written another way, [ BA
] = [P |Q]−1 . This
in fact is the necessary condition to reconstruct the original fine data after decomposition.
Haar wavelets are good for approximating piecewise constant functions (i.e., straight lines),
however they are not good for approximating smooth curves and surfaces. The scalings(original
basis functions) of Haar are first order B-splines and therefore better wavelets for curves would be
multiresolution filters generated from higher order B-splines.

132
9.5 B-Spline Wavelets3
The conventional method for constructing multiresolution representation (MRA) for B-spline is to
build B-spline wavelets first. Although, the goal in this text is not to discuss this kind of methods
in details, a very high-level discussion could be helpful. Assume we want to find MRA for cubic
B-spline. In fact, the coarse and fine basis functions, φ(u) and φ̄(u), are known here. For example,
for a given standard knot sequence, φ(u) is a vector function that includes all cubic B-spline basis
functions. And φ̄(u) is a vector function that includes all cubic B-splines after inserting midpoints
into the original knot sequence. The first step in conventional methods is to find a vector function
ψ(u) that forms a basis for complement space of coarse B-splines. In a simpler term, perhaps
not very accurate, φ(u) is coarser and weaker than φ̄(u), however, ψ(u) helps φ(u) to cover this
weakness. Therefore, the wavelets approach to construct MRA is:
• Build the wavelets functions.

• Use the functions to find multiresolution filter matrices A, B, P , and Q.


The drawback to this approach is that rather complicated to deal with and yield very complicated
and ugly matrices.
As an alternative approach, MRA can be built by reversing subdivision. The idea is comparable
with the idea of subdivision: do curve and surface modeling by direct and discrete operations on the
points, no need to use basis functions. In reverse subdivision approach for MRA, we can directly
operate on discrete data and avoid any functional operations using φ(u) , φ̄(u) and ψ(u).
For constructing MRA in reverse subdivision approach, we start with a given fixed subdivision
matrix P (for example Chaikin subdivision). Assume F denotes a vector containing all of the fine
points. We would like to find a coarse point vector C in such a way its subdivision becomes close
as much as possible to F or equivalently P C becomes a very good approximation of F . This helps
to express the essence of F via subdivision process. For best approximation, we need a method
that directly operates on discrete data points, therefore we use Discrete Least Squares. For this, we
minimize the Euclidean distance of P C and F as vectors:
X
min ||P C − F || = ((P C)i − Fi )2 . (9)
C
i

Notice C is the only unknown in the above problem. Using linear algebra, it is not to hard to show
that the solution of 9 is also the solution of the following non-singular linear system which is called
normal equation:

P T P C = P T F.
3
This is an optional section, only for further readings.

133
The matrix P and P T P are shown in the figure 9.15.

Figure 9.15: P , P T P , alternating P ’s columns to make Q’s column and finally Q.

For the details vector D, we need to find Q matrix. In essence, details are related to the residual
of 9. Therefore, as an elegant solution, we try to find columns of Q such that they form a basis
for complement space of P ’s columns. This can be easily done by alternating the signs of general
column of P (in general case, we may have to reverse the order and then alternate the signs) as
shown in the figure 9.15.

134
Having P and Q, the rest of the steps for MRA can be summarized as following :

9.5.1 Local B-Spline Wavelets


Notice in 9.5, we do not directly use A and B but we solve two banded linear systems. The mainly
because A and B are full matrices. Although, using a good algorithm for solving banded systems
results in a fast linear time algorithm, still a local perturbation in fine points may perturbs the entire
coarse points. This global effect might not be desirable for some applications. In fact, the least
square problem 9 is the reason for this global effect. In that formulation, we are looking for the
best C to minimize the Euclidian distance for all terms like ((P C)i − Fi )2 . To obtain banded A
and B we have to localize the problem using a discrete local least squares method. The resulting
filters automatically produce the best coarse points for local neighborhoods of fine points. The
width of this neighborhood dictates the bandwidth of A and B. Wider filters generate a better
coarse approximation but require more computations. There is an efficient technique for finding
filters that considered all the fine points to create coarse points described by the paper at
http://pages.cpsc.ucalgary.ca/s̃amavati/papers/LocalLS.pdf. Some example B-spline MRA based
on this technique can be found in the survey paper http://pages.cpsc.ucalgary.ca/s̃amavati/papers/local_MR.pdf
As a simple but important example, the regular MRA filters for Chaikin subdivision obtained
from this approach when the window size is set to four:

a =  − 41 34 43 − 14 
 

b =  − 14 43 − 34  14
(10)
p =  41 43 34 14
q = − 41 − 34 43 14

.

135
The interpretation of the above compact notation is
 
. . .
 −1 3 3 1 0 0 0 0 
A= 4 4 4 4
 0 0 −1 3 3 1 0 0 

4 4 4 4
. . .
or equivalently its point based operation:
−1 3 3 −1
C0 = F−1 + F0 + F1 + F2
4 4 4 4
The B Filter:
 
...
 1 −3 3 −1 0 0 0 0 
B= 4 4 4 4
 0 0 1 −3 3 −1

4 4 4 4
0 0 
...
And its point based operation:
1 −3 3 −1
D0 = F−1 + F0 + F1 + F2
4 4 4 4
The Q Filter:
−1
 
4
0
−3

4
0 
−1
 3

 ... ... 
Q= 4 4
−3
1

 
 4 4 
3
 0 4

1
0 4
and its application on points:
3 1 3 −1
F−1 = C−1 + C0 + D−1 + D0
4 4 4 4
1 3 1 −3
F0 = C−1 + C0 + D−1 + D0
4 4 4 4
These filters are appealingly simple, yet their quality is reasonably good.
The construction has been also nicely successful for cubic B-spline with a width of seven:

a =  18 − 21 83 1 38 − 21 18
 

b =  − 81 12 − 34 21  − 18
p =  81 21 34 12 18
q = 81 − 12 83 1 38 − 12 18

.

136
9.6 Chaikin reverse subdivision
Here we focus on an intuitive way based on reversing Chaikin subdivision to obtain the same filters
from precious section using simple geometric interpretation.

Figure 9.16: Geometric interpretation of the Chaikin reverse subdivision.

As shown in figure 9.16 we have


1
M= (C−1 + C0 )
2
3 1 1
F0 = C0 + C−1 = (M + C0 )
4 4 2
3 1 1
F1 = C0 + C1 = (N + C0 )
4 4 2
We first assume that F−1 , F0 , F1 and F2 are resulted from subdivision and try to reverse this
process as follows:
1
M = (F−1 + F0 )
2
3 1
C0 = M + 2 (F0 − M ) = 2F0 − M = F0 − F−1
2 2
similarly we have
1
N = (F1 + F2 )
2
137
3 1
C0 = N + 2 (F1 − N ) = 2F1 − N = F1 − F2
2 2
Now assume F represents general points not necessarily resulted from subdivision.

Figure 9.17: Reversing subdivision of general points.

As shown in figure 9.17 we can estimate C0l from F−1 and F0 and C0r from F1 and F2
3 1
C0l = F0 − F−1
2 2
3 1
C0r = F1 − F2 .
2 2
Therefore, a reasonable estimate for C0 will be the average of C0l and C0r
   
1 l r
 1 3 1 1 3 1
C0 = C + C0 = F0 − F−1 + F1 − F2
2 0 2 2 2 2 2 2
−1 3 3 −1
C0 = F−1 + F0 + F1 + F2
4 4 4 4
which gives us exactly the same A filter.
As shown in figure 9.17, details can be found as
 
l 3 1 −1 3 3 −1
d0 = C0 − C0 = F0 − F−1 − F−1 + F0 + F1 + F2
2 2 4 4 4 4

138
−1 3 −3 1
d0 = F−1 + F0 + F1 + F2
4 4 4 4
which gives us exactly the same B filter.
This approach can also be used for reconstruction of the original fine points. For example to
r
find F0 we need just to apply the subdivision scheme on C−1 and C0l

3 1 r 3 1
F0 = C0l + C−1 = (C0 + d0 ) + (C−1 − d−1 )
4 4 4 4
3 1 3 −1
F0 = C0 + C−1 + d0 + d−1
4 4 4 4
similarly we can obtain
1 3 1 −3
F−1 = C0 + C−1 + d0 + d−1
4 4 4 4
which gives us exactly the same P and Q filters.

9.6.1 Boundary filters for quadratic B-Spline Wavelets


All multiresolution filters in the previous subsection are regular, meaning they are applicable only
to data with full neighborhoods. Using symmetric extension, we can apply such regular filters to
curves, surfaces, and images with boundaries. However, boundary interpolation is often strongly
desired. To have this property, we must sacrifice the regularity of the filters near to the boundary.
To fulfill the interpolation condition for B-spline representations, multiple knots are used at the
ends of the knot sequence, corresponding to the beginning and ending portions of any data that
the filters might operate on. This knot multiplicity creates irregular or extraordinary parts in the
subdivision matrix P and consequently in the other matrices A, B and Q. We use a block matrix
notation to separate the boundary filters from the regular filters. For example, the P matrix for
Chaikin with the interpolation condition is shown in (11). In this notation Ps shows the extraordi-
nary parts of the subdivision matrix near to the start of the sample vector. Similarly, Pe refers to
the extraordinary parts near to the end. And finally, Pr shows the regular portion of this matrix.
 
Ps
P =  Pr  , (11)
Pe
where " #
1 0 0 0 0 ···
Ps = 1 1
,
2 2
0 0 0 ···

139
 
3 1
 0 4 4
0 0 ··· 
1 3
0 0 0 ··· 
 
4 4

 
Pr = 0 0 3 1
0 ···  ,


 4 4 
1 3

 0 0 4 4
0 ··· 

..
.
 
1 1
··· 0 0 0 2 2
Pe =   .
··· 0 0 0 0 1
If we use the same kind of the blocked matrix notation for A,
 
As
A =  Ar  , (12)
Ae
where As , Ar and Ae respectively refer to the extraordinary block near to the start, the regular
block and the extraordinary block near to the end, then the result of the boundary analysis is:
" #
1 0 0 0 0 0 ···
As = ,
− 12 1 3
4
− 1
4
0 0 · · ·
 
1 3 3 1
0 0 −4 4 4
−4 0 0 ···
 
Ar =  0

0 0 0 −4 1 3 3
−41
···  ,

4 4
..
.
 
1 3 1
··· 0 0 −4 4
1 −2 
Ae =  .
··· 0 0 0 0 0 1
And B is " #
− 21 1 − 34 1
4
0 0 0···
Bs = ,
0 0 − 14 3
4
− 34 1
4
0···
 
1
0 0 0 0 4
− 34 3
4
− 14 0 0 ···
 
Br =  0 0 0 0 0 0 1
− 34 3
− 14 ···  ,

 4 4
..
.

140
h i
Be = ··· 0 0 1
− 34 1 − 12 .
4

Finally, for Q we have


 
0 0 0 0 ···
 1
··· 

 2 0 0 0
 
 3 1
 −4 0 0 ··· 

4
Qs = 
 −1 3
 ,
 4 4
0 0 ··· 

 
 0 −3 −1 0 ··· 
 4 4 
0 − 4 − 34
1
0 ···
 
3
 0 0 4
− 14 0 0 ··· 
1
0 0 − 34 0 0 ··· 
 
4

 
Qr =  0 0 0 3
− 14 0 ···  ,


 4 
1

 0 0 0 4
− 34 0 ··· 

..
.
 
1
··· 0 0 0 2
Qe =   .
··· 0 0 0 0

9.6.2 Efficient Algorithm


We show how an efficient algorithm can be made based on the multiresolution filters for quadratic
B-spline subdivision, according to the matrix forms presented in Sec. 9.6.1.
For all algorithms, we have focused on doing just one step of decomposition or reconstruc-
tion. Each algorithm can be used multiple times to construct a hierarchical wavelet transform. In
all cases F represents the vector of high-resolution data, C represent low-resolution data and D
represents the detail vector.
Conceptually, a multiresolution algorithm performs these matrix-vector operations.

C = AF
D = BF
F = PC + QD .

141
However, A, B, P, and Q are regular banded matrices, so using matrix-vector operations is
not efficient. By using the blocked and banded structure of these matrices, more efficient (O(n)
versus O(n2 )) algorithms can be obtained.
The first algorithm is REDUCE - RESOLUTION. In this algorithm, F [1..m] is the input fine data
and the vector C[1..n] is the output coarse approximation. The index i traverses F and j traverses
C.
REDUCE - RESOLUTION (F [1..m])
1 C1 = F 1
2 C2 = − 21 F1 + F2 + 34 F3 − 41 F4
3 j=3
4 for i = 3 to m − 5 step 2
5 Cj = − 14 Fi + 34 Fi+1 + 34 Fi+2 − 41 Fi+3
6 j =j+1
7 endfor
8 Cj = − 14 Fm−3 + 43 Fm−2 + Fm−1 − 21 Fm
9 Cj+1 = Fm
10 return C[1..j + 1]
Lines 1–2 in REDUCE - RESOLUTION correspond to the As matrix, while lines 8–9 correspond to
the Ae matrix. The for loop represents the application of the regular Ar block.
The second algorithm is FIND - DETAILS. We can again identify blocks corresponding to Bs ,
Br , and Be .
FIND - DETAILS (F [1..m])
1 D1 = − 21 F1 + F2 − 34 F3 + 41 F4
2 D2 = − 41 F3 + 34 F4 − 43 F5 + 14 F6
3 j=3
4 for i = 5 to m − 5 step 2
5 Dj = 14 Fi − 43 Fi+1 + 34 Fi+2 − 41 Fi+3
6 j =j+1
7 endfor
8 Dj = 14 Fm−3 − 43 Fm−2 + Fm−1 − 21 Fm
9 return D[1..j]
For reconstruction, we need to compute PC + QD. The 2-scale column shift property causes to
have two kinds of regular rows(odd and even) for P and Q. This only requires simple odd/even
regular rules as demonstrated by the algorithm RECONSTRUCTION.
RECONSTRUCTION (C[1..n], D[1..s])

142
1 E1 = 0D1
2 E2 = 21 D1
3 E3 = − 34 D1 + 14 D2
4 E4 = − 14 D1 + 34 D2
5 E5 = − 34 D2 − 41 D3
6 E6 = − 14 D2 − 43 D3
7 j=7
8 for i = 3 to s − 1
9 Ej = 34 Di − 41 Di+1
10 Ej+1 = 14 Di − 34 Di+1
11 j =j+2
12 endfor
13 Ej = 12 Ds
14 Ej+1 = 0Ds
15
16 F1 = C1 + E1
17 F2 = ( 21 C1 + 12 C2 ) + E2
18 j=3
19 for i = 2 to n − 2
20 Fj = ( 34 Ci + 41 Ci+1 ) + Ej
21 Fj+1 = ( 14 Ci + 34 Ci+1 ) + Ej+1
22 j =j+2
23 endfor
24 Fj = ( 12 Cn−1 + 12 Cn ) + Ej
25 Fj+1 = Cn + Ej+1
26 return F [1..j + 1]
Lines 1–14 in RECONSTRUCTION construct the E = QD term. Lines 1 through 6 correspond to
Qs , and lines 13–14 apply Qe . The for loop at line 8 is for the regular block Qr . In line 1, E1
has been set to 0D1 instead of 0 to have general algorithm that can work for the data with any
dimension induced by D. Lines 24 trough 37 make F = PC + E. Again the terms Pe , Pr and Pe
are distinguishable in the algorithm.
Note that m, the size of the high-resolution data F , is equal to n + s; it is clear that the running
time of all three algorithms is linear in m.

143
Figure 9.18: Capturing stroke styles: (a) the original curve. (b) the curve from (a), reconstructed
without Di . (c) A new base curve. (d) The reconstructed curve with the (c) as the base curve and
details Di from (a).

9.7 Example Applications


Multiresolution provides a tool for decomposing data into a hierarchy of components with different
scales or resolutions. This hierarchy can be used for noise removal, compression, synthesizing and
recognition of the objects. In particular, multiresolution of smooth scalings and wavelets can nicely
be used for smooth objects. Here we show some examples and applications of the quadratic and
cubic B-spline multiresolution filters.

9.7.1 Curve by Examples


We can use multiresolution filters on curves, such as those representing artistic silhouettes and
line hand-gesture styles. Using analysis filters, we can extract styles (based on the characteristic
details) from the curves, and these styles can then be applied to new base curves. Figure 9.18
shows an application of this, based on the interpolating quadratic B-spline wavelets from Chaikin
subdivision.

9.7.2 Removing noise from Curves


If we reconstruct a data set without using any (or using only a small portion) of the details, a simple
de-noising is achieved.

9.7.3 Image Compression


After decomposing an image to a low-resolution approximation and corresponding details Di , we
can lossily compress the image by removing small magnitude details. This is one major step in

144
Figure 9.19: Comparison of quadratic B-spline wavelets image compression with established tech-
niques: (a) a sample image containing high-frequency data; (b) the resulting compression rates for
various filters.

current image compression techniques such as JPEG. In compare with Haar filters, all of B-spline
filters reported in this note have better compression rates. These MRA filters with more successful
image compression filters, D9/7 and D4, that have been used in JPEG2000 have been compared.
Although our discussed MRA filters are based on smooth scalings and wavelets (in contrast to
D9/7 and D4), the resulting compression rate is comparable; see Fig. 9.19. In this comparison, we
have removed the same amount of the details and compared the PSNR of the reconstructed images;
higher PSNR indicates better detail retention. In particular, the wide quadratic B-spline filters is
obtained by setting the local window size to eight(it is not discussed in this note) perform very
close to the D9/7 filter.

145
Figure 9.20: Left: A smooth base terrain. Middle: a model terrain with high-frequency details.
Right: the synthesized terrain.

9.7.4 Terrain by Example


Terrain is typically represented with a height map (a regular grid of elevation data), which directly
maps to an open-open tensor-product surface. Multiresolution helps us to use an existing terrain
to synthesize new terrain by transferring the characteristic details as descibed in Terrain Synthesis
By-Example paper at http://pages.cpsc.ucalgary.ca/s̃amavati/papers/terrain_by_example.pdf. For
terrain synthesis, we can capture the details of a high-resolution target terrain and use them for a
smooth base terrain to add realistic and more predictable noise. Figure 9.20 shows the application
of the quadratic filters to terrain synthesis.

146
10 Solid Modeling
10.1 Introduction
A solid object encloses a finite amount of space and the concepts of inside and outside for this
kind of objects are well-defined (see Figure 10.1). Most of the realistic objects are solid and
consequently, solid modeling is very crucial for CAD/CAM industry.
For solid modeling, having a space representation is necessary. Using parametric surfaces or
meshes for representing the skin of the solid is a reasonable approach, however there are some
other related issues for solid modeling. For example, supporting Boolean operations like union,
intersection and cut is usually desirable for solid objects. Another profitable feature is to ability of
deforming the space and its containing objects. Therefore, we not only should represent the solid
but also should answer how to deform and how to support Boolean operations.
Using parametric surface or any kind of other boundary representation have issues for showing
the internal space and also require a fast and suitable method for computing boolean operations.
Trimmed NURBS is a appropriate approach to be used for solid modeling, although, we have to
find intersection of non-linear parametric patches for each operation. Using meshes for solids leads
us to find intersection of two , possible very large, polygonal meshes which is not usually trivial
problem.
To achieve a good representation for solids and the above discussed properties, we introduce
several modeling techniques:
• Trivariate Parametric Patch

• Implicit Representation

• CSG

• OCTREE

10.2 Trivariate Hyper Patches


Recalling from parametric surfaces, Q(u, v) is a deformation of a rectangular domain to a 3D
surface. Any point on the surface is easily created from and represented by (u, v) in the parametric
domain. Trivariate patches are direct extension of this idea: Q(u, v, t) is a deformation of a cuboid
domain to a 3D solid. Any point inside of solid is created from a triple like (u, v, t). For creating
points inside solids, we can discritisize the domain to (ui , vj , tk ) and find the act of Q on these
triples(Q(ui , vj , tk )). A good advantage of this representation is that not only it can provide a
representation for solids but also it can easily create a space deformation. For doing this, it is

147
Figure 10.1: Left: a sphere is a solid object. Right: a half-sphere is not a solid object.

Figure 10.2: Left: The shape as the domain of a bilinear patch. Right: The shape scene deforma-
tion.

enough to cover the scene by a encompassing cuboid. Then any Q(u, v, t) whose domain is the
cubiod, acts as a deformation of the scene. Figure 10.2 illustrates this idea in 2D case (Q(u, v)).
For defining Q(u, v, t), the best approach is to use and extend control point paradigm using
Bezier, B-spline or NURBS. For this approach, we have to start from a 3D lattice of control point
Pi,j,k and then the surface(for example in the case B-spline) is defined
m X
m X
m 0 00
X
Q(u, v, t) = Pi,j,k Ni,d (u)Nj,d0 (v)Nk,d00 (t). (1)
i j k

This shows that trivariate patch is a good representation for space when we would like to start
from the domain and find its result after applying Q. However, for the Boolean operations we need
to use many times the inquiry whether the point p is inside the given solid(trivariate patch here).
This is not a trivial and simple question for a trivariate parametric patch. Therefore, we would like
to consider other solid representations.

148
10.3 Implicit Modeling
We can represent an object by many mathematical models. Parametric and implicit representations
are two important modeling approaches.

Example 10.1

The unit circle:


• Parametric form:
   
x(u) cos u
Q(u) = = 0 ≤ u ≤ 2π
y(u) sin u
vary u and evaluate x = x(u) and y=y(u)
• Implicit form:

f (x, y) = x2 + y 2 − 1 or f (p) = kpk2 − 1


Find all p = (x, y) ∈ E2 such that f (x, y) = 0 or f (p) = 0. Function f does not not explicitly
describe the curve, but implies its existence.

Figure 10.3: The unit circle

In the above example, finding all p is not a simple problem, parametric modeling is usually
preferred. However, in some special kind of applications, implicit modeling is advantageous.
Intuitively, an implicit surface consists of set of points in 3D that satisfy a particular requirement.
This requirement is represented mathematically by function f . Function f characterizes a volume.
In addition, f (p) is proportional to the distance between p and the surface.

149
10.3.1 Benefit of Implicit Modeling
In solid modeling, it is important to be able to find the inside and outside of the solid. In implicit
modeling, f (x, y) < 0 implies inside the model and f (x, y) > 0 implies outside.

Example 10.2

In the previous example

• f (0, 0) = −1 ⇒ (0, 0) is inside

• f (0.5, 0.5) = −0.5 ⇒ (0.5, 0.5) is inside

• f (1, 0) = 0 ⇒ (1, 0) is on the curve

• f (1, 1) = 1 ⇒ (1, 1)is outside

To extend inside/outside determination to 3D, we use a 3 variable function f (x, y, z) and 3D


point p as input. For example, the unit sphere is x2 + y 2 + z 2 − 1 = 0 or f (p) = kpk2 − 1.

10.3.2 Normal to the Implicit Surface


The vector function, gradient 5f = ( δf , δf , δf ) is a the normal of the surface at point p(x, y, z).
δx δy δz

Example 10.3

For the unit sphere:


5f (x, y, z) = (2x, 2y, 2z)

• 5f (1, 0, 0) = (2, 0, 0)

• 5f (0, −1, 0) = (0, −2, 0)

• 5f (0, 0, 0) = (0, 0, 0)

150
If the gradient is zero, we cannot have a suitable normal.

Point p is a singular point if 5f (p) = 0,otherwise it is regular.

Example 10.4

• p = (1, 0), x2 + y 2 − 1 = 0

• p = (2, 0), x2 + y 2 − 4 = 0

To evaluate the gradient:


δf δf δf
5f (p) = ( (p), (p), (p))
δx δy δz

δf f (x + ∆x, y, z)
(p) = lim
δx ∆x→0 ∆x
δf f (x + δ, y, z) − f (x − δ, y, z)
(p) ' for a small step size δ
δx 2δ
δf δf
Similarly for δy
(p) and δz
(p)

10.3.3 Implicit Representation of Primitives


Each primitive is represented by a skeletal element. The iso-surface is all the points with the same
distance (r). It is determined by using an energy function, e.g. f (r) = r12 .

10.3.4 Point
Assume we have a hot point at c. An implicit surface is formed by all points around c, with the
same temperature (iso-surface). For all points p on the iso-surface, kp − ck = r. The implicit
function here is the temperature. Set f (r) ' r12 . Therefore, the only important term for making
this primitive is the radius r. Hence, the iso-surface is f (r) = T

151
Figure 10.4: A point primitive

10.3.5 Lines
If the skeleton is a line (a hot bar), r is taken to be the closest distance to the line. Here the
iso-surface is also f (r) = T

Figure 10.5: A line primitive

Other primitives, for example triangle primitives, can be considered too. In general, it would
be more appropriate to have a series of very simple primitives and make complex objects by com-
bining these simple primitives using Boolean operations and blend operation.

152
Figure 10.6: Left: Diagrams for two intersection solids. Right: The associated functions for the
Boolean operations.

10.4 Boolean Operations on Implicit Models


We would like to have a simple method for boolean operations in implicit modeling (skeletal
approach). We need a simple test for inside/outside of the combined surfaces. In the first step, we
slightly change the notation. Assume the energy function f , center A and threshold T .
We introduce F as:
F (p) = f (p) − T
to have zero value on the iso-surface. To find the inside and outside of the solid

• F (inside) > 0

• F (outside) < 0

• F (on surface) = 0

With this new definition, having two primitives, we can find their intersection, union and difference.
For doing this, we must define the new energy functions for the combined solids. Figure 10.2 shows
how to find these functions.

153
To find the difference SA − SB = SA ∩ SB0 = min(FA , −FB ). Figure 10.7 show the results of
union, intersection and difference operations of two point primitives.

Figure 10.7: Union, intersection and difference of two point primitives.

10.5 Blending
As demonstrated in the Figure 10.7, Boolean operations create sharp features on the combined
solids. This can be also understood from the energy functions of these operations. Neither min
nor max functional operators is a smooth function. In many applications, it would be a good
idea to combine primitives in a smooth fashion. In essence, addition of energy functions is a
smooth operator and can have a nice blending result. Assuming f (r) ' r12 , the blend of two point
primitives can easily be found by adding the fields’ strength at any given points. Figure 10.8show
the effect of this new operation.

Figure 10.8: Blending of two points. The threshold has been set to three different values.

154
Let’s consider a simple 2D example for this operation.

Example 10.5

Two point primitives with the centers c1 = (0, 0), c2 = (4, 0) are given. To find the total(after
blending) field strength at a test points p = (0, 2), we have
1 1 1
f (p) = f1 (p) + f2 (p) = + = .
4 4 2
Notice that for a threshold T = 0.3, the point p was outside of both primitives(f1 (p) <
T, f2 (p) < T ), however after blending, the point would be inside of the blending surface(f (p) >
0.3).

P
This idea can be extended for blending many primitives at p using i f (ri where ri = repre-
sents the distance of p to the ith primitive.

10.5.1 Better Blending


The simple energy function f (r) = r12 usually results in some practical difficulties. For example,
consider the blending of two point primitives as shown in figure 10.9. If the distance between two
primitives becomes large, we expect to see only two simple point primitives as the result of the
blend operation. However, this does not happen since the energy function is not local and has an
unbounded support.

155
Figure 10.9: Increasing the distance of two point primitives.

To perform a local effect, we should change the energy function. In addition, it would be
necessary to have a smooth transition from f (r) to zero. This smooth transition results in a smooth
iso-surface and smooth overlaps. This can be done by sigmoid functions. Figure 10.10 shows such
a function. Note that the function is smooth at r = 0 and r = R.

Figure 10.10: Sigmoid function that gives better blending

There exist many ways to define this kind of energy functions. Here we introduce two different
methods:
• Metaballs (Alaska University)
2

 a(1 − 3rb2 ) 0 ≤ a ≤ 3b
3a
f (r) = (1 − rb )2 3b ≤ r ≤ b quadratic B-spline
 2
0 b≤r

156
Figure 10.11: Ray-sphere intersection can be solved by substituting the ray description into the
sphere definition.

• Soft objects (Wyvill)


4r6 17r4 22r2
f (r) = 1 − + −
9R6 9R4 9R2

10.6 Rendering Implicit Objects


Deciding inside and outside is an easy task for implicit solids and surfaces, however rendering them
is not well fit to the current graphics’ API(i.e. Open GL). The pipeline of graphics’ API is based
on processing a sequence of faces in a very efficient way. For rendering implicit solids, one can
convert it to a polygonal mesh using technique such as marching cube. In this kind of methods, any
place in the space that shows a transition from inside to outside of the solid, is a base for creating
a face for the surface(or boundary of the solid). By marching the space and splicing the resulting
faces the mesh is constructed. The naive implementation of this method can be computational
expensive, and it does not also well fit with the nature of implicit representation and perhaps solid
modeling in general.
The other possibility is to use ray casting(or tracing). In fact ray-tracing, for some of implicit
primitives like spheres is very easy and the intersection test can be found analytically by solving
quadratic equation.

10.6.1 Ray-Sphere Intersection


Ray-sphere intersection is perhaps the easiest intersection test. The surface of a sphere of radius r
centered at pc is defined as all points p satisfying

kp − pc k2 = r2 . (2)

157
Equivalently, if pc = (xc , yc , zc ) we can write
(x − xc )2 + (y − yc )2 + (z − zc )2 = r2 .
This setting is depicted in Figure 10.11.
A ray can be defined as a point p0 and a direction vector d, such that any point q along the ray
satisfies q = p0 +td for some t. The particular value of t can be used to find the nearest intersection
(eg. t1 < t2 implies that object 1 is closer than object 2) and to discard invalid intersections (eg.
t < 0 implies the object is “behind” the ray).
To intersect a ray with a sphere, we can substitute the expression for a point along the ray for a
point on the surface of the sphere, and then solve for t. Let q = p0 + td be a point along the ray.
Substituting into Equation 2, we get:
kp0 + td − pc k2 = r2
ktd + Dk2 = r2
(td + D) · (td + D) = r2
2
t (d · d) + 2t(d · D) + D · D = r2
t2 + 2t(d · D) + kDk2 − r2 = 0,
where D = p0 − pc and d · d = kdk2 = 1.
We have a quadratic expression in t, the unknown, which can be solved easily via the quadratic
equation: √
−b ± b2 − 4ac
t= ,
2a
where a = 1, b = 2(d · D), and c = kDk2 − r2 . We can simplify this expression:
p
−2(d · D) ± 4(d · D)2 − 4(kDk2 − r2 )
t =
p 2
= −(d · D) ± (d · D)2 − kDk2 + r2
The quantity under the square-root, (d · D)2 − kDk2 + r2 , is known as the discriminant. If the
discriminant is negative, then the ray does not intersect the sphere. Otherwise, the sphere is inter-
sected at p0 + td for each t value; the smallest t value gives the closest intersection.

10.6.2 Ray-Tracing for other primitives


In general, the chance of having an analytic solution for ray/implicit is very low and there is only
a small subset of algebraic quadratic surfaces results in simple equations. The problem can be
expressed as following:

158
• The energy function F is known,

• the ray p0 + td is given,

• Find t such that F (p0 + td) become zero(or very close to zero).

This is root finding, a famous problem of Numerical Computation, and has several well stud-
ied techniques such as Bisection and Newton. The Newton method has much faster convergence
rate than Bisection however the function F must be at least C1 . Consequently, the blend of point
primitives is a better case for ray-tracing than union or intersection due to non-smoothness of
their energy function. One possibility is to create ray/compund_solid intersection in terms of
ray/simple_primitives intersection. Therefore, a more systematic approach for representing com-
pound solids. This is done using CSG.

10.7 Constructive Solid Geometry


A successful representation for solids is Constructive Solid Geometry(CSG). This is a systematic
approach that starts from very simple solids, primitives, and combines them by boolean operations.
It is possible to use "implicit" primitives or other types of primitives such as cube, cylinder and
torus. To represent and collect all boolean operation, a binary tree can be used as demonstrated in
the Figure10.12.
Because the Boolean operations we are interested in are also binary (i.e. they have left and
right operands), a binary tree provides a natural way to represent complex CSG objects. Consider
an object containing the primitives A, B, C1 , and C2 , which are combined to form object X =
A ∩ (B ∪ (C1 ∪ C2 )). The binary tree representing this object is shown in Figure 10.13(left).

159
U

Figure 10.12: CSG tree

In a CSG tree, the leaf nodes represent primitive objects, and the internal nodes represent
Boolean operations. The tree representation of a compound object is not necessarily unique; con-
sider Figure 10.13(right), which is equivalent to the left figure though the primitives are combined
in a different order.

10.8 Rendering CSG


Though the binary tree provides a good data structure for representing CSG objects, they’re not
much use if we can’t visualize the object represented within. A ray-tracing rendering approach is
most often used, though CSG objects require a little more work than other ray-tracing primitives.
When we intersect a ray with a solid object primitive, such as a sphere, we expect to get an
even number of intersections: each pair represents entering and exiting the object. Because solid
objects enclose a finite space, this should always be the case (though negative intersections should
be considered if the viewpoint could lie inside the solid).
So, giving a set of intersection times (also called a t-list) for object A and another set for object
B, we want to find the t-list for the Boolean combination of A and B.
If t(X) represents the t-list for an object X, then we can combine the sets in an intuitive
fashion. In general,
t(A op B) = t(A) op t(B) .
For example, t(A ∪ B) = t(A) ∪ t(B). But how do we perform operations on these t-lists?

160
U U

U A A U

U B C1 U

C1 C2 C2 B

Figure 10.13: Left: the CSG tree representing A ∩ (B ∪ (C1 ∪ C2 )). Right: an equivalent CSG tree
that combines the primitives in a different order.

t(A ∪ B) = (t1 , t6 , t3 , t8 )

Figure 10.14: The t-list for a compound object such as A ∪ B is found by performing the Boolean
operation on the t-lists of each primitive.

Consider Figure 10.14. Given two t-lists t(A) = {t1 , . . . , t4 } and t(B) = {t5 , . . . , t8 }, we can
take the union t(A ∪ B) of them by finding the set of intervals for which either t(A) or t(B) is
active. This t-list t(A ∪ B) represents the t-list for the compound object A ∪ B.
A t-list provides an easy test for whether a point p is inside of a compound object. We just need
to cast a ray through p and the object, and check whether the hit time for p belongs to an inside
interval, <todd , todd+1 >.
Using t-lists, we can render the composite object easily. We compute the t-list for the entire
tree by first computing the t-list of each leaf primitive. Then we traverse the tree in a depth-first

161
Figure 10.15: The composite t-list is computed by combining t-lists of the primitives and cascading
up the tree.

manner and pass the combined t-lists up the tree.


As an example, consider Figure 10.15. The t-lists for two cylinder primitives are shown, which
model the main part of a coffee mug (Figure 10.12). They are combined with a Boolean difference,
which subtracts the smaller cylinder from the larger one. The difference operation is applied to the
primitive’s t-lists to form the composite t-list.
Note that we can make the traversal more efficient by pruning the tree during traversal based on
the t-lists. For example, if we are computing t(A∩B) but we’ve already determined that t(A) = ∅,
then there is no need to compute t(B) because its intersection with ∅ will also be the empty set.
We can use ray-casting operations on CSG objects for many other purposes besides rendering,
such as: visibility testing and estimating area and volume. For example, by firing a set of parallel
rays from a plane through an object, we can slice out volume elements. Doing this over an entire
discretized plane, we can estimate the entire volume of an object. See Figure 10.16.

162
Figure 10.16: We can use ray-casting for purposes other than rendering. The volume of a solid can
be estimated from the t-lists of several parallel rays.

11 Procedural modeling

163

Você também pode gostar