Computer Graphics (ETCS - 210) - Curves Notes by Mr. Uttam Singh

Bezier Curve
•
In graphics and CAD, we do not usually have derivative data
•
Bezier suggested using the same 4 data points as with the cubic interpolating curve to
approximate the derivatives in the Hermite form
•
Specifying tangent vectors is difficult
•
It is easier to specify points that represent the tangent vectors
•
For Bezier curves, we specify 4 points:
•
•
The initial point on the curve: P1
•
The last point on the curve: P4
•
A point that is used to determine the tangent at the first point: P2
•
A point that is used to determine the tangent at the last point: P3
It turns out that Bezier and Hermite curves can be related as follows:
R1  Q' (0)  3( P2  P1 )
R4  Q' (1)  3( P4  P3 )
 P1 
P 
GB   2 
 P3 
 
 P4 
•
The Bezier Geometry matrix is:
•
So, relating the Hermite Geometry matrix to the Bezier Geometry matrix, gives us:
 P1   1
P   0
GH   4   
 R1   3
  
 R4   0
0  P1 
0 0 1  P2 
 M HB  GB
3 0 0  P3 
 
0  3 3  P4 
0
0
The Bezier Basis Matrix
•
•
To find the Bezier basis matrix, we have:
Q(t )  T  M H  GH ,
with
GH  M HB  GB
So,
Q(t )  T  M H  M HB  GB
and hence,
M B  M H  M HB
•
Thus,
M B  M H  M HB
 1 3  3
 3 6 3

 3 3
0

0
0
1
1
0
0

0
So,

 1 3  3
 3 6 3
t 1
 3 3
0

0
0
1
1  P1 
0  P2 
0  P3 
 
0  P4 

 1 3  3
 3 6 3
t 1
 3 3
0

0
0
1
1
0
0

0

Q(t )  T  M B  GB  t 3 t 2
•
Multiplying T and MB gives,
T  M B  t3

t2

  t 3  3t 2  3t  1 3t 3  6t 2  3t

 1  t 
3
3t 1  t 
2
3t 2 1  t  t 3
 3t 3  3t 2
t3


Q(t )  1  t  P1  3t 1  t  P2  3t 2 1  t P3  t 3 P4
3
2
•
So,
•
The four polynomials BB=T·MB are the weighting functions for the Bezier curves, and are called
the Bernstein Polynomials
•
We can fairly easily join two Bezier curves and maintain C1 continuity between them.
P1’ = P4
P2’ – P1’ = P4 – P3
•
The criteria that have to be met:
•
The convex hull of a set of points is the smallest convex region that contains all of the points in
the set
•
Example of Convex hull
•
Bezier curves lie within the convex hull of the control points
•
Useful for trivial acceptance/rejection tests
B-spline Curves
•
These curves are approximating rather than interpolating curves.
•
The curves come close to, but may not actually pass through, the control points.
•
Usually used as multiple, joined curve segments
•
B-splines have C2 continuity between curve segments

“Smoother” than other curve forms
•
For a sequence of connected B-spline curves, each curve segment is determined from four
control points.
•
Each control point contributes to 4 curve segments (except the first three and last three)
•
By convention, curve segment Qi is determined by control points Pi-3, Pi-2, Pi-1, and Pi
•
Rather than defining each curve segment on the interval 0 £ t £ 1, we make the parameter
domains sequential.
•
Curve segment Qi is defined on the parameter range
•
Between two curve segments Qi-1 and Qi there is a join point or knot at parameter value ti
•
A uniform B-spline has knots that are equally spaced in t.
•
The B-spline geometry vector is given by
GBS
ti £ t £ ti+1
 Pi 3 
P 
  i 2 
 Pi 1 
 
 Pi 
•
The first curve segment, Q3 is defined by the points P0 through P3 over the parameter t3 = 0 to t4
=1
•
The second curve segment, Q4 is defined by the points P1 through P4 over the parameter t4 = 1 to
t5 = 2
•
The last curve segment, Qm is defined by the points Pm-3 through Pm over the parameter tm = m-3
to tm+1 = m-2
B-spline Properties
•
Since each control point contributes to four curve segments, moving one control point alters
four curve segments, but does not alter the others.
•
Because of the way we have parameterized t, we define
•
Then the curve segment is computed as
•
The B-spline basis matrix MBs is defined as
•
B-spline curve joins maintain C2 continuity
•
B-splines are bounded by their convex hulls

Ti  (t  ti )3
(t  ti ) 2
Qi (t )  Ti  M Bs  GBs ,
M Bs
 1 3  3

1  3 6 3

3
6  3 0

4
1
1
ti  t  ti 1
1
0
0

0

(t  ti ) 1
Drawing Curves
•
Two approaches:
1. Evaluate x(t), y(t), and z(t) for incrementally spaced values of t in an iterative fashion.
•
Draw line segments between the points at each iteration
•
Can optimize using Horner’s method or forward differences
2. Recursively subdivide the curve until the new control points get sufficiently close to the
curve
•
Can generate a large number of curve segments
Advantages of B-spline curves
•
B-spline curves require more information (i.e., the degree of the curve and a knot vector) and a
more complex theory than Bézier curves.
•
But, it has more advantages to offset this shortcoming.

a B-spline curve can be a Bézier curve.

B-spline curves satisfy all important properties that Bézier curves have.

B-spline curves provide more control flexibility than Bézier curves can do.
Properties of B-spline curves
•
The degree of a B-spline curve is separated from the number of control points, i.e., we can use
lower degree curves and still maintain a large number of control points.
•
We can change the position of a control point without globally changing the shape of the whole
curve.
•
Since B-spline curves satisfy the strong convex hull property, they have a finer shape control.
•
There are other techniques for designing and editing the shape of a curve such as changing
knots.
•
B-spline curves are still polynomial curves and polynomial curves cannot represent many useful
simple curves such as circles and ellipses.
NURBS
•
NURBS are one form of rational polynomial curves
•
Non-Uniform Rational B-Spline
•
Defined by :

its order
-
determines the number of control points that affect a region of the curve
-
The polynomial is degree one less than the order (i.e. order 4 is cubic
polynomial)

a set of weighted control points

a knot vector
-
a sequence of values that determine how the control points affect the curve
•
NURBS curves are generalizations of both B-splines and Bezier curves
•
NURBS are one form of rational polynomial curves
•
Non-Uniform Rational B-Spline
•
Defined by:
 h pb
f (u ) 
 hb
n
i 1 i
n
i i , k ,t
i 1 i i , k , t
Where
hi  scalar wei ght for each control point
pi  control points
bi ,k ,t  the B - spline curve
k  B - spline parameter
t  knot vector
•
If the weights are set to 1, the NURBS becomes a regular B-spline
•
NURBS can represent conics exactly.
Non-periodic (open) uniform B-Spline
•
The knot spacing is evenly spaced except at the ends where knot values are repeated k times.
•
E.g P(u) =  Ni,k(u)pi
•
Degree = k-1, number of control points = n + 1
•
Number of knots = m + 1 @ n+ k + 1
(u0 < u < um)
for degree = 1 and number of control points = 4 (k = 2, n = 3)
 Number of knots = n + k + 1 = 6
non periodic uniform knot vector (0,0,1,2,3, 3)
* Knot value between 0 and 3 are equally spaced  uniform
Example
•
For curve degree = 3, number of control points = 5
•
 k = 4, n = 4
•
 number of knots = n+k+1 = 9
•
 non periodic knots vector = (0,0,0,0,1,2,2,2)
•
For curve degree = 1, number of control points = 5
•
 k = 2, n = 4
•
 number of knots = n + k + 1 = 7
•
 non periodic uniform knots vector = (0, 0, 1, 2, 3, 4, 4)
•
For any value of parameters k and n, non periodic knots are determined from
0ik
0

ui  i  k  1
n  k  2

e.g
k in
ni  nk
0i2
0

ui  i  2  1
3  2  2

k=2, n = 3
2i3
3i 5
u = (0, 0, 1, 2, 3, 3)
Basis Function
N i ,k u   u  u i 
1
N i ,1  
0
N i ,k 1 u 
u i  k 1  u i
 ui  k  u 
N i 1,k 1 u 
ui  k  ui 1
u i  u  u i 1
Otherwise.
Example
•
Find the knot values of a non periodic uniform B-Spline which has degree = 2 and 3 control
points. Then, find the equation of B-Spline curve in polynomial form.
•
Degree = k-1 = 2  k=3
•
Control points = n + 1 = 3  n=2
•
Number of knot = n + k + 1 = 6
•
Knot values  u0=0, u1=0, u2=0, u3=1,u4=1,u5= 1
•
To obtain the polynomial equation,
•
=  Ni,3(u)pi
P(u) =  Ni,k(u)pi
•
= N0,3(u)p0 + N1,3(u)p1 + N2,3(u)p2
•
firstly, find the Ni,k(u) using the knot value that shown above, start from k =1 to k=3
•
For k = 1, find Ni,1(u) – use equation (1.2):
•
N0,1(u) = 1
•
0
•
N1,1(u) = 1
•
0
•
N2,1(u) = 1
•
0
•
N3,1(u) = 1
•
0
•
N4,1(u) = 1
•
0
u0 u
u1 ; (u=0)
otherwise
u1 u
u2 ; (u=0)
otherwise
u2 u
u3 ; (0 u  1)
otherwise
u3 u
u4 ; (u=1)
otherwise
u4 u
u5 ; (u=1)
otherwise
For k = 2, find Ni,2(u)
N i ,k u   u  u i 
•
•
•
N i ,k 1 u 
ui  k 1  ui
 u i  k  u 
N i 1,k 1 u 
u i  k  u i 1
N 0, 2 (u ) 
u  u0
u u
N 0,1  2
N1,1
u1  u 0
u 2  u1
N 0, 2 (u ) 
u0
0u
N 0,1 
N1,1  0
00
00
N1, 2 (u ) 
u u
u  u1
N1,1  3
N 2,1
u 2  u1
u3  u 2
(u0 =u1 =u2 = 0)
(u1 =u2 = 0, u3 = 1)
•
N1, 2 (u ) 
u0
1 u
N1,1 
N 2,1  1  u
00
1 0
Similarly,
N 2, 2 (u ) 
u  u2
u u
u0
1 u
N 2,1  4
N 3,1 
N 2,1 
N 3,1  u
u3  u 2
u 4  u3
1 0
11
N 3, 2 (u ) 
u  u3
u u
u 1
1 u
N 3,1  5
N 4,1 
N 3,1 
N 4,1  0
u 4  u3
u5  u 4
11
11
(u3 =u4 = u5 = 1)
For k = 2
N0,2(u) = 0
N1,2(u) = 1 - u
N2,2(u) = u
N3,2(u) = 0
(u2 =0, u3 =u4 = 1)