You are on page 1of 30

Chapter -11

Representing curves and surfaces


• Polygon mesh is a collection of edges, vertices and polygons connected such
that each edge is shared by at most two polygons.
• An edge connects two vertices, and a polygon is a closed sequence of edges. An
edge can be shared by two adjacent polygons and a vertex is shared by at least
two edges.
• A polygon mesh can be represented in several different ways. Three polygon
mesh representations are:
– Explicit representation
– Pointers to a vertex list
– Pointers to a edge list
• Typical operations on a polygon mesh are:
– Finding all the edges incident to a vertex.
– Finding all the polygons sharing an edge or vertex.
– Finding the vertices connected by an edge.
– Finding edges of a polygon,
– Displaying the mesh, etc.
• Two basic criteria, space and time, can be used to evaluate different
representations. In general, more explicitly the relations among polygons, vertices
and edges are represented, the faster the operations are and the more the space
the representation requires.
Representing Polygon Meshes
1). Explicit Representation: Each polygon is represented by a list of vertex
coordinates. For eg. A polygon P having n vertices is represented as follows:

• There are edges between successive vertices and between the last and the first
vertex in the list.
• For a single polygon, this is space efficient, but for a polygon mesh, much space
is lost coz the coordinates of shared vertices are duplicated.
• There is no explicit representation of shared vertices and edges, so finding one
requires comparing each of the coordinate triples of one polygon with all others.
• In this representation, for drawing a mesh, we first have to check for shared
edges, coz otherwise each shared edge will be drawn twice and it might cause
problems.
2). Pointer to a vertex list: Store all vertices once into a numbered list, and
represent each polygon by its vertices. For eg. A polygon P made up of vertices
1,3, 4, 5 is represented as follows:
V=(V1,V2,V3,V4,V5,V6)= ((x1,y1,z1),(x2,y2,z2),(x3,y3,z3),(x4,y4,z4),(x5,y5,z5),(x6,y6,z6))
• Since the coordinates of each vertex are stored only once, there is a considerable
saving of space.
• Coordinates of a vertex can be changed easily in this representation as
compared to the explicit representation.
• However it is still difficult to find polygons that share an edge.
• Shared polygon edges will still be drawn twice if care is not taken.

3). Pointers to an edge list (explicit-edge): We again have a vertex list V, and
each polygon is represented as a list of edges, in which each edge can occur
only once. Each edge in the edge list points to two of the vertices in the vertex list
defining the edge, and also to one or two of the polygons to which the edge
belongs. For eg.
V=(V1,V2,V3,V4)= ((x1,y1,z1),(x2,y2,z2),(x3,y3,z3),(x4,y4,z4))
E1 = (V1,V2,P1,λ)
V2
E2 = (V2,V3,P2,λ) E
2
E3 = (V3,V4,P2,λ) E 1
E4 V3
E4 = (V4,V2,P1, P2) V 1
P1 P2
E E3
E5 = (V4,V1,P1,λ) 5
V4
P1 = (E1,E4,E5)
P2 = (E2,E3,E4)
• Consistency of Polygon-mesh Representations – at times we requires the
polygons to follow some consistency, say to
– make sure all polygons are closed.
– All edges are used at least once but not more than some maximum.
– Each vertex is referenced at least once.
– Mesh to be completely connected (any vertex can be reached from any other
vertex).
– To have no holes (there exist one boundary, a connected sequence of edges,
each of which is used by one polygon)
• Of the three representations, the explicit edge scheme is the easiest to check for
consistency, because it contains the most information.
• Plane Equations
Ax + By + Cz + D = 0
• Given points P1, P2 and P3 on the plane, plane’s normal can be computed as the
vector cross product P1P2 X P2P3. If the cross product is zero, then the three
points are collinear and do not define the plane.
• We can find the perpendicular distance d from the plane to each vertex (x,y,z) as:
d = (Ax + By + Cz + D) / (A2 + B2 + C2)1/2
• Also this distance is positive or negative, depending on which side of the plane
the point lies. If the vertex is on the plane, then d=0.

(x1, y1 )
(x3, y3)
A3
A1
A2 (x2, y2)

• Finding area of a polygon C = ½ Σ(i=1 to n) (yi + yiӨ1) (xiӨ1 - xi)


Where the operator Ө is normal addition except that nӨ1 =1.
Using the above formula, area of the triangle A3 can be calculated as:
A3 = ½ (y1+y2)(x2-x1) + ½ (y2+y3)(x3-x2) + ½ (y3+y1)(x1-x3)

-A1 -A2 A1+A2+A3


Types of Curves
1).Explicit functions:
In the Cartesian plane, an explicit equation of a planar curve is given by
y = f(x), z = g(x)
The difficulties with this approach are that:
(1) it is impossible to get multiple values of y for a single x, so curves such as
circles and ellipses must be represented by multiple curve segments.
(2) such a definition is not rotationally invariant.
(3) describing curves with vertical tangents is difficult coz a slope of infinity is
difficult to represent.
2).Implicit Equations (functional):
It is of the form
f(x, y, z) = 0
The difficulties with this approach are that:
(1) Circle can be defined as: x2+y2=1, but what about a half circle?, we’ll have to
specify additional constraints, such as x>=0.
(2) If two implicitly defined curves are joined, it is difficult to determine whether
the tangent directions agree at the join points. Tangent continuity is important for
some applications.
3).Parametric Representation:
The cubic polynomials that defines a curve segment Q(t)= [x(t) y(t) z(t)]T are of
the form

0<=t<=1
Written in matrix form, it becomes
Q(t)= [x(t) y(t) z(t)] = T⋅ C
where
The derivative of Q(t) is the parametric tangent vector of the curve. Applying
the definition to the curve’s equation, we have

Often we will want to represent a curve as a series of curves pieced together.


But if we will want these curves to fit together reasonably ...
continuity!
Continuity

Two curve segments The directions of the tangent Second-order parametric


join together: G0 vectors (not necessarily the continuity: C2 parametric
geometric continuity. magnitudes) are equal: G1 continuity.
geometric continuity.
• Cn parametric continuity
Both the directions and means that the tangent vectors
magnitudes are equal: C1 of the nth derivative are equal.
parametric continuity.
Note: For two curves to join smoothly, we require only that their tangent-vector
directions match; we do not require that their magnitudes match.
• For two tangent vectors TV1 and TV2 to have same direction, it is necessary that one
be a scalar multiple of the other, TV1 = k . TV2, with k>0.
• C1 continuity implies G1, but the converse is generally not true. So curves can be G1
but not necessarily C1.
• There is a special case where C1 continuity does not imply G1 continuity: when both
segments’ tangent vectors are [0,0,0] at the join point. In this case, the magnitude is
same, whereas the direction can be different.
The curves are C0, C1, and C2 continuous
(respectively) with curve S.
The continuity is defined by the tangent
vector at the join point for the two curves.

• Q1 and Q2 have equal tangent vectors and


hence both are C1 and G1 continuous at P2.
• Q1 and Q3 have tangent vectors in the same
direction, but the magnitude of TV3 is twice that
of TV1, so they are only G1 continuous at P2.
• The larger tangent vector of Q3 means that the
curve is pulled more in the tangent-vector
direction before heading towards P3.
• Each of the equations x(t), y(t) and z(t) have 4 unknown variables, so 4
constraints are needed to solve for the four unknowns.
• Hermite curves are defined by two endpoints and two tangent-endpoint vectors.
• Bezier curves are defined by two endpoints and two other points that control the
end-point tangent vector.
• Several type of splines are there that are defined by four control points.
• Q(t) = T.C, where coefficient matrix C= M.G, where M is a 4X4 basis matrix, and
G is a 4 element column vector of geometric constraints, called the geometry
vector. Geometry vector consist of the four constraints that we’ll consider.
• M or G, or both M and G differ for each type of curve.
• For each type of curve, M and G are constants:
Q(t)= T. M .G i.e.

Q(t) =
• Multiplying out only x(t) = T.M.Gx
x(t) = (t3m11 + t2m21 + t m31 + m41)g1x + (t3m12 + t2m22 + t m32 + m42)g2x +
(t3m13 + t2m23 + t m33 + m43)g3x + (t3m14 + t2m24 + t m34 + m44)g4x
The above equation emphasizes that the curve is a weighted sum of the elements of
the geometry matrix. The weights are each cubic polynomial of t, and are called
blending functions. The blending function B is given by B= T.M
Hermite curves
• Hermite curves are determined by the two endpoints P1, P4 and tangent vectors
at the endpoints R1, R4.

The vector directions influence


the curve as the curve is
drawn from one endpoint to
the other.

Each of the curves above are drawn from the same


endpoints. The only difference is in the magnitude
of vector R1. The bigger curves have a larger R1
vector while the smaller curves on the bottom have
a smaller R1 vector.
The Hermite basis matrix MH is as follows:

Expanding the product T. MH in Q(t)=T. MH. GH gives the hermite blending function BH
Q(t) = T. MH. GH = BH. GH

For two hermite cubics to share a common endpoint with G1 continuity, the geometry
vectors must have the form :

and with k>0

And for C1 continuity, k must be equal to 1


Computer Graphics

Family of Hermite curves.


y(t)

x(t)
Bezier Curves
• Uses 2 end points and two intermediate points which are not on the curve,
P1,P2,P3,P4.
• Starting and ending tangent vectors are specified indirectly as:
R1 = Q’(0) = 3(P2-P1) and R4 = Q’(1) = (P4 – P3)

Bezier geometry vector GB, consisting of four points is:

GB =
Bezier Basis matrix MB, is given as:

MB =

And the product Q(t) = T. MB . GB is


Q(t) = (1-t)3P1 + 3t(1-t)2P2 + 3t2(1-t)P3 + t3P4
• The four polynomials BB = T. MB ,which are weights in the above equation are called
the Berstein Polynomials.
• For two bezier curves segments (P1,P2,P3,P4) and (P4,P5,P6,P7) with common
endpoint (i.e. P4 is shared) and G1 continuity,
P3 – P4 = k(P4 - P5), k>0,
i.e. the three points, P3,P4 and P5 must be collinear.
• In the more restrictive case when C1 continuity is also required in addition to G1
continuity, k must be equal to 1.

• In the four berstein polynomials BB ,the sum is everywhere unity and also each
polynomial is everywhere nonnegative for 0<=t<1. Thus Q(t) is weighted average
of the four control points. This condition means that each curve segment, which is
just the sum of four control points weighted by the polynomials, is completely
contained in the convex hull of the four control points.
• knots • Control points
control points that lie on the a set of points that influence
curve the curve's shape

• Interpolating spline
curve passes through the knots • Approximating spline
control points merely influence
shape
Uniform Nonrational B-Splines (only definition)
• Natural cubic spline, is a C0,C1 and C2 continuous cubic polynomial that
interpolates the control points. This is 1 more degree of continuity than is inherent
in hermite and bezier curves. Thus, splines are inherently more smoother than
hermite and bezier curves.
• The polynomial coefficients for natural cubic splines are dependent on all n
control points; their calculation involves inverting an n+1 by n+1 matrix.
• This has two disadvantages:
– Moving any one control point effects the entire curve.
– Too much computation time is needed to invert the matrix.
• B-splines, consists of curve segments whose polynomial coefficients depend on
just a few control points. This is called local control. Thus, moving a control point
affects only a small part of the curve.
• B-splines have the same continuity as the natural splines but do not interpolate
their control points.
• Cubic B-Spline approximate a curve with m+1 control points: P0, P1,…,Pm,
where m >= 3, with a curve consisting of m-2 connected, cubic polynomial, curve
segments, Q3 to Qm.
• The curve segments Qi-1 and Qi join at knots, at the parameter value ti .
• The parameter value is called the knot value.
• Endpoints of the entire curve are also called knots. There is a total of m-1 knots.
• Each of the m-2 curve segments of a B-spline curve is defined by four of the m+1
control points. In particular, curve segment Qi is defined by points Pi-3, Pi-2, Pi-1,
and Pi.

t10
t9
t5 t6
t3 t8
t7
t4
Control points
knots

• The term uniform means that the knots are spaced at equal intervals of the
parameter t.
• The term nonrational is used to distinguish these splines from rational cubic
polynomial curves, where x(t),y(t) and z(t) are each defined as ratio of two cubic
polynomials.
• The term B stands for basis.
• B-spline geometry vector GBsi for segment Qi is

GBsi = 3<=i<=m

• Just as each curve segment is defined by four control points, each control point
influences four curve segments. Moving a control point in a given direction moves
the four curve segments it affects in the same direction, the other curve segments
are totally unaffected. This is local control property of B-splines.
• Equation of B-spline curve segment i is
Qi(t) = Ti . MBs . GBsi
• Ti is a row vector [(t - ti)3 (t - ti)2 (t - ti) 1 ]
• The B-spline basis matrix, MBs is

MBs = 1/6
Nonuniform, Nonrational B-Splines
• Nonuniform coz the parameter value between successive knot values need not be
uniform. The nonuniform knot-value sequence means that the blending functions
are no longer the same for each interval, but rather vary from curve segment to
curve segment.
• These curve segments have several advantages over uniform B-splines:
– Continuity of join points can be reduced from C2 to C1 to C0 to none. If the
continuity is reduced to none, then the curve interpolates a control point, but
without the effect of uniform B-splines, where the curve segments on either
side of the control point are straight lines.
– The starting and ending points can be interpolated exactly, without introducing
straight line segments.
– It is possible to add an additional knot and control point so that the resulting
curve can be easily reshaped, whereas this cannot be done with uniform
B-splines.
• The knot-value sequence is a non-decreasing sequence of knot values t0
through tm+4(i.e. there are four more knots than there are control points). Thus the
curve with smallest number of control points is 4 and has 8 knot values.
• The knot-value sequence has to be non-decreasing, i.e. they can be equal. When
this occurs, the parameter value is called a multiple knot and the number of
identical parameter values is called the multiplicity of the knot. For instance, in
the knot sequence (0,0,0,0,1,1,2,3), knot value 0 has multiplicity 4, knot value 1
has multiplicity 2, knot value 2 has multiplicity 1, and knot value 3 also has
multiplicity 1.
Nonuniform, Rational Cubic Polynomial Curve Segments
• One of the disadvantages of the curves discussed till now is that they cannot be
used to create common conic shapes such as circles, ellipses, parabolas, etc.
This can be done using rational cubic curves, however.

• x(t) = X(t)/W(t) y(t) = Y(t)/W(t) z(t) = Z(t)/W(t)


where each of X(t), Y(t), Z(t), and W(t) are cubic polynomial curves.

• Defining curves as rational polynomials in this manner allows for simple exact
representations of conic sections such as circles, as well as curves which are
invariant under perspective projection.
• Nonuniform, Rational B-splines are called NURBS.
• Rational curves are useful for two reasons:
– They are invariant under rotation, scaling, translation and perspective
transformations of the control points, whereas nonrational curves are only
invariant under rotation, scaling and translation.
– Can be used to create common conic shapes such as circles, ellipses,
parabolas, etc.
Subdividing Curves
• There are two ways to increase the number of control points:
– Degree elevation – the degree of splines is increased from 3 to 4 or more.
This adjustment is necessary if higher orders of continuity is required, but
otherwise this method will increase the computational time needed.
– Subdivide – we can increase the number of control points by subdividing the
curve segment into two segments. For example, a bezier curve segment with
four control points can be subdivided into two segments with total of seven
control points.

P2 H
P3
L3
R2
L4 = R1
L2
R3

P 1 = L1 P4 = R 4
• Given a bezier curve Q(t) defined by points P1, P2, P3 and P4, we want to find a
left curve defined by points L1,L2,L3,L4 and right curve defined by R1,R2,R3,R4,
such that for the left curve 0<=t<1/2 and for right curve ½<=t<1
• Every subdivision divides the line in the ration t:(1-t)
• Say if t=1/2, then H = (P2+P3)/2,
L2=(P1+P2)/2, L3=(L2+H)/2, R3=(P3+P4)/2,
R2=(H+R3)/2, L4=R1=(L3+R2)/2
Conversion Between Representations
• Given a curve represented by geometry vector G1 and basis matrix M1, we want
to find the equivalent geometry matrix G2 for basis matrix M2 such that the two
curves are identical:
T . M2 . G2 = T . M1 . G1
this can be rewritten as
M2 . G2 = M1 . G1
solving for G2, the unknown geometry matrix:
multiply both sides by M2-1 gives
=> M2-1 . M2 . G2 = M2-1 . M1 . G1
=> G2 = M2-1 . M1 . G1
=> G2 = M12 . G1 where M12 = M2-1 . M1
As an example, in converting from B-spline to bezier form,

MBs,B = MB-1 . MBs = 1/6

And the inverse conversion, MB,Bs = MBs-1 . MB =


Drawing Curves
• We can draw curves by:
– Iterative evaluation of x(t), y(t) and z(t) for incrementally based values of t, plotting lines
between successive points.
– Recursive subdivision that stops when the control points get sufficiently close to the
curve itself.
• A more efficient way to repeatedly evaluate a cubic polynomial is with forward
differences. The forward difference Δf(t) of a function f(t) is
Δf(t) = f(t + δ) – f(t), δ > 0
which can be rewritten as
f(t + δ) = f(t) – Δf(t)
Rewriting in iterative form:
fn+1 = fn + Δfn
For a third degree polynomial,
f(t) = at3 + bt2 + ct + d = T . C
So the forward difference is
Δf(t) = a(t + δ)3 + b(t + δ)2 + c(t + δ) + d – (at3 + bt2 + ct + d)
= 3at2δ + t(3aδ2 + 2bδ) + aδ3 + bδ2 + cδ -----(1)
thus Δf(t) is a second degree polynomial.
• Applying forward difference to Δf(t)
Δ2f(t) = Δ (Δf(t)) = Δf(t + δ) – Δf(t)
applying this to (1) gives
Δ2f(t) = 6aδ2t + 6aδ3 + 2bδ2
This is now a first degree equation.

• Applying forward difference to Δ2f(t)


Δ3f(t) = Δ (Δ2f(t)) = Δf2(t + δ) – Δ2f(t) = 6aδ3
Third forward difference is a constant, so further forward differences are not needed.
The above equation can be re-written as
Δ2fn+1 = Δ2fn + 6aδ3

• Now using the forward differences in an algorithm that iterates from n=0 to nδ=1
f0 = d,
Δf0 = aδ3 + bδ2 + cδ
Δ2f0 = 6aδ3 + 2bδ2
Δ3f0 = 6aδ3

You might also like