You are on page 1of 47

UNIT II

CURVES & SURFACES



The need to represent curves and surfaces arises in two cases:

In modeling existing objects (a car , a face, a mountain)

In modeling from scratch where no preexisting physical object is being represented

In first case mathematical object may be unavailable.

One can use as a model the coordinates of the infinitely many points of the object but this not
feasible for computer with finite storage.

We merely approximate the object with pieces of planes, spheres or other shapes the t are
easy to describe mathematically and require that points on our model be close to
corresponding points on the object.
In second case, the user creates the object in the modeling process.

To create the object the user may sculpt the object interactively, describe it mathematically
of give an approximate description to be filled in by some program.

In CAD the computer representation is used later to generate physical realizations of the
abstractly designed object.
Curves and Surfaces
Often we are required to represent surfaces that are
not planar in nature.

To do so the parametric representation of 2-D curves
and 3-D surfaces may be employed.

In general for any genus of surface or curve, there is
both a parametric and an implicit representation.

In computer graphics it is often more convenient to
adopt the parametric form.
Three most common representations for 3D surfaces are
polygon mesh surfaces
parametric surfaces
quadric surfaces
How do we draw surfaces?
Approximate with polygons
Draw polygons
How do we specify a surface?
Explicit, implicit, parametric
How do we approximate a surface?
Interpolation (use only points)
Hermite (use points and tangents)
Bezier (use points, and more points for tangents)
Polygon mesh
A polygon mesh or unstructured grid is a collection of
vertices, edges and faces that defines the shape of a
polyhedral object in 3D computer graphics and solid
modeling.

The faces usually consist of triangles, quadrilaterals or
other simple convex polygons, since this simplifies
rendering, but may also be composed of more general
concave polygons, or polygons with holes.
A cross section of curved object and its polygon representation

polygon mesh representation
Pointers to a vertex list
V=(v1,v2,v3,v4)={(x1,y1,z1)(x4,y4,z4)}
P1={1,2,4}
P2={4,2,3}
Each vertex stored just once, considerable space is saved
It is still difficult to find polygons that share an edge
Shared edge are drawn twice

Pointers to an edge list
V=(v1,v2,v3,v4)={(x1,y1,z1)(x4,y4,z4)}
E1={v1,v2,p1,*}
E2={v2,v3,p2,*}
E3={v3,v4,p2,*}
E4={v4,v2,p1,p2}
E5={v4,v1,p1,*}
P1={E1,E4,E5}
P2={E2,E3,E4}
E=(v1,v2,p1,p2,pn)

Avoid
redundant clipping
Transformation
Scan conversion
If Edge is shared by
n no. of polygon
Explicit representation

P={(x1,y1,z1),(x2,y2,z2),(x3,y3,z3),..(xn,yn,zn)}
v1
v2
v3
v4
v1
v2
v3
v4
p1
p2
p1
p2
E1
E2
E3
E5
E4
Explicit Representation

P={(x1,y1,z1),(x2,y2,z2),(x3,y3,z3),..(xn,yn,zn)}

Curve in 2D: y = f(x)
Curve in 3D: y = f(x), z = g(x)
Surface in 3D: z = f(x,y)
Problems:
How about a vertical line x = c as y = f(x)?
Circle y = (r
2
x
2
)
1/2
two or zero values for x
Too dependent on coordinate system
Rarely used in computer graphics

For single polygon: space efficient
For polygon mesh: much space is lost
because of duplicity of vertices and edges
One can not find all polygons that share
the vertex and all its incident edges
interactively
Implicit Representation
Curve in 2D: f(x,y) = 0
Line: ax + by + c = 0
Circle: x
2
+ y
2
r
2
= 0

Surface in 3d: f(x,y,z) = 0
Plane: ax + by + cz + d = 0
Sphere: x
2
+ y
2
+ z
2
r
2
= 0


Sphere definition
For example, the implicit form of a sphere is:


In general all implicit representations of a 3-d surface
are of the form:


The parametric form of a sphere is:

x y z r
2 2 2 2
0 + + =
f x y z ( , , ) = 0
f :( , ) (cos cos ,sin , cos sin ) u o u o u u o
Parametric form
The general form of a 3-d surface in its parametric (or
explicit) representation is:


When rendering such curves and surfaces using
polygons, the parametric representation is more
convenient as the surface is defined in terms of a
parametric variable or variables.

This allows the exact determination of the value of the
surface at regular intervals, thus allowing an
approximation to the surface by taking a number of
such samples.
f u v f u v f u v f u v
x y z
( , ) ( ( , ), ( , ), ( , )) =
Example - 1
determine the representation of the function f(u) =
sin(u).
This is a parametric description of a curve in 2
dimensions with parameter u.
This is an example of an unbounded curve (in that we
can take values of u from -...+. Well limit our
curve to the domain (0...2t). This gives the following
curve:


Now we must determine how fine or coarse a representation we need
to use in order to faithfully capture this curve.
We will sample the curve at regular intervals of u along the length of
the curve. In this example, the curve will be sampled at regular points
a unit distance apart (i.e. at u = 0, 1, 2...).
This yields the following sample points which we will join by straight
lines which is the way the curve will be finally displayed on the raster:
Representing Curves
There are many different methods of representing general
curves. The most common are:

Cubic Splines
Bezier Curves
B-splines
NURBS and |-splines

Interpolation vs. Approximation
Given a set of n points, to create a curve we either
interpolate the points (curve passes through all points)
approximate the points (points describe convex hull of
curve)
Points on curve = knot points
Points on convex hull (off curve) = control points
Interpolate
Approximate
Control points
Convex hull
knot points
Splines
To interpolate we can use a simple polynomial spline.
With n points we require a polynomial of degree n-1
(order n polynomial).
Let f(u) be the parameterised polynomial where 0 s u
s 1

( ) b au u f + =
( ) c bu au u f + + =
2
( ) d cu bu au u f + + + =
2 3
Linear Quadratic Cubic
Splines
These polynomials are plots of f(u) with respect to u
for each u, there is one and only one f(u)
curve cannot turn back on itself

Use polynomials for each axis (in 2D we have 2
polys):



As before we limit u to [0,1], although the polynomial
is defined for all values of u.



( )
( )
y y y y
x x x x
d u c u b u a u y
d u c u b u a u x
+ + + =
+ + + =
2 3
2 3
( )
( )
y y y y
x x x x
d u c u b u a u y
d u c u b u a u x
+ + + =
+ + + =
2 3
2 3
( )
( )
( )
( ) ( ) ( ) | | | | ( ) C u p . 1
2 3
2 3
2 3
2 3
=

+ + + =
+ + + =
+ + + =
u
d d d
c c c
b b b
a a a
u u u u z u y u x
d u c u b u a u z
d u c u b u a u y
d u c u b u a u x
z y x
z y x
z y x
z y x
z z z z
y y y y
x x x x
Splines
For a 3D spline, we have 3 polynomials:
( ) u p
Defines the variation in x with
distance u along the curve
12 unknowns
4 3D points required
If we have more than 4 points we
require a polynomial of higher
degree
higher degree polynomials are more
difficult to control
they exhibit unwanted wiggles
(oscillations)








Quadratic Cubic Quartic Quintic
Splines
In general we use cubic polynomials for curves in
CG:
minimal ups & downs and faster to compute than
high degree polynomials
lowest degree which allows non-planar curves
(quadratics require 3 points, 3 points always lie in
the same plane)
Splines
Defining the Cubic Spline
Normally we supply 4 points we wish the spline to pass through. These
are
2 endpoints
2 derivatives of the end points

If we have more than 4 points we must employ more than 1 spline
use a piecewise cubic polynomial
for n points, we have (n1)/3 individual cubic segments
without further constraints these will not join smoothly
smooth non-smooth
Curve Continuity Piecewise Curve Segments
To ensure a smooth connection between curve segments we
enforce further continuity constraints
2 types of continuity:
parametric continuity, denoted C
n
where n = degree of
continuity
geometric continuity, denoted G
n
Given a curve such that at point p, 2 segments c
i
(u) and c
i+1
(u)
meet then:
( ) ( )
0
1
1 =
+
=
=
u
n
i
n
u
n
i
n
n
du
u c d
du
u c d
C
( ) ( ) 0 1
1 +
= =
i i
c c p
( ) ( )
0
1
1 =
+
=

u
n
i
n
u
n
i
n
n
du
u c d
du
u c d
G o
differentials are equal differentials are proportional
Geometric continuity
In this case we require only parametric derivative of two curves
to be proportional to each other at their intersection point
If two curve segments joint together there curve has G
0

continuity
If the direction of two segments tangent vectors are equal at
the joint point the curve has G
1
continuity
In CAD G
1
is often required
Mathematically.
2
2
1
2
2
2
1
1
0
1
G
du
Q d
du
P d
G
du
dQ
du
dP
G Q P
n
n
n
=>
=>
=> =
Parametric Continuity
0
th
order
Here curve simply meets
1
st
order
If the tangent vectors of two curves segment are
equal (in direction as well as in magnitude) at the joint
point
2
nd
order
If both the first and second parametric derivatives of
the two curve section are same at the their
intersection
N
th
order
If the nthe derivative are equal at the joint point.
since we want these curves to fit
together reasonably ...

Zero order parametric continuity
First order parametric continuity
Second order parametric continuity
Examples of Continuity
c
0
c
1
c
2
Cubic Parametric Curves
A curve segment p(u) is defined by constraints on
end-points, tangent vectors, and continuity between
curve segments.
Each cubic polynomial has 4 co-efficients, so four
constraints will be needed.
Remember:




This allows us to formulate 4 equations in the 4
unknowns, and then solve for the unknowns.

( )
( )
( )
( ) ( ) ( ) | | | | ( ) C u p . 1
2 3
2 3
2 3
2 3
=

+ + + =
+ + + =
+ + + =
u
d d d
c c c
b b b
a a a
u u u u z u y u x
d u c u b u a u z
d u c u b u a u y
d u c u b u a u x
z y x
z y x
z y x
z y x
z z z z
y y y y
x x x x
Geometry Matrix
To see how the co-efficients can depend on 4 constraints, recall that
a parametric cubic curve is defined by

Rewrite the co-efficient matrix as where
M is a 4x4 basis matrix,
G is a 4-element matrix of geometric contraints, called the geometry
matrix.

The geometric contraints are just the conditions, such as endpoints,
or tangent vectors, that define the curve.
Gx refers to the column vector of just the x components; Gy and
Gz are similarly defined
G or M, or both G and M, differ for each type of curve.
C u = ) p(u
M.G C=
Geometry Matrix
The elements of G and M are constants so the
product G.M.u is just three cubic polynomials in u.
Expanding:







( ) ( ) ( ) ( ) | | | |

= =
4
3
2
1
44 43 42 41
34 33 32 31
24 23 22 21
14 13 12 11
2 3
1
G
G
G
G
m m m m
m m m m
m m m m
m m m m
u u u u z u y u x u p
| |

=
z y x
z y x
z y x
z y x
g g g
g g g
g g g
g g g
m m m m
m m m m
m m m m
m m m m
u u u
4 4 4
3 3 3
2 2 2
1 1 1
44 43 42 41
34 33 32 31
24 23 22 21
14 13 12 11
2 3
1
Blending Functions
We can read this equation in the following way:
The point p(u) is a weighted sum of the columns
of the geometry matrix G, each of which
represents a point or a vector in 3-space
Multiplying out just x(u) gives:


x
x
x
x
g m um m u m u
g m um m u m u
g m um m u m u
g m um m u m u u x
4 44 34 24
2
14
3
3 43 33 23
2
13
3
2 42 32 22
2
12
3
1 41 31 21
2
11
3
) (
) (
) (
) ( ) (
+ + +
+ + + +
+ + + +
+ + + + =
Blending functions
Blending Functions
This emphasizes that the curve is a weighted sum of
the elements of the geometry matrix.

The weights are each cubic polynomials of the
parameter u, and are called the blending functions.

The blending functions B are given by

This is similar to piecewise linear approximation, for
which only two geometric constraints (i.e. the
endpoints of the line) are needed.

So each curve segment is a straight line defined by the
endpoints G1 and G2 :
M u
Linear Interpolation (straight line)



We can represent its equation in three ways
1. As weight average of control points
X (u)=(1-u) g
1x
+ u g
2x

2. As polynomial in t
X (u)=(g
2x-
g
1x
) u + g
1x

3. As matrix form




G1
G
2

=
1 0 1
1 1
] g g [ ) (
1x 2x
u
u x
B
0
(t) p
0
+B
1
(t)p
1
Blending function
When t=0 p
0
, t=1p
1
, t=.5 midpoint
Curve is based at p0 & a vector(p
1
-p
0
)is
added which is scaled by t
Geometry Matrix, Geometry Basis,
Polynomial Basis
The key to defining a parametric cubic curve
therefore lies in the basis matrix M.

Depending on the nature of this matrix, specific
forms of curves may be created.

HERMITE CURVE
BEZIER CURVE
UNIFORM NONRATIONAL B-SPLINE
NONUNIFORM, NONRATIONAL B-SPLINE
OTHER SPLINE FORMS
Hermite Curves

The Hermite form of a cubic polynomial
curve segment is determined by
constraints on the endpoints P
1
and P
4
,
and tangent vectors at the endpoints R
1

and R
4
.

NOTE: LATER P2, P3 WILL BE USED INSTEAD OF TANGENT VECTORS TO DEFINE THE CURVE
Hermite Curves - Examples
P
1
P
4
R
1
R
4
Only the direction of R
1
varies
Only the magnitude of R
1
varies
Hermite Geometry Vector
The Hermite Geometry vector G
H
is





G
Hx
is the x component of G
H
so:

=
4
1
4
1
R
R
P
P
G
H

=
x
x
x
x
Hx
R
R
P
P
G
4
1
4
1
Hermite Curves
The Hermite basis matrix, M
H
, relates the Hermite
Geometry vector G
H
to the polynomial co-efficients.

Therefore:



where


Hx H x x x x
G M T d t c t b t a t x = + + + =
2 3
) (
| | 1
2 3
t t t T =
Hermite Curves
The constraints on x(0) and x(1) are found by direct
substitution into the previous equation:

| |
| |
x Hx H
x Hx H
P G M x
P G M x
4
1
1 1 1 1 ) 1 (
1 0 0 0 ) 0 (
= =
= =
Hermite Curves
The tangent vector constraints on x(0) and x(1) are
found by differentiation, i.e:




So:


and
| |
Hx H
G M t t t x = 0 1 2 3 ) ( '
2
| |
Hx H x
G M R x = = 0 1 0 0 ) 0 ( '
1
| |
Hx H x
G M R x = = 0 1 2 3 ) 1 ( '
4
Hermite Curves
The four constraints can be written in matrix form as:




The only way that this equation can be satisfied is if
M
H
is the inverse of the given 4x4 matrix, so:




Hx H Hx
x
x
x
x
G M G
R
R
P
P

= =

0 1 2 3
0 1 0 0
1 1 1 1
1 0 0 0
4
1
4
1

0 0 0 1
0 1 0 0
1 2 3 3
1 1 2 2
0 1 2 3
0 1 0 0
1 1 1 1
1 0 0 0
1
H
M
Matrix Inverse
Hermite Blending Functions
We know that:



The Hermite blending functions B
H
are given by , since
these weight the geometry vector G
H
.
Therefore:








H H
G M T t p = ) (
H
M T
= = =
H H H H
G B G M T t p . ) (
( )
( )
4
2 3
1
2 3
4
2 3
1
2 3
) (
) 2 (
3 2
1 3 2
R t t
R t t t
P t t
P t t

+ +
+ +
+ +
Hermite Curves - Blending Fuctions
P
1
P
4
R
1
R
4
t
f(t)
1
1
Labels show
which geometry
element is
weighted.
Two Hermite curves joined at p4
p
1
p
4
p
7
Y(t)
t
0 ,
7
4
7
4
4
1
4
1
>

withk
R
kR
P
P
and
R
R
P
P
x
x
x
x
Both curves share a
common end point
with G
1
continuity
End

You might also like