Notes 1
Notes 1
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 [email protected] 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
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
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
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
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:
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:
Example 1.2
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
Example 1.5
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.
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)
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.
Example 1.8
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:
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)!
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
8
• Q2 (0) = (1 − 0)2 P0 + 2(1 − 0)0P1 + 02 P2 = P0 = (0, 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.
Example 2.2
9
• T2 (0) = −2P0 + 2P1 = 2(P0 − 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.
• 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.
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.
11
Example 2.3
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.
12
Example 2.4
Compute Q3 ( 12 ) given the control points P0 = (4, 0), P1 = (8, 2), P2 = (0, 2), P3 = (0, 0).
• 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.
13
P2
1
P1
P1
P3
P0
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.
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?
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
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
Example 3.1
p(u) = a0 + a1 u + a2 u2 + a3 u3 (ai = 0 or ai 6= 0)
• p(u) = 1 + 5u − 2u2 + u3
• p(u) = 1 − 2u3
18
• p(u) = 0 (equivalent to p(u) = 0 + 0u − 0u2 + 0u3 )
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.
• Bernstein polynomials B0,k−1 (u), B1,k−1 (u), ..., Bk−1,k−1 (u) form another basis of Pk .
Example 3.2
{1, u, u2 , u3 } and {(1 − u)3 , 3u(1 − u)2 , 3u2 (1 − u), u3 } are two basis sets of P4 .
p(u) is represented by (1, −3, 3, −2) using the standard basis and (1, 0, 0, −1) using Bernstein
basis.
• 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.
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.
u0 u1 u2 u3 u4 u5 u6
0 1 2 3 4 5 6
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
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
First order B-splines produce box functions that are useful in representing pixel values of im-
ages.
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
0 1 2 3 4 5 6
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
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.
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.
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.
• 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.
25
So to create a curve with the B-spline basis, we must keep in mind:
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.
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.
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
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):
A(P ) = M P + v
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.
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 .
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 ).
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
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.
Figure 3.19: Different multiple knot sequences. The numbers in brackets (e.g., (1)) indicate the
multiplicity of the knot.
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
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
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
.
Example 3.6
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.
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.
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.
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.
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
[1]
Figure 3.22: Top table: computing Eδ from set of input Ei . Bottom image: one step of recurrence.
[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
40
3.10 Exercises
1. Find an example of a curve which is C 1 but not G1 .
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.
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:
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.
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).
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
• Unit summation: m
P
i=0 Ri,k (u) = 1 for all u ∈ [0, 1].
• 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.
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.
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.
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
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 =
2π
v
ty =
2π
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.
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.
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).
Example 5.4
Creating a cylinder using a ruled surface.
Q(u, v) = (1 − v)P0 (u) + vP1 (u) = (cos u, sin u, v) 0 ≤ u < 2π, 0 ≤ v < 1
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.
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 ).
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.)
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:
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:
57
+ _ =
Now, what do we want from Q(u, 0)? We should get P0 (u). Let’s check:
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.
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
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
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)
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.
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
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.
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
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
68
Figure 5.20: Bezier Surface
Example 5.6
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
71
where Bi,j,d,d0 (u, v) is a two dimensional basis function with the following definition
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
{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
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
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
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)
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.
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.
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
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.
|E| = |F | + |V | − 2.
80
Figure 6.6: Three successive vertices in a face.
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 )|
82
vi
v’i vi
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..
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.
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
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.
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.
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.
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?
Pm0
new: Q̄(u) = j=0 Fj N̄j,k (u) Fj is a fine control point.
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
Fj−1 = 12 Ci−1 + 12 Ci
Fj = 18 Ci−1 + 34 Ci + 18 Ci+1
Fj+1 = 21 Ci + 12 Ci+1
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.
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.
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:
• affine invariance
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?
(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.
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.
Figure 7.6: Different values for the subdivision filters may decrease continuity (middle) or result
in divergence (right).
These eigenvalues are exactly the same as Chaikin subdivision’s eigenvalues. Therefore, this sub-
division scheme also generates a smooth limit curve.
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 ) .
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
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.
• 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.
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.
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.
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.
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.
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.
Example 8.2
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 .
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.
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
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:
• has tangent plane continuity(G1 ) at extra-ordinary vertices (i.e., in the irregular case).
• 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
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
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.
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.
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.
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.
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.
• 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.
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.
123
These values can also be considered as coordinates of a curve. This can also be represented by an
approximating function
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.
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
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
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:
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.
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.
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.
As the video is played we use reconstruction to restore the original number of frames again
(without the details we have thrown out).
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
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
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.
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.
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 :
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.
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.
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
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).
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.
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
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
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
Example 10.3
• 5f (1, 0, 0) = (2, 0, 0)
• 5f (0, 0, 0) = (0, 0, 0)
150
If the gradient is zero, we cannot have a suitable normal.
Example 10.4
• p = (1, 0), x2 + y 2 − 1 = 0
• p = (2, 0), x2 + y 2 − 4 = 0
δ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.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
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.
• 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.
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.
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.
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.
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.
158
• The energy function F is known,
• 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.
159
U
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.
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.
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