7/31/2019 Curves&Surfaces Lec Ppt
1/95
UNIT II
CURVES & SURFACES
7/31/2019 Curves&Surfaces Lec Ppt
2/95
Contents
Bresenhams line drawing algorithm
Circle drawing algorithms
A simple technique
The mid-point circle algorithm
Curves & Surfaces
Polygon Mesh
Hermite curve
Bezier Curve
B-Spline Curve
7/31/2019 Curves&Surfaces Lec Ppt
3/95
The Bresenham Line Algorithm
Meet JACK BRESENHAM
The big advantage of this algorithm is thatit uses only integer calculations
Jack Bresenham workedfor 27 years at IBM
b e f o r e e n t e r i n g
academia. Bresenham
developed his famous
algorithms at IBM in the
e a r l y 1 9 6 0 s
7/31/2019 Curves&Surfaces Lec Ppt
4/95
The Big Idea
Move across thex axis in unit intervals and ateach step choose between two differentycoordinates
2 3 4 5
2
4
3
5 For example, fromposition (2, 3) we
have to choose
between (3, 3) and
(3, 4)
We would like the
point that is closer to
the original line
(xk
,yk
)
(xk+1,yk)
(xk+1,yk+1)
7/31/2019 Curves&Surfaces Lec Ppt
5/95
They coordinate on the mathematical line at
xk+1 is:
Deriving The Bresenham Line Algorithm
At sample positionxk+1 the
vertical separations from
the mathematical line are
labelled dupperand dlower
bxmy k )1(
y
yk
yk+1
xk+1
dlower
dupper
7/31/2019 Curves&Surfaces Lec Ppt
6/95
So, dupperand dlowerare given as follows:
and:
We can use these to make a simple decision
about which pixel is closer to the mathematical
line
Deriving The Bresenham Line Algorithm (cont)
klower yyd
kk ybxm
)1(
yyd kupper )1(
bxmy kk )1(1
7/31/2019 Curves&Surfaces Lec Ppt
7/95
This simple decision is based on the differencebetween the two pixel positions:
Lets substitute m with y/xwhere x and
y are the differences between the end-points:
Deriving The Bresenham Line Algorithm (cont)
122)1(2 byxmdd kkupperlower
)122)1(2()(
byxx
yxddx kkupperlower
)12(222 bxyyxxy kk
cyxxy kk 22
7/31/2019 Curves&Surfaces Lec Ppt
8/95
So, a decision parameterpkfor the kth stepalong a line is given by:
The sign of the decision parameterpkis thesame as that ofdlowerdupper
Ifpkis negative, then we choose the lowerpixel, otherwise we choose the upper pixel
Deriving The Bresenham Line Algorithm (cont)
cyxxy
ddxp
kk
upperlowerk
22
)(
7/31/2019 Curves&Surfaces Lec Ppt
9/95
Remember coordinate changes occur along
thex axis in unit steps so we can doeverything with integer calculations
At step k+1 the decision parameter is given as:
Subtractingpkfrom this we get:
Deriving The Bresenham Line Algorithm (cont)
cyxxyp kkk 111 22
)(2)(2 111 kkkkkk yyxxxypp
7/31/2019 Curves&Surfaces Lec Ppt
10/95
But,xk+1 is the same asxk+1 so:
whereyk+1 - ykis either 0 or 1 depending onthe sign ofpk
The first decision parameter p0 is evaluated at
(x0, y0) is given as:
Deriving The Bresenham Line Algorithm (cont)
)(22 11 kkkk yyxypp
xyp 20
7/31/2019 Curves&Surfaces Lec Ppt
11/95
The Bresenham Line Algorithm
BRESENHAMS LINE DRAWING ALGORITHM(for |m| < 1.0)
1. Input the two line end-points, storing the left end-point in (x0, y0)
2. Plot the point (x0, y0)
3. Calculate the constants x, y, 2y, and (2y - 2x) and get the firstvalue for the decision parameter as:
4. At eachxkalong the line, starting at k = 0, perform the following test. Ifpk
< 0, the next point to plot is
(xk+1, yk) and:
xyp 20
ypp kk 21
7/31/2019 Curves&Surfaces Lec Ppt
12/95
The Bresenham Line Algorithm (cont)
warning! The algorithm and derivation above
assumes slopes are less than 1. for other
slopes we need to adjust the algorithm slightly
Otherwise, the next point to plot is (xk+1, yk+1) and:
5. Repeat step 4 (x 1) times
xypp kk 221
7/31/2019 Curves&Surfaces Lec Ppt
13/95
Bresenham Example
Lets have a go at this
Lets plot the line from (20, 10) to (30, 18)
First off calculate all of the constants:
x: 10
y: 8
2y: 16
2y - 2x: -4
Calculate the initial decision parameterp0:
p0= 2yx = 6
7/31/2019 Curves&Surfaces Lec Ppt
14/95
Bresenham Example (cont)
17
16
15
14
13
12
11
10
18
292726252423222120 28 30
k pk (xk+1,yk+1)
0
1
2
3
4
56
7
8
9
7/31/2019 Curves&Surfaces Lec Ppt
15/95
Bresenham Exercise
Go through the steps of the Bresenham line
drawing algorithm for a line going from
(21,12) to (29,16)
7/31/2019 Curves&Surfaces Lec Ppt
16/95
Bresenham Exercise (cont)
17
16
15
14
13
12
11
10
18
292726252423222120 28 30
k pk (xk+1,yk+1)
0
1
2
3
4
56
7
8
7/31/2019 Curves&Surfaces Lec Ppt
17/95
Bresenham Line Algorithm Summary
The Bresenham line algorithm has the following advantages:
An fast incremental algorithm
Uses only integer calculations
Comparing this to the DDA algorithm, DDA has the followingproblems:
Accumulation of round-off errors can make the pixelated
line drift away from what was intended
The rounding operations and floating point arithmeticinvolved are time consuming
7/31/2019 Curves&Surfaces Lec Ppt
18/95
A Simple Circle Drawing Algorithm
The equation for a circle is:
where ris the radius of the circle So, we can write a simple circle drawing
algorithm by solving the equation fory at unit
x intervals using:
222ryx
22 xry
7/31/2019 Curves&Surfaces Lec Ppt
19/95
A Simple Circle Drawing Algorithm (cont)
20020 220 y
20120 221 y
20220 222 y
61920 2219 y
02020 2220 y
7/31/2019 Curves&Surfaces Lec Ppt
20/95
A Simple Circle Drawing Algorithm (cont)
However, unsurprisingly this is not a brilliantsolution!
Firstly, the resulting circle has large gaps where
the slope approaches the vertical Secondly, the calculations are not very efficient
The square (multiply) operations
The square root operation try really hard to avoid
these!
We need a more efficient, more accurate solution
7/31/2019 Curves&Surfaces Lec Ppt
21/95
Eight-Way Symmetry
The first thing we can notice to make our circledrawing algorithm more efficient is that circles
centred at (0, 0) have eight-way symmetry
(x, y)
(y, x)
(y, -x)
(x, -y)(-x, -y)
(-y, -x)
(-y, x)
(-x, y)
2
R
7/31/2019 Curves&Surfaces Lec Ppt
22/95
Mid-Point Circle Algorithm
Similarly to the case with lines, there
is an incremental algorithm for
drawing circles the mid-point circle
algorithm In the mid-point circle algorithm we
use eight-way symmetry so only ever
calculate the points for the top right
eighth of a circle, and then usesymmetry to get the rest of the
points
The mid-point circle
a l g o r i t h m w a sd e v e l o p e d b y J a c k
B r e s e n h a m .
7/31/2019 Curves&Surfaces Lec Ppt
23/95
Mid-Point Circle Algorithm (cont)
(xk+1, yk)
(xk+1, yk-1)
(xk, yk)
Assume that we havejust plotted point (xk, yk)
The next point is a
choice between (xk+1, yk)and (xk+1, yk-1)
We would like to choose
the point that is nearest tothe actual circle
So how do we make this choice?
7/31/2019 Curves&Surfaces Lec Ppt
24/95
Mid-Point Circle Algorithm (cont)
6
2 3 41
5
4
3
7/31/2019 Curves&Surfaces Lec Ppt
25/95
Mid-Point Circle Algorithm (cont)
M
6
2 3 41
5
4
3
7/31/2019 Curves&Surfaces Lec Ppt
26/95
Mid-Point Circle Algorithm (cont)
M
6
2 3 41
5
4
3
7/31/2019 Curves&Surfaces Lec Ppt
27/95
Mid-Point Circle Algorithm (cont)
Lets re-jig the equation of the circle slightly togive us:
The equation evaluates as follows:
By evaluating this function at the midpointbetween the candidate pixels we can make ourdecision
222),( ryxyxfcirc
,0
,0
,0
),( yxfcirc
boundarycircletheinsideis),(if yx
boundarycircleon theis),(if yx
boundarycircletheoutsideis),(if yx
7/31/2019 Curves&Surfaces Lec Ppt
28/95
Mid-Point Circle Algorithm (cont)
Assuming we have just plotted the pixel at(xk,yk) so we need to choose between(xk+1,yk) and (xk+1,yk-1)
Our decision variable can be defined as:
Ifpk< 0 the midpoint is inside the circle andand the pixel atykis closer to the circle
Otherwise the midpoint is outside andyk-1 is
closer
222 )2
1()1(
)2
1,1(
ryx
yxfp
kk
kkcirck
7/31/2019 Curves&Surfaces Lec Ppt
29/95
Mid-Point Circle Algorithm (cont)
To ensure things are as efficient as possible we cando all of our calculations incrementally
First consider:
or:
whereyk+1 is eitherykoryk-1 depending on the signofpk
2212111
21]1)1[(
21,1
ryx
yxfp
kk
kkcirck
1)()()1(2 122
11 kkkkkkk yyyyxpp
7/31/2019 Curves&Surfaces Lec Ppt
30/95
Mid-Point Circle Algorithm (cont)
The first decision variable is given as:
Then ifpk< 0 then the next decision variable
is given as:
Ifpk> 0 then the decision variable is:
r
rr
rfp circ
45
)
2
1(1
)2
1,1(
22
0
12 11 kkk xpp
1212 11 kkkk yxpp
7/31/2019 Curves&Surfaces Lec Ppt
31/95
The Mid-Point Circle Algorithm
1. Input radius rand circle centre (xc, yc), then set the
coordinates for the first point on the circumference of a
circle centred on the origin as:
2. Calculate the initial value of the decision parameter as:
3. Starting with k = 0 at each positionxk, perform thefollowing test. Ifpk< 0, the next point along the circle
centred on (0, 0) is (xk+1, yk) and:
),0(),( 00 ryx
rp 4
50
1211
kkk
xpp
7/31/2019 Curves&Surfaces Lec Ppt
32/95
The Mid-Point Circle Algorithm (cont)
4. Otherwise the next point along the circle is (xk+1, yk-1) and:
5. Determine symmetry points in the other seven octants
6. Move each calculated pixel position (x, y) onto the circular
path centred at (xc, yc) to plot the coordinate values:
7. Repeat steps 3 to 5 untilx >= y
111 212 kkkk yxpp
cxxx cyyy
7/31/2019 Curves&Surfaces Lec Ppt
33/95
Mid-Point Circle Algorithm Example
To see the mid-point circle algorithm in action
lets use it to draw a circle centred at (0,0) with
radius 10
7/31/2019 Curves&Surfaces Lec Ppt
34/95
Mid-Point Circle Algorithm Example (cont)
9
7
6
5
4
3
2
1
0
8
976543210 8 10
10k pk (xk+1,yk+1) 2xk+1 2yk+1
0
1
2
3
4
5
6
7/31/2019 Curves&Surfaces Lec Ppt
35/95
Mid-Point Circle Algorithm Exercise
Use the mid-point circle algorithm to draw the
circle centred at (0,0) with radius 15
7/31/2019 Curves&Surfaces Lec Ppt
36/95
Mid-Point Circle Algorithm Example (cont)
k pk (xk+1,yk+1) 2xk+1 2yk+1
0
1
2
3
4
5
6
78
9
10
11
12
9
7
6
54
3
2
1
0
8
976543210 8 10
10
131211 14
15
13
12
14
11
16
15 16
7/31/2019 Curves&Surfaces Lec Ppt
37/95
Mid-Point Circle Algorithm Summary
The key insights in the mid-point circle
algorithm are:
Eight-way symmetry can hugely reduce the work
in drawing a circle
Moving in unit steps along the x axis at each point
along the circles edge we need to choose
between two possible y coordinates
7/31/2019 Curves&Surfaces Lec Ppt
38/95
CURVES & SURFACES
7/31/2019 Curves&Surfaces Lec Ppt
39/95
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 notfeasible for computer with finite storage.
We merely approximate the object with pieces of planes, spheres or other shapes the t are easy todescribe mathematically and require that points on our model be close to corresponding points onthe 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 givean approximate description to be filled in by some program.
In CAD the computer representation is used later to generate physical realizations of the abstractlydesigned object.
7/31/2019 Curves&Surfaces Lec Ppt
40/95
Curves and Surfaces
Often we are required to represent surfaces that are notplanar in nature.
To do so the parametric representation of 2-D curves and3-D surfaces may be employed.
In general for any genus of surface or curve, there is both aparametric and an implicit representation.
In computer graphics it is often more convenient to adoptthe parametric form.
7/31/2019 Curves&Surfaces Lec Ppt
41/95
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)
7/31/2019 Curves&Surfaces Lec Ppt
42/95
Polygon mesh
A polygon mesh or unstructured grid is a collection ofvertices, edges and faces that defines the shape of apolyhedral object in 3D computer graphics and solidmodeling.
Thefaces usually consist of triangles, quadrilaterals or othersimple convex polygons, since this simplifies rendering, butmay also be composed of more general concave polygons, orpolygons with holes.
A cross section of curved object and its polygon representation
7/31/2019 Curves&Surfaces Lec Ppt
43/95
7/31/2019 Curves&Surfaces Lec Ppt
44/95
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
v2v3
v4
v1
v2v3
v4
p1 p2
p1 p2
E1
E2
E3E5
E4
7/31/2019 Curves&Surfaces Lec Ppt
45/95
Explicit Representation
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 = (r2 x2)1/2 two or zero values for x
Too dependent on coordinate system
Rarely used in computer graphics
7/31/2019 Curves&Surfaces Lec Ppt
46/95
Implicit Representation
Curve in 2D: f(x,y) = 0
Line: ax + by + c = 0
Circle: x2
+ y2
r2
= 0
Surface in 3d: f(x,y,z) = 0
Plane: ax + by + cz + d = 0
Sphere: x2 + y2 + z2 r2 = 0
7/31/2019 Curves&Surfaces Lec Ppt
47/95
Sphere definition
For example, the implicit form of a sphere is:
In general all implicit representations of a 3-d surface are ofthe form:
The parametric form of a sphere is:
x y z r2 2 2 2 0
f x y z( , , ) 0
f:( , ) (cos cos ,sin ,cos sin )
7/31/2019 Curves&Surfaces Lec Ppt
48/95
Parametric form
The general form of a 3-d surface in its parametric (orexplicit) representation is:
When rendering such curves and surfaces using polygons,the parametric representation is more convenient as thesurface is defined in terms of a parametric variable orvariables.
This allows the exact determination of the value of thesurface at regular intervals, thus allowing an approximationto the surface by taking a number of such samples.
f u v f u v f u v f u vx y z( , ) ( ( , ), ( , ), ( , ))
7/31/2019 Curves&Surfaces Lec Ppt
49/95
Example - 1
determine the representation of the functionf() = sin().
This is a parametric description of a curve in 2 dimensions
with parameter .
This is an example of an unbounded curve (in that we cantake values of from -...+. Well limit our curve to the
domain (0...2). This gives the following curve:
7/31/2019 Curves&Surfaces Lec Ppt
50/95
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 along the length of the
curve. In this example, the curve will be sampled at regular points a unit
distance apart (i.e. at = 0, 1, 2...).
This yields the following sample points which we will join by straight lineswhich is the way the curve will be finally displayed on the raster:
7/31/2019 Curves&Surfaces Lec Ppt
51/95
Representing Curves
There are many different methods of representing general
curves. The most common are:
Cubic Splines
Bezier Curves
B-splines
NURBS and -splines
7/31/2019 Curves&Surfaces Lec Ppt
52/95
Interpolation vs. Approximation
Given a set ofnpoints, to create a curve we either
interpolate the points (curve passes through all points)
approximate the points (points describe convex hullof curve)
Points on curve = knot points
Points on convex hull (off curve) = control points
Interpolate Approximate
Control points
Convex hull
knot points
7/31/2019 Curves&Surfaces Lec Ppt
53/95
Splines
To interpolate we can use a simple polynomial spline.
With n points we require a polynomial of degree n-1
(order n polynomial).
Letf(u) be the parameterised polynomial where 0 u 1
bauuf cbuauuf 2 dcubuauuf 23
Linear Quadratic Cubic
7/31/2019 Curves&Surfaces Lec Ppt
54/95
Splines
These polynomials are plots off(u) with respect to u
for each u, there is one and only onef(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 isdefined for all values ofu.
yyyy
xxxx
ducubuauy
ducubuaux
23
23
7/31/2019 Curves&Surfaces Lec Ppt
55/95
yyyy
xxxx
ducubuauyducubuaux
23
23
S li
7/31/2019 Curves&Surfaces Lec Ppt
56/95
Cup .12323
23
23
u
ddd
ccc
bbb
aaa
uuuuzuyux
ducubuauz
ducubuauy
ducubuaux
zyx
zyx
zyx
zyx
zzzz
yyyy
xxxx
Splines
For a 3D spline, we have 3 polynomials:
up
Defines the variation in x withdistance u along the curve
12 unknowns4 3D points required
S li
7/31/2019 Curves&Surfaces Lec Ppt
57/95
If we have more than 4 points werequire a polynomial of higher degree
higher degree polynomials are more
difficult to control
they exhibit unwanted wiggles
(oscillations)
Quadratic Cubic Quartic Quintic
Splines
7/31/2019 Curves&Surfaces Lec Ppt
58/95
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
7/31/2019 Curves&Surfaces Lec Ppt
59/95
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 apiecewise cubic polynomial
for n points, we have n1/3 individual cubic segments
without further constraints these will not join smoothly
smoothnon-smooth
7/31/2019 Curves&Surfaces Lec Ppt
60/95
Curve Continuity Piecewise Curve Segments
To ensure a smooth connection between curve segments we enforcefurther continuityconstraints
2 types of continuity:
parametric continuity, denoted Cn where n = degree of continuity
geometric continuity, denoted Gn
Given a curve such that at pointp, 2 segments ci(u) and ci+1(u) meetthen:
0
1
1
u
n
in
u
n
in
n
du
ucd
du
ucdC
01 1 ii ccp
0
1
1
u
n
in
u
n
in
n
du
ucd
du
ucdG
differentials are equal differentials are proportional
G t i ti it
7/31/2019 Curves&Surfaces Lec Ppt
61/95
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 G0 continuity
If the direction of two segments tangent vectors are equal at the
joint point the curve has G1 continuity
In CAD G1 is often required
Mathematically.
2
2
1
2
2
2
11
0
1
Gdu
Qd
du
Pd
Gdu
dQ
du
dP
GQP
n
n
n
Parametric Continuity
7/31/2019 Curves&Surfaces Lec Ppt
62/95
Parametric Continuity 0th order
Here curve simply meets
1st order
If the tangent vectors of two curves segment are equal (indirection as well as in magnitude) at the joint point
2nd
order If both the first and second parametric derivatives of the
two curve section are same at the their intersection
Nth order
If the nthe derivative are equal at the joint point.
7/31/2019 Curves&Surfaces Lec Ppt
63/95
since we want these curves to fit together
reasonably ...
Zero order parametric continuity
First order parametric continuity
Second order parametric continuity
7/31/2019 Curves&Surfaces Lec Ppt
64/95
Examples of Continuity
c0
c1
c2
7/31/2019 Curves&Surfaces Lec Ppt
65/95
Cubic Parametric Curves
A curve segment p(u) is defined by constraints on end-points, tangent vectors, and continuity between curvesegments.
Each cubic polynomial has 4 co-efficients, so fourconstraints will be needed.
Remember:
This allows us to formulate 4 equations in the 4unknowns, and then solve for the unknowns.
Cup .12323
23
23
u
ddd
ccc
bbb
aaa
uuuuzuyux
ducubuauz
ducubuauy
ducubuaux
zyx
zyx
zyx
zyx
zzzz
yyyy
xxxx
7/31/2019 Curves&Surfaces Lec Ppt
66/95
Geometry Matrix
To see how the co-efficients can depend on 4 constraints, recall that aparametric cubic curve is defined by
Rewrite the co-efficient matrix as where M is a 4x4 basis matrix,
G is a 4-element matrix ofgeometric contraints, called the geometry matrix.
The geometric contraints are just the conditions, such as endpoints, ortangent vectors, that define the curve.
Gxrefers to the column vector of just the x components; Gyand Gz aresimilarly defined
G or M, or both G and M, differ for each type of curve.
Cu )p(uM.GC
7/31/2019 Curves&Surfaces Lec Ppt
67/95
Geometry Matrix
The elements ofG and M are constants so the product
G.M.u is just three cubic polynomials in u.
Expanding:
4
3
2
1
44434241
34333231
24232221
14131211
231
G
G
G
G
mmmm
mmmm
mmmm
mmmm
uuuuzuyuxup
zyx
zyx
zyx
zyx
ggg
ggg
ggg
ggg
mmmm
mmmm
mmmm
mmmm
uuu
444
333
222
111
44434241
34333231
24232221
14131211
231
7/31/2019 Curves&Surfaces Lec Ppt
68/95
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 justx(u) gives:
x
x
x
x
gmummumu
gmummumu
gmummumu
gmummumuux
4443424
2
14
3
3433323
2
13
3
24232222
123
1413121
2
11
3
)(
)(
)(
)()(
Blending functions
Blending Functions
7/31/2019 Curves&Surfaces Lec Ppt
69/95
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 whichonly two geometric constraints (i.e. the endpoints of the
line) are needed.
So each curve segment is a straight line defined by theendpoints G1 and G2 :
Mu
Linear Interpolation (straight line)
7/31/2019 Curves&Surfaces Lec Ppt
70/95
Linear Interpolation (straight line)
We can represent its equation in three ways
1. As weight average of control pointsX (u)=(1-u) g1x+ u g2x
2. As polynomial in t
X (u)=(g2x-g1x) u + g1x
3. As matrix form
G1
G2
101
11]gg[)( 1x2x
uux
B0(t) p0 +B1(t)p1 Blending function
When t=0 p0 , t=1p1 , t=.5midpoint
Curve is based at p0 & a vector(p1-p0)is added
which is scaled by t
Geometry Matrix, Geometry Basis, Polynomial
Basis
7/31/2019 Curves&Surfaces Lec Ppt
71/95
The key to defining a parametric cubic curvetherefore 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
7/31/2019 Curves&Surfaces Lec Ppt
72/95
Hermite Curves
The Hermite form of a cubic polynomial curve
segment is determined by constraints on the
endpoints P1 and P4, and tangent vectors atthe endpoints R1 and R4.
NOTE: LATER P2, P3 WILL BE USED INSTEAD OF TANGENT VECTORS TO DEFINE THE CURVE
7/31/2019 Curves&Surfaces Lec Ppt
73/95
Hermite Curves - Examples
P1P4
R1
R4
Only the direction of R1 varies
Only the magnitude of R1 varies
7/31/2019 Curves&Surfaces Lec Ppt
74/95
Hermite Geometry Vector
The Hermite Geometry vector GH is
GHxis thexcomponent of GH so:
4
1
4
1
R
R
P
P
GH
x
x
x
x
Hx
R
R
P
P
G
4
1
4
1
7/31/2019 Curves&Surfaces Lec Ppt
75/95
Hermite Curves
The Hermite basis matrix, MH, relates the Hermite Geometryvector GH to the polynomial co-efficients.
Therefore:
where
HxHxxxx GMTdtctbtatx 23
)(
123
tttT
7/31/2019 Curves&Surfaces Lec Ppt
76/95
Hermite Curves
The constraints on x(0) and x(1) are found by directsubstitution into the previous equation:
xHxH
xHxH
PGMx
PGMx
4
1
1111)1(
1000)0(
7/31/2019 Curves&Surfaces Lec Ppt
77/95
Hermite Curves
The tangent vector constraints on x(0) and x(1) are foundby differentiation, i.e:
So:
and
HxH GMtttx 0123)('2
HxHx GMRx 0100)0(' 1
HxHx GMRx 0123)1(' 4
7/31/2019 Curves&Surfaces Lec Ppt
78/95
Hermite Curves The four constraints can be written in matrix form as:
The only way that this equation can be satisfied is if MH is
the inverse of the given 4x4 matrix, so:
HxHHx
x
x
x
x
GMG
R
R
P
P
0123
0100
1111
1000
4
1
4
1
0001
01001233
1122
0123
01001111
10001
HM
Matrix Inverse
7/31/2019 Curves&Surfaces Lec Ppt
79/95
Matrix Inverse
H i Bl di F i
7/31/2019 Curves&Surfaces Lec Ppt
80/95
Hermite Blending Functions We know that:
The Hermite blending functions BH are given by , since these
weight the geometry vector GH.
Therefore:
HH GMTtp )(
HMT
HHHH GBGMTtp .)(
4
23
1
23
423
1
23
)(
)2(
32
132
Rtt
Rttt
Ptt
Ptt
7/31/2019 Curves&Surfaces Lec Ppt
81/95
Hermite Curves - Blending Fuctions
P1 P4
R1
R4
t
f(t)
1
1
Labels show
which geometry
element isweighted.
T H i j i d 4
7/31/2019 Curves&Surfaces Lec Ppt
82/95
Two Hermite curves joined at p4
p1
p4p7
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
G1 continuity
7/31/2019 Curves&Surfaces Lec Ppt
83/95
Bzier Curves
The drawback of the Hermite form is the need to explicitly specify the
tangent vectors.
The Bzier form of the cubic polynomial curve segment indirectly specifiesthe endpoint tangent vector.
Such curves are constrained by their endpoints: P1 and P4, and also byintermediate points that are not on the curve: P2 and P3.
The starting and ending tangent vectors are determined by the vectorsP1P2 and P3P4 and are related to the Hermite R1 and R4 by:
)(3)1('
)(3)0('
344
121
PPpR
PPpR
7/31/2019 Curves&Surfaces Lec Ppt
84/95
Examples of some Bzier Curves
B i C
7/31/2019 Curves&Surfaces Lec Ppt
85/95
Bzier Curves
The reason for using the constant 3 is apparent from the following:
Consider the Bezier curve defined by the 4 equally spaced points:(0,0), (0,1), (0,2), (0,3).
It's obvious that this curve has the definition:
Therefore:
Now we can see that if velocity is to be constant everywhere onthe line:
)()( 141 PPtPtp
14)(' PPtp
)(3)0(' 12141 PPPPpR
)(3)1(' 34144 PPPPpR
P1 P2 P3 P4
7/31/2019 Curves&Surfaces Lec Ppt
86/95
Bzier Geometry Vector and Change of Basis
The Bzier geometry vector is:
A change of basis matrix MHB defines the relationship
between the Hermite geometry vector GH and the Bzier
geometry vector GB as follows:
4
3
2
1
P
P
P
P
GB
BHBH GM
P
PP
P
R
RP
P
G
4
3
2
1
4
1
4
1
3300
00331000
0001
)(3)0(' 12141 PPPPpR
)(3)1('34144
PPPPpR
Bzier Basis Matrix
7/31/2019 Curves&Surfaces Lec Ppt
87/95
Bzier Basis Matrix
To find the Bezier basis matrix, MB, consider:
Therefore, we simply calculate:
BB
BHBH
BHBH
HH
GMT
GMMT
GMMT
GMTtp
)(
)(
0001
0033
0363
1331
HBHB MMM
B t i P l i l
7/31/2019 Curves&Surfaces Lec Ppt
88/95
Bernstein Polynomials
We now have:
The four weights are known as the Bernstein Polynomials
BB GMTtp )(
4
3
32
2
2
1
3
)1(3
)1(3
)1(
Pt
Ptt
Ptt
Pt
7/31/2019 Curves&Surfaces Lec Ppt
89/95
Bernstein Polynomials
P1
P2 P3
P4
Labels show
which geometry
element is
weighted.
G l B t i F f B i C
7/31/2019 Curves&Surfaces Lec Ppt
90/95
General Bernstein Form for Bzier Curves
The Bezier curve p(t) based on the (L+1) points P0,P1,,PL isgiven by:
where are the Bernstein polynomials, and the k-
th Bernstein polynomial is defined as:
and
)()p( 0 tBPt
L
kk
L
k
)(tBL
k
kkLL
k ttk
LtB
)1()( kL
kLk
L
k
L
for
)!(!
!
J i i S t
7/31/2019 Curves&Surfaces Lec Ppt
91/95
Joining Segments
Consider the following two Bezier curve segments, joinedat P4:
P1
P2
P3
P4
P5P
6
P7
Points P3, P4 and P5 are collinear
Curve Continuity
7/31/2019 Curves&Surfaces Lec Ppt
92/95
Curve Continuity
G1 continuity is provided at the endpoint when
i.e. the 3 points P3, P4 and P5 must be distinct and collinear.
In the more restrictive case when k=1, there is C1 continuity in
adition to G1 continuity.
0),( 5443 kPPkPP
Convex Hull Property
7/31/2019 Curves&Surfaces Lec Ppt
93/95
Convex Hull Property
The Bernstein blending polynomials are everywhere non-
negative.
In addition, their sum is everywhere unity (i.e. 1).
Thus, each curve segment, which is just the sum of four control
points weighted by the polynomials, is completely containedwithin the convex hull of the four control points.
Convex Hull
C H ll P t
7/31/2019 Curves&Surfaces Lec Ppt
94/95
Convex Hull Property
The convex hull for 2D curves is the convex polygonformed by the 4 control points (e.g. like a rubber bandaround them)
For 3D curves, the convex hull is the convex polyhedron
formed by the control points (e.g. like cling-filmstretched around them.)
The convex hull property holds for all cubics defined byweighted sums of control points if the blendingfunctions are nonnegative and sum to one.
7/31/2019 Curves&Surfaces Lec Ppt
95/95
Convex Hull Property
One advantageous result of the fact that the blending
polynomials sum to 1, is that the value of the fourth
polynomial can be found by subtracting the first three
from 1. The convex hull property is useful for clipping and
collision detection, where we can perform tests on the
convex hull of a curve before having to perform
expensive intersection tests.