Curves and Surfaces
Shireen Elhabian and Aly A. FaragUniversity of Louisville
February 2010
“A smile is a curve that sets everything straight…”
Phyllis Diller(American comedienne and actress, born 1917)
Outline• Introduction
• Affine transformations
• Curves
– What is a curve?
– Affine invariance
– Convex Hull
– Lagrange Interpolation
– Bezier Curves
• Surfaces
Introduction
We will discuss some of the existing curves associated with theirinterpolation techniques. We will start with few of the importantproperties which we desire for curves e.g. continuity and affineinvariance. We will introduce transformations for manipulatingcurves and then proceed to discuss some of the most popularcurves used in computer graphics. But let’s first introduce thenotion of parametric curves which will be later extended todefine parametric surfaces.
Points in space
• A point, which can be defined as follows:
Line Segment
• A line segment can be defined by its ending points.
• Many ways to define the equation of a line.
• Think about it as a road, we will end up with the parametricform of the line.
x0
x1
t = 0
t = 1
x(t)=(1-t) x0+t x1
Affine Transformations
What is a transform?
Recall …
Scaling
Scaling in 2D
• Scaling a coordinate means multiplying each ofits components by a scalar
• Uniform scaling means this scalar is the samefor all components:
´ 2
Scaling in 2D
• Non-uniform scaling: different scalars percomponent:
• How can we represent this in matrix form?
X ´ 2,Y ´ 0.5
Scaling in 2D
• Scaling operation:
• Or, in matrix form:
úû
ùêë
é=ú
û
ùêë
ébyax
yx''
úû
ùêë
éúû
ùêë
é=ú
û
ùêë
éyx
ba
yx
00
''
scaling matrix
Scaling in 3D
úúúú
û
ù
êêêê
ë
é
×
úúúú
û
ù
êêêê
ë
é
=
úúúú
û
ù
êêêê
ë
é
11000000000000
1'''
zyx
ss
s
zyx
z
y
x
z x
y
Translation
Translation in 2D
y
x
tyytxx+=+=
''
tx = 2ty = 1
Translation in 3D
úúúú
û
ù
êêêê
ë
é
×
úúúú
û
ù
êêêê
ë
é
=
úúúú
û
ù
êêêê
ë
é
11000100010001
1'''
zyx
ttt
zyx
z
y
x
(x’,y’,z’)
(x,y,z) T=(tx,ty,tz)
z
x
y
Rotation
Rotation in 2D
q
(x, y)
(x’, y’)x’ = x cos(q) - y sin(q)y’ = x sin(q) + y cos(q)
úû
ùêë
éúû
ùêë
é -=ú
û
ùêë
éyx
yx
qqqq
cossinsincos
''
Or, in matrix form
Rotation in 3D• How should we specify rotations?
• In 2D, it was always counterclockwise in the xy-plane.
• In 3D, we have more choices
– xz-plane, yz-plane, an arbitrary plane.
• We could specify these in terms of the vectorperpendicular to the plane of rotation.
– z axis, y-axis, x-axis, arbitrary axis
Rotation in 3D – Euler Angles
úúúú
û
ù
êêêê
ë
é
×
úúúú
û
ù
êêêê
ë
é -
=
úúúú
û
ù
êêêê
ë
é
11000010000cossin00sincos
1'''
zyx
zyx
gggg
úúúú
û
ù
êêêê
ë
é
×
úúúú
û
ù
êêêê
ë
é
-=
úúúú
û
ù
êêêê
ë
é
110000cos0sin00100sin0cos
1'''
zyx
zyx
bb
bb
úúúú
û
ù
êêêê
ë
é
×
úúúú
û
ù
êêêê
ë
é-
=
úúúú
û
ù
êêêê
ë
é
110000cossin00sincos00001
1'''
zyx
zyx
aaaa
z x
y
z x
y
z x
y
Curves
What are they?
Example – Space Curves
The intersection is acircle (space curve)
x
y
z
1
y -½ =0x2 + y2 + z2 = 1
Parametric Curves
Parametric Curves• Some restrictions should be placed on the continuous functions defining the
curve in order not to fill the space, however there are still some parametriccurves that are space filling, e.g. the Peano curve.
In 1880 the Italian logician Giuseppe Peano (1858-1932) constructed the Peano curve, abase motif fractal which uses a line segment as base. The motif is dividing the linesegment in three parts, and making a square up and down the middle part. This leads to afilled square, so the curve is a space-filling curve.
Peano curve - 2Peano curve - 1Peano curve - 0
Affine Invariance
Proof left as homework L
Convex Hull
• Another useful property is that if a curve lies within its convex hull which canbe defined as follows:
x yx
y
Non-convex setConvex set
Given a set of pins on a pin board and a rubber band around them. How does the rubber band look when it snaps tight? We represent the convex hull as the sequence of points on the convex hull polygon, in counter-clockwise order.
Interpolation
• In numerical analysis, interpolation is a method of constructing new pointswithin the range of a discrete set of known points.
• From the engineering point of view, we often has a number of points,obtained by sampling or experimentation, and we wish to construct afunction which closely fits these points, this is called curve fitting whereinterpolation is a special case, in which the function must go exactly throughthe known points.
• Another way to define interpolation is from its linguistic meaning, inter meansbetween and pole means points or nodes, hence any method of calculating anew point between two or more known points is called interpolation.
n-degree Interpolation
Lagrange Interpolation
Joseph-Louis Lagrange, Italian-born mathematician and astronomer, who lived most of his life in Prussia and France, making significant contributions to all fields of analysis, to number theory, and to classical and celestial mechanics.
Example: Uniform Lagrange Interpolation
0 0.5 1 1.5 2 2.5 3-0.5
0
0.5
1
1.5
t
L3 k
L30 L31 L32 L33
Basis functions for uniform Lagrange interpolation of degree 3.
Uniform Lagrange interpolation of four points, control points are shown in read, the convexhull of the control points is shown in dashed-red line while the convex hull of the generatedcurve (shown in dashed-blue) is much larger than the convex hull of the control points, henceLagrange curve does not satisfy the convex hull property.
0 1 2 3 4 5-2
-1
0
1
2
3
4
x
y
x0
x1
x2
x3
Convex hull of the control points
Convex hull of the curve
t = t0 = 0
, t = t1 = 1
t = t2 = 2
t = t3 = 3
In Matlab…
Next …
• However Lagrange interpolation does not satisfy the convex hullproperty.
• Typically, we would like the curve to be more confined, i.e. thearea of the convex hull of the curve should not be much greaterthan the area of the convex hull of the control points.
• Next we will discuss some of the more popular curves and howthey may be used to interpolate points.
Bézier CurvesBézier curves are one of the most popular representations for curves.
Pierre Étienne Bézier (September 1, 1910 – November 25, 1999) was a French engineer and patentor (but not the inventor) of the Bézier curves and Bézier surfaces that are now used in most computer-aided design and computer graphics systems.
The t in the function for a linear Bézier curve can be thought of as describing how far x(t) isfrom P0 to P1. For example when t=0.25, x(t) is one quarter of the way from point P0 to P1. As tvaries from 0 to 1, x(t) describes a curved line from P0 to P1.
For quadratic Bézier curves one can construct intermediate points Q0 and Q1 such that as t varies from 0 to 1:Point Q0 varies from P0 to P1 and describes a linear Bézier curve. Point Q1 varies from P1 to P2 and describes alinear Bézier curve. Point x(t) varies from Q0 to Q1 and describes a quadratic Bézier curve.
For higher-order curves one needs correspondingly more intermediate points. For cubic curves onecan construct intermediate points Q0, Q1 & Q2 that describe linear Bézier curves, and points R0 &R1 that describe quadratic Bézier curves. For fourth-order curves one can construct intermediatepoints Q0, Q1, Q2 & Q3 that describe linear Bézier curves, points R0, R1 & R2 that describequadratic Bézier curves, and points S0 & S1 that describe cubic Bézier curves.
Bernstein Polynomials Properties
Proof left as homework L
Example• The most popular Bézier curves are Bézier curves of degree 3. Let the
control points be given as follows:
0 0.2 0.4 0.6 0.8 10
0.2
0.4
0.6
0.8
1
t
B3 k
B30 B31 B32 B33
Basis functions for Bézier curves of degree 3.
• The curve will be defined by;
0 1 2 3 4 5-2
-1
0
1
2
3
4
x
y
Convex hull of the curve
x0
x1
x2
x3
Convex hull of the control points
Bézier curve of four points and its convex hull , control points are shown in read, the convex hull of the control points is shown in dashed-red line while the convex hull of the generated curve (shown in dashed-blue) is inside the convex hull of the control points, hence Bézier curve satisfy the convex hull property.
In Matlab…
Derivatives of Bézier Curves
Homework L
Differentiate Bézier curve and prove Theorem 4
Thus we have immediate form of the derivative at the end points.These are the tangents to the curve at the end points. This will beuseful in defining curves that are piecewise continuous.
Piecewise Continuous BézierCurves
• We can construct Bézier curves of arbitrary degree, however it becomes moredifficult to control the curves since the Bézier curve is only guaranteed tointerpolate end points. Instead we can create several Bézier segments that arepiecewise continuous.
• There are different kinds of continuity which can be considered.
Recall…
Example
0 0.2 0.4 0.6 0.8 1-15
-10
-5
0
5
10
t
B3 k,1
B30,1 B31,1 B32,1 B33,1
0 0.2 0.4 0.6 0.8 1-15
-10
-5
0
5
10
t
B3 k,2
B30,2 B31,2 B32,2 B33,2
-0.5 0 0.5 1 1.5 2 2.5-1
-0.5
0
0.5
1
1.5
x
y
Piecewise Bézier curve with two pieces, control points are shown in red, the generate curve isshown in blue
In Matlab…
In Matlab…
Bézier Curves Rendering
de Casteljau's Method
00x
01x
02x
03x
04x
05x
2.0=t10x
11x
12x
13x
14x2
1x
22x
23x
20x
31x
32x
30x
40x
41x
)(50 txx =
Recursive Subdivision
Although de Casteljau's method can be numerically stable, we still do notknow how many points the Bézier curve needs to be evaluated to obtainacceptable results. Next we will discuss how Bézier curves can besubdivided until a desired level of accuracy is obtained.
00x
01x
02x
03x
04x
05x
2.00 =t
10x
11x
12x
13x
14x2
1x
22x
23x
20x
31x
32x
30x
40x
41x
)(50 txx =
)(1 txControl points of
)(2 txControl points of
Rational Bézier Curves
1)1,0(
0
0
==
wx
31)1,2(
1
1
=
=
w
x
31
)1,2(
2
2
=
-=
w
x
1)1,0(
3
3
=-=
wx
Section of a circle, drawn with a rational Bézier curve
Surfaces
Tensor Product Surfaces
Tensor Product Bézier Surfaces
• Using the normals, we can definepiece-wise continuous Bézier surfaces,where de Casteljau’s algorithm can beapplied to efficiently render thesesurfaces. (refer to the reading material)
Piecewise Continuous Bézier Surfaces
Triangular Bézier Surfaces
Instead of arranging the initial configuration of the controlpoints in a rectangular fashion as with tensor product Béziersurfaces, we can arrange the control points in a triangle (seethe following figure). If the degree of the Bézier surface is n,then there are n+1 control points on each side.
003x
300x
030x012x 021x
120x
210x
102x
201x
111x
The Bézier triangles are affine invariant, the surface interpolates the three corner control pointsand the surface lies within the convex hull of the control points.
Rational Bézier Surfaces
Subdivision SurfacesWe saw before how to subdivide a Bézier curve using de Casteljau’s method.With sufficient subdivision, the Bézier curve segments can be approximatedby lines.
If we proceed to subdivide an infinite number of times, the limit curve is theBézier curve.
However, this is not the only way to subdivide a curve, we can recursivelyintroduce new control points as a function of the given control points toproduce smoother curves, different subdivision methods apply differentsubdivision rules, i.e. how to obtain new points in terms of the points at thecurrent iteration.
In the same way that curves can be recursively subdivided, we can subdivide asurface control mesh. The tensor product Bézier surface can be modeled inthis manner, but subdivision is not limited to rectangular meshes, triangularones can also be subdivided.
Loop Subdivision
Loop’s subdivision scheme works on triangular meshes. The surface is anapproximating surface, that is it doesn’t interpolate (passes through) its controlpoints. A new vertex is added for each edge, at each subdivision step.
kx
kny
k2y
k1y
k3y
ki 1+y
Current vertex/point
kiy
i-th neighbor Neighborhood/valence of the current point
kx
kny
k2y
k1y
k3y
ki 1+y
Current vertex/point
kiy
i-th neighbor A new vertex introduced at the edge connecting to the i-thneighbor
1+kix
New vertex introduced on the edges connecting neighboring vertices
kx
kny
k2y
k1y
k3y
ki 1+y
Current vertex/point
kiy
i-th
b b
b
b
bb
bn-1
Vertex Mask
kx
kny
k2y
k1y
ki 1-y
ki 1+y
3/8
1/8
1/8
Current vertex/point
kiy
3/8
i-th neighbor A new vertex introduced at the edge connecting to the i-th neighbor
1+kix
Edge Mask
Edge mask
½½ 1/8 6/8 1/8
Vertex mask
Thank You!!!