Graphics & Visualization
Chapter 7
Parametric Curves and Surfaces
Graphics & Visualization: Principles & Algorithms Chapter 7
Parametric Curves and Surfaces Graphics & Visualization: - - PowerPoint PPT Presentation
Graphics & Visualization Chapter 7 Parametric Curves and Surfaces Graphics & Visualization: Principles & Algorithms Chapter 7 Introduction We have already presented algorithms for the rasterization
Graphics & Visualization: Principles & Algorithms Chapter 7
Graphics & Visualization: Principles & Algorithms Chapter 7
The need for mathematical representations of free-form shapes
became apparent in the automotive and aeronautic industries
Paul de Casteljau & Pierre Bézier developed independently the
theory of polynomial curves & surfaces
This theory constitutes the basic tool for describing and rendering
free-form shapes.
2
Given as 2 (for plane curves) or 3 (for space curves) independent
coordinate functions in terms of a parameter t.
( ) ( ) ( )
( ) ( ) ( ) ( ) x t x t t t y t y t z t = = X X
Graphics & Visualization: Principles & Algorithms Chapter 7
The description of plane and space curves is essentially the same,
z(t) = 0 for a plane curve
are given as 3 independent coordinate functions in terms of 2
parameters u and v:
( ) z t
( , ) ( , ) ( , ) ( , ) x u v u v y u v z u v = X
3
Between two points p0 and p1 P(t) = (1-t) p0 + t p1 , t
[0,1]
Expresses the linear interpolation between these points (p0 and p1)
Graphics & Visualization: Principles & Algorithms Chapter 7 4
Graphics & Visualization: Principles & Algorithms Chapter 7
5
1 0( )
1 1( )
1 1 1 1 1 2
1
1
Graphics & Visualization: Principles & Algorithms Chapter 7
6
1 0( )
1 1( )
2 1 1 1 2 2 1 2
1
p p
2
p
2 2 0( )
( ) t t
P
1 1( )
t p
1 0( )
t p
is a quadratic Bézier curve (or a second-degree Bézier curve)
Will be denoted by P2(t)
1 0( )
1 1( )
2 0( )
2 0( )
Graphics & Visualization: Principles & Algorithms Chapter 7
Will be denoted by P2(t)
7
r i t
Needs four control points Performs three linear interpolation steps
1
p
1
p
1 1
p
2
p
1 2
p p
2
p
2 1
p
3 3
( ) t
P
Graphics & Visualization: Principles & Algorithms Chapter 7
Need for (n+1) control points p0, p1, …, pn Perform n linear interpolation steps Control polygon of the curve: the polygon formed by p0,p1,…, pn The curve is given by:
(1)
8
p
3
p
( ) (1 ) , [0,1 ]
n n i n i i i
n t t t t i
− =
= − ∈
P p
Computes the Bézier curve points
Summarizes the linear interpolation steps in an iterative scheme
Graphics & Visualization: Principles & Algorithms Chapter 7
Summarizes the linear interpolation steps in an iterative scheme
1. For the required value of t, set 2. Perform the linear interpolation steps: 3. The point on the curve corresponding to parametric value t is
9 0( )
, 0,1,...,
i i
t i n = = p p
n n
1 1 1
r r r i i i
− − +
Casteljau algorithm can be written in a triangular arrangement
Graphics & Visualization: Principles & Algorithms Chapter 7
No need to store all intermediate points Use a one-dimensional array Initialize it with the control points of the curve Overwrite its elements from top to bottom as the algorithm progresses At the end, the point on the curve will be the first element of the array
10
point bezierPoint ( int n, point[] controlPt, float t ) { point deCasPt[n+1]; for (i=0; i <= n; i++) deCasPt[i] = controlPt[i]; for (r=1; r <= n; r++) { for (i=0; i <= n-r; i++) {
Graphics & Visualization: Principles & Algorithms Chapter 7
for (i=0; i <= n-r; i++) { deCasPt[i] = (1-t)*deCasPt[i] + t*deCasPt[i+1]; } } return deCasPt[0]; }
11
Graphics & Visualization: Principles & Algorithms Chapter 7
On the same line with coefficients ¾ On the next line with coefficient ¼
The required point is
12
( )
3 1 4
29 16 23 16 = P
n i n i i
−
( ) (1 ) , [0,1]
n n i n i i i
n t t t t i
− =
= − ∈
P p ( ) ( ) , [0,1]
n n n i i
t B t t = ∈
P p
Graphics & Visualization: Principles & Algorithms Chapter 7
13
( ) ( ) , [0,1]
i i i
t B t t
=
= ∈
P p
2 2 3 3 2 3 2 1 1 2 2 3 2 2 2
3 3 3
( ) ( )
n i n i i
f t t c B
=
=∑
n
Graphics & Visualization: Principles & Algorithms Chapter 7
14
( ) 1 , and ( ) 1 , [0,1]
n n i i n i
B t t B t t
=
= ∀ ≤ ≤ ∈
n n j n j
−
The Bézier curve always lies inside the convex hull of its control points
The Bézier curve is an affine combination of its control points Therefore, to apply an affine transformation to a Bézier curve, just transform
Graphics & Visualization: Principles & Algorithms Chapter 7
Therefore, to apply an affine transformation to a Bézier curve, just transform
its control points
The curve remains unaltered if t [0, 1] is changed to u
[a, b] where u = a + (b-a) t
The interpolation steps become
15
1 1 1
r r r i i i
− − +
If the control points are used in reverse order pn,pn-1,…,p1,p0 the shape of the
curve does not change
The curve is traversed in the opposite direction
If all control points lie on a straight line, then the curve also has the shape of
a straight line
Graphics & Visualization: Principles & Algorithms Chapter 7
A planar Bézier curve is intersected by an arbitrary straight line no more than
the number of times that the line intersects the control polygon of the curve.
A non-planar Bézier curve is intersected by an arbitrary line or plane no more
than the number of times that the line or plane intersects the control polygon
A curve with a convex control polygon is also convex but the inverse is not
always true (a convex Bézier curve may have a non-convex control polygon)
16
The curve starts at its first control point and ends at its last one
Pn (0) = p0 and Pn (1) = pn
The tangent (first derivative) of a Bézier curve is:
The tangent vector at the endpoints are parallel to the first and last edge of its
1 1 1
( ) ( )( )
n n n i i i i
d t n B t dt P p p
− − + =
= −
Graphics & Visualization: Principles & Algorithms Chapter 7
The tangent vector at the endpoints are parallel to the first and last edge of its
control polygon:
If the curve is defined over an arbitrary parametric interval u
[a, b] , then:
17
1 1
and (0) ( ) (1) ( )
n n n n
d d n n dt dt
−
= − = − P p p P p p
1 1
1 ( ) (0) ( ) 1 ( ) (1) ( )
n n n n n n
d d dt a n du dt du b a d d dt b n du dt du b a
−
= = − − = = − − P P p p P P p p
The second derivatives at the endpoints of an nth-degree Bézier curve are:
2 2 1 2 2 1 2 2
(0) ( 1)( 2 ) (1) ( 1)( 2 )
n n n n n
d n n dt d n n dt
− −
= − − + = − − + P p p p P p p p
Graphics & Visualization: Principles & Algorithms Chapter 7
If the curve is defined over an arbitrary parametric interval u
[a, b], then:
18
2 2 1 2 2 2 1 2 2 2
1 ( ) ( 1)( 2 ) ( ) 1 ( ) ( 1)( 2 ) ( )
n n n n n
d a n n du b a d b n n du b a
− −
= − − + − = − − + − P p p p P p p p
Local control: moving a control point has a localized effect on the
curve
Bézier curves do not possess local control since the Bernstein
polynomials are non-zero over the whole parametric interval [0,1] of the curve
Moving any control point affects the shape of the whole curve
Graphics & Visualization: Principles & Algorithms Chapter 7
Moving any control point affects the shape of the whole curve
Bézier curves posses pseudo-local control:
the effect of moving pi is more pronounced around the parametric value i/n, where has its only maximum
Makes it easier to predict the change of the shape of a Bézier curve
when moving its control points
19
n i
p
1
p
1
p
1 1
p
2
p
1 2
p
3
p
2
p
2 1
p
3 3
( ) t
P Graphics & Visualization: Principles & Algorithms Chapter 7
The “left” one with endpoints P3(0) = p0 and P3(t0) The “right” one with end points P3(t0) and P3(1) = p3
20
Call its control points li, i = 0, 1, 2, 3 so that
3 3
i i i
=
3 3 3
Graphics & Visualization: Principles & Algorithms Chapter 7
21
3 3 3 3
3 1 1 1 1
1 (0) (0) (0) 3( ) 3( ) (1 ) d d d dt dt dt dt dt t t t ′ = = ⇔ − = − ′ ⇔ = − + P L L p p l l l p p
1 1
2 1 2 1 2 2 2 2 1 2
Graphics & Visualization: Principles & Algorithms Chapter 7
line of the de Casteljau triangle.
22
2 2
i i
Is the part that corresponds to the interval [t0,1] of the curve Its control points ri can be computed by working similarly , so: They are the points of the “hypotenuse” of the de Casteljau triangle This result holds for Bézier curves of any degree.
( )
n i i i
t
−
= r p
Graphics & Visualization: Principles & Algorithms Chapter 7
Not only computes the points to the curve that corresponds to t0 But also provides the control points of the 2 segments into which the curve
is subdivided by this point
The implementation readily provides points ri (they are the deCasPt) To provide points li: after each column of the triangle is completed, its 0-
index element is a control point of the left segment
23
Graphics & Visualization: Principles & Algorithms Chapter 7
Subdivide recursively the curve into two segments After a number of steps the control points will be nearly collinear Then the subdivision may stop Each segment can be drawn as a line segment between its two endpoints
24
draw its flat regions quickly perform more recursive steps wherever the curve has high curvature
Prefer t0=1/2 because interpolation steps involve only divisions by 2
computing the distance of every other control points pi, i=1,2,…,n-1
Graphics & Visualization: Principles & Algorithms Chapter 7
computing the distance of every other control points pi, i=1,2,…,n-1 ensuring that every such distance is less than the required tolerance
25
n n i n
Construct the axis-aligned bounding box (AABB) of the initial curve Check the (AABB) for intersections with the line if exists an intersection subdivide the curve into its left & right segment continue recursively with the AABB of each segment
Graphics & Visualization: Principles & Algorithms Chapter 7
If the line does not intersect the AABB, it will not intersect the curve
26
The higher the degree, the less efficient is to compute it
(more linear interpolation steps, numerical accuracy problems)
The lack of local control makes it difficult to create a desirable shape with a
Graphics & Visualization: Principles & Algorithms Chapter 7
The lack of local control makes it difficult to create a desirable shape with a
single Bézier curve
27
values (C0),
( ) ( ) 1 1
r r
Graphics & Visualization: Principles & Algorithms Chapter 7
values (C0), tangents (C1) and second derivatives (C2)
28
are equal at t1
Pn(t) , t
[0,1] of degree n with control points p0, p1, …, pn
Qm(t), t
[1,2] of degree m with control points q0, q1, …, qm
n =
p q
n − = − ⇔ − = −
Graphics & Visualization: Principles & Algorithms Chapter 7
q1 must be placed at the line (pn-1pn)and its distance from pn is (1)
to define the position of q2
29
1 1 1 1
( ) ( ) ( )
n n n n n
n n m m
− −
− = − ⇔ − = − p p q q q p p p
1 2 2 1
( 1)( 2 ) ( 1)( 2 )
n n n
n n m m
− −
− − + = − − + p p p q q q
1 1 1 1
n n n n n n− −
position of one more control point.
2 1 1 2
2 2 − = − q q p p
2 1 1 2
2 2 1
1 1 2
p
1
p
3
q
2
p
1
q
2
q
3
q
p
1
p
3
q
Graphics & Visualization: Principles & Algorithms Chapter 7
Use higher-degree curves (not efficient) Require lower continuity (not satisfying results) Modify the kind of continuity required :
instead of parametric continuity (Cr) require the weaker geometric continuity (Gr)
30
2
q
1
q
2
p
3
q
2
q
1
q p
1
p
3
q
2
p d
3
q
Spline curves comprised of polynomial segments of degree k joined with
Ck-1 continuity
The degree k of the segments is also the degree of the B-spline curve Are defined by control points p0, p1, …, pn
Graphics & Visualization: Principles & Algorithms Chapter 7
Are defined by control points p0, p1, …, pn
The number (n+1) of control points is independent of the curve degree
and related to the number of the polynomial segments
The polynomial segments are defined over consecutive parametric intervals
[ti, ti+1]
Domain of the B-spline curve: the union [tmin, tmax] of the intervals
31
first min max last
Graphics & Visualization: Principles & Algorithms Chapter 7
The degree of the curve The number of its control points 32
Graphics & Visualization: Principles & Algorithms Chapter 7
33
Graphics & Visualization: Principles & Algorithms Chapter 7
(pi-2, pi-1) in the interval [ti-1, ti+1] and (pi-1, pi) in the interval [ti, ti+2]
34 1 1 1 1 2 1 1 1 1 1 1 1 1 2 1 2 2 2
( ) , [ , ] ( ) , [ , ]
i i i i i i i i i i i i i i i i i i i i i i
t t t t t t t t t t t t t t t t t t t t t t t t
+ − − − − − + + − + − + − + + +
− − = + ∈ − − − − = + ∈ − − q p p q p p
2 1 1 1 1 1 1 1
( ) ( ) ( ) ( ), [ , ]
i i i i i i i i i i i i
t t t t t t t t t t t t t t t
+ − + + +
− − = = + ∈ − − Q q q q
1 1( ) i
−
1( ) i t
1 1( ) i
−
1( ) i t
t t t t t t t t t t t t t t t t
+ + + +
− − − − − − − − = + + +
(1)
Graphics & Visualization: Principles & Algorithms Chapter 7
They satisfy They join at ti+1 (C0) Their tangents coincide (C1)
35
1 1 1 2 1 2 1 1 1 1 1 1 1 1 2 1 2
( )
i i i i i i i i i i i i i i i i i i i i i i i i i i i i
t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t
+ + + + − − − + + − + + − + + + +
− − − − − − − − = + + + − − − − − − − − Q p p p
1 1 1 1 1 1
i i i i i i i i
+ + + + + +
Its control points Its knots
Graphics & Visualization: Principles & Algorithms Chapter 7
36
2 1 1 1 2 2 1 3 1 1 1 2 1 2 2 1 3 1
( ) , [ , ], ( )
i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i
t t t t t a b t t t t t t t t t t t t t t t t a t t t t t t t t
− − + + + + + + + + − + + + + + + +
− − = + + ∈ − − − − − − = + + + − − − − Q p p p Q p p
1 1 1 2 3 3 2 2 1 2 2 2 3 3 2 3 1
, [ , ], ( ) , [ , ]
i i i i i i i i i i i i i i i i i i
c t t t t t t t t b c t t t t t t t
+ + + + + + + + + + + + + + + + +
∈ − − = + + ∈ − − p Q p p p
Graphics & Visualization: Principles & Algorithms Chapter 7
37
3 2 3 1 i i i i
t t t t
+ + + +
− −
2( ) i i
Control points p0, p1, …, pn First segment Q2(t) uses p0, p1, p2 and requires knots t1, t2, t3, t4
Last segment Q (t) uses p , p , p and requires knots t
, t , t , t
2
( ) ( )
n i i i
t N t
=
= ∑ Q p
Graphics & Visualization: Principles & Algorithms Chapter 7
Last segment Qn(t) uses pn-2, pn-1, pn and requires knots tn-1, tn, tn+1, tn+2
These knots don’t contribute to the shape of the curve
38
2 0( )
2( ) n
interpolate (k+1) control points pi-k, pi-k+1, pi in pairs
result: points , j=i-k+1, i-k+2,…, i , t [t t ] on linear segments
1 ( )
Graphics & Visualization: Principles & Algorithms Chapter 7
result: points , j=i-k+1, i-k+2,…, i , t [tj, tj+k] on linear segments
interpolate the points of previous step result: points , j=i-k+r, …, i , t
[tj, tj+k-r+1] on shrinking t
39
1 ( ) j t
j r t
Each point pi affects (k+1) segments Qj(t), j=i, i+1, …, i+k Construct a function that expresses its contribution to the curve
( ) ( )
n k i i i
t N t
=
= ∑ Q p
k i
k i
Graphics & Visualization: Principles & Algorithms Chapter 7
“Dummy” Knots t0 and tn+k+1 needed for the definition of the but do not
affect the shape of the curve
Knots may be repeated At most k consecutive knots may be equal, ti < ti+k
40
k i
k i
1
i i i
+
1 1 1
( ) ( ) ( )
r r r i i r
t t t t N t N t N t
− − + +
− − = +
Graphics & Visualization: Principles & Algorithms Chapter 7
r-degree polynomials of t with local support on [ti, ti+r+1 ), i.e. 0 everywhere
else
Spline functions because they consist of (r+1) polynomial segments of
degree r joined with Cr-1 continuity at the knots
41
r i
1 1 1 1 1 1
( ) ( ) ( )
r r r i i r i i i i r i i r i
t t t t N t N t N t t t t t
− − + + + + + + +
− − = + − −
1( ) i
1
N
1 1
N
1 2
N
1 3
N
2 4
N 35 . t 75 . 95 . 6 1 2 1 35 . t 95 . 105 . 6 1 2 1
2
N
2 1
N
2 2
N
2 3
N
2 4
N
Graphics & Visualization: Principles & Algorithms Chapter 7
42
2( ) i
Computes points on a B-spline curve Summarizes the linear interpolation steps
Graphics & Visualization: Principles & Algorithms Chapter 7
1. For the required value of t, find the parametric interval [ti, ti+1). The domain is [tk, tn+1] so i must satisfy k ≤ i ≤ n 2. Set 3. Perform the linear interpolation steps: 4. The point of the curve corresponding to t is:
43 0( )
, , 1,...,
j j
t j i k i k i = = − − + q p
1 1 1 1 1 1
( ) ( ) ( ), 1,2,...,
k r j j r r r j j j k r j j k r j j
t t t t t t t r k t t t t
− + + − − − − + + − + +
− − = + = − − q q q ( ) ( )
k i
t t = Q q
Graphics & Visualization: Principles & Algorithms Chapter 7
(1-t and t) – they depend on the specific row and column
must be computed from bottom to top so that the required points are not
44
for (j = i-k; j <= i; j++) { m = j-i+k; //so that m = 0, 1, …, k-r deBoorPt[m] = controlPt[j]; } for (r = 1; r <= k; r++) { for (j = i; j >= i-k+r; j--) {
Graphics & Visualization: Principles & Algorithms Chapter 7
for (j = i; j >= i-k+r; j--) { m = j-i+k; coeff = (t-knots[j]) / (knots[k-r+1+j] - knots[j]); deBoorPt[m] = (1-coeff)*deBoorPt[m-1] + coeff*deBoorPt[m]; } }
45
the curves will vary.
Graphics & Visualization: Principles & Algorithms Chapter 7
46
1
2
N
2 1
N
2 2
N
2 3
N
2 4
N
Graphics & Visualization: Principles & Algorithms Chapter 7
47
35 . t 95 . 105 . 6 1 2
curve
Graphics & Visualization: Principles & Algorithms Chapter 7
48
[1,1,1,2,3,4,5,5,5] [1,1,1,2,2,4,5,5,5] [1,1,1,2,2,2,5,5,5] p
1
p
2
p
3
p
4
p
5
p
6
p
Graphics & Visualization: Principles & Algorithms Chapter 7 49
0, 1,..., i k =
Graphics & Visualization: Principles & Algorithms Chapter 7
◆
changes abruptly
50
0, 1,..., , 1,..., 1, 1,...,
i
i k t i k i k n n k i n n k = = − = + − + = + +
1 1
0 , 1,..., , 1,...,
i i k i k i
i k t i k n t p p
− − − −
= + − = + =
Graphics & Visualization: Principles & Algorithms Chapter 7
and / or
points
51
1
, 1,...,
i n k j j j
t i n n k p p
− + =
= − = + + ∑
1 1
i i i k i k
− − − −
Graphics & Visualization: Principles & Algorithms Chapter 7
52
1 1 1
i i i k i k n k j j j
− − − − − + =
Graphics & Visualization: Principles & Algorithms Chapter 7
53
affects the curve on [ti, ti+k+1] where ≠ 0
k i
1 1
r
2
p
2
r r
5 6
r Graphics & Visualization: Principles & Algorithms Chapter 7
54 1
, 0,..., , 1, , 1
j j j j
j i k j i n
−
= = − = = + … + r p r p
1
, 1,...,
j k j j j j j k j j k j
t s s t j i k i t t t t
+ − + +
− − = + = − + − − r p p
r
1 1 3
p
3
r
4
r
4 5
r
segment
k i
Graphics & Visualization: Principles & Algorithms Chapter 7
All the interpolation steps performed, are convex combinations of the control points
that contribute to its computation
55
points
Graphics & Visualization: Principles & Algorithms Chapter 7
straight line
segment
56
◆
A planar B-spline curve may not be intersected by an arbitrary straight line more times than its control polygon
◆
A non-planar B-spline curve may not be intersected by a straight line or plane more times than its control polygon
Stronger form
Graphics & Visualization: Principles & Algorithms Chapter 7
◆
The above hold for the polygon formed by the (k+1) control points that contribute to any point on the curve
knot sequence is used
57
1 1 1 1 1
n k i i i i i k i
− − + = + + +
Graphics & Visualization: Principles & Algorithms Chapter 7
sequence (0<k>, 1<k>) is a Bézier curve of degree k and control points p0, p1, …, pk
58
Graphics & Visualization: Principles & Algorithms Chapter 7
59
Graphics & Visualization: Principles & Algorithms Chapter 7
60 1 1 1 2 1 1 1 1 1 1 1 1 1 2 1 1 2 1 1 1 2 2
( ) ( ) ( ) ( )
i i i i i i i i i i i i i i i i i i i i i i i i i i i i i
t t t t t t t t t t t t t t t t t t t t
+ − − − − + − + − − + + + + − + + +
− − = = + = − − = − − = = + = − − r Q p p q r p r Q p p q
Graphics & Visualization: Principles & Algorithms Chapter 7
during the interpolation steps.
61
1 1 2 1 3 2 1 1 1 1 2 1 2 1 1 1 2 1 1 1 2 1 2 1 2 1 1 2 1 1 1 2 1 1 2 2 1 2
( ) ( )
i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i
t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t
+ + − − − − + − + − + − + − + − − − − + − + − + + + − − + − + − + −
− − − − = + + − − − − − − = = + − − − − = = + − − r p p r r q p p r q p
1 1 2 1 1 3 1 1 3 2 1 2 2 3 3 i i i i i i i i i i i i i i i i i i i
t t t t t t t t t t t t t t t t
− + + + + + + − + + + +
− − − − = + + − − − − p r r p p
Not invariant to projection transformations not handled easily in a 3D graphics scene Cannot represent conic sections (circles, ellipses, parabolas, hyperbolas) except for parabolas
Graphics & Visualization: Principles & Algorithms Chapter 7 62
h T T i i i i i i i i i i i
n n i i i n i h n h i i n i n
= =
Graphics & Visualization: Principles & Algorithms Chapter 7 63
i n i i i
= =
n r n i i i n n i i i i
= =
Common factors are ruled out due to the division
Graphics & Visualization: Principles & Algorithms Chapter 7 64
Convex-hull property is not maintained Poles, that make the curve go to infinity, may be created
Graphics & Visualization: Principles & Algorithms Chapter 7 65
Convex – hull hold if the weights Variation – diminishing are non - negative
h
Graphics & Visualization: Principles & Algorithms Chapter 7 66
Numerical accuracy Increased computational complexity
If B2 – 4AC < 0, the curve is an ellipse If in addition, B = 0 and A = C, the curve is a circle
Graphics & Visualization: Principles & Algorithms Chapter 7 67
◆ If in addition, B = 0 and A = C, the curve is a circle
If B2 – 4AC = 0, the curve is a parabola If B2 – 4AC > 0, the curve is a hyperbola
An elliptical segment, if | w1 | < 1 A parabolic segment, if | w1 | = 1 (normal Bézier curve) A hyperbolic segment, if | w1 | > 1
Graphics & Visualization: Principles & Algorithms Chapter 7 68
Solid segments: w1 > 0; dashed segments: w1 < 0
The control polygon must be an isosceles triangle |p0p1| = |p1p2| w1 = sinθ, where θ is the half-angle between p0p1 and p1p2
Graphics & Visualization: Principles & Algorithms Chapter 7 69
n r n i i i n n i i i i
= =
Graphics & Visualization: Principles & Algorithms Chapter 7 70
Strong convex – hull hold if the weights Strong variation – diminishing are non - negative
Simple B-Spline curves (equal weights) Simple and rational Bézier curves
Graphics & Visualization: Principles & Algorithms Chapter 7 71
Simple and rational Bézier curves Conic sections
They do not pass through their control points The control points only provide a good indication of their shape
Curves that pass through given points
Graphics & Visualization: Principles & Algorithms Chapter 7 72
Defined by the (n+1) coefficients of the respective polynomials, which can be computed as the single solution of the linear system of (n+1) equations formed as shown above
Graphics & Visualization: Principles & Algorithms Chapter 7 73
Directly, by using Lagrange polynomials Recursively, by using Aitken’s algorithm
Interpolation of several points requires a high-degree polynomial complex and numerically unstable computations The generated curve exhibits oscillations and does not follow its control polygon in a predictable way
Graphics & Visualization: Principles & Algorithms Chapter 7 74
Interpolation with B-splines Hermite curves
n j n i j i j j i
= ≠
( ) ( ) ( )
n n i
t L t t =∑
i
P p
Graphics & Visualization: Principles & Algorithms Chapter 7 75
Invariance under affine transformations: holds since Lagrange polynomials sum to 1 interpolation curve is a barycentric combination
( ) ( ) ( )
i i
t L t t
=
=∑
i
P p ( )
n i
L t
No convex – hull property: Lagrange polynomials are neither always positive nor less than 1 the curve is not contained in the convex hull of its control points Linear precision: if all control points lie on a straight line, the curve has the shape of a straight line No variation–diminishing property: curve may demonstrate oscillations
Graphics & Visualization: Principles & Algorithms Chapter 7 76
0( )
, 0,1,...,
i i
t i n = = p p ( ) ( )
n
1 1 1
r r r i r i i i i i r i i r i
− − + + + +
Graphics & Visualization: Principles & Algorithms Chapter 7 77
, m m
78
1
1
, m m
n n i i i
=
1 1
1 3
1 1 1 3 2 2 1 1
1 (0) 3( ) , 3 1 (1) 3( ) 3 m H q q q p m m H q q q p m
= = − ⇔ = + ′ = = − ⇔ = −
3 2 2 3 1 1 1
79
3 3 3 3 1 1 2 3 1
i
3 3 2 3 3 2 1 3 3 2 3 3 2 2
their defining elements must be altered for the curve to remain the same, when parameter t [0,1] is changed to u [a, b]: We set u = (1-t)a + tb
1
1 ( ) 3( ), 1 ( ) 3( ) a b a b ′ = = − − ′ = = − m H q q m H q q
Graphics & Visualization: Principles & Algorithms Chapter 7 80
Physical explanation: Using H(t) we traverse the curve in one time unit; if
we want to traverse it in (b-a) time units, our speed, represented by the tangent vectors, must be smaller by a factor of (b-a)
1 3 2
( ) 3( ) b b a ′ = = − − m H q q
3 3 3 3 1 1 2 3 1
( ) ( ) ( ) ( )( ) ( )( ) , [ , ] u H u H u H u b a H u b a u a b = + + − + − ∈ H p p m m
1
n
81
i
3 3 3 1 1 2 1 3 1 1 1
( ) ( ) ( ) ( )( ) ( )( ) , [ , ]
i i i i i i i i i i i
u H u H u H u t t H u t t u t t H p p m m
+ + + +
= + + − + − ∈
It allows the modification of the shape of the curve by altering the tangent vectors Even more flexibility achieved, by requiring only G1 geometric continuity at the joins, allowing the tangent vectors at end of a segment and at the beginning of the next one to be multiple of each other instead of equal
Graphics & Visualization: Principles & Algorithms Chapter 7 82
Graphics & Visualization: Principles & Algorithms Chapter 7 83
i
1
i i i
+ −
84
1 1
1 ( ) 2
i i i + −
= − m p p
n
Tangent vector is set equal to the tangent of the parabola that interpolates the 3 neighboring points pi-1, pi, pi+1 If Qi(u), u [ti, ti+1] is this parabola (can be computed using Lagrange polynomials or Aitken’s algorithm) then:
i
m
i i i
85
For the first and last tangent vectors we may use the tangents of the first and last parabola respectively:
1 1
n n n
−
We reach the following formulas for the tangent vectors in terms of the elements of the curve:
2 1 2 1 1 2 2 1 2 1 1 2 1 2 1 1 1 1 1 1
2 ( )( ) ( )( ) ( )( ) 2 ( )( ) ( )( ) ( )( )
i i i i i i i i i i i
t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t t
+ + − − − +
− − + − − = + + − − − − − − − − + − = + + − − − − − − m p p p m p p p
86
Notice that Bessel tangents can be used independently, in order complement the tangents of cardinal splines mentioned above
0, n
m m
1 1 1 1 1 1 1 1 1 1
( )( ) ( )( ) ( )( ) (
i i i i i i i i i i i i i i i i n n n n n
t t t t t t t t t t t t t t t t
− + + − − + − + + − −
− − − − − − − = − m
1 2 2 1 2 1 2 1 1 2 1 2
2 )( ) ( )( ) ( )( )
n n n n n n n n n n n n n n n n n n
t t t t t t t t t t t t t t t
− − − − − − − − − − − − −
− − − − + − − − − − p p p
2 2
Graphics & Visualization: Principles & Algorithms Chapter 7 87
1 2 2
i i i i
−
3 3 3 3 1 1 2 3 1
( ) ( ) ( ) ( )( ) ( )( ) , [ , ] u H u H u H u b a H u b a u a b = + + − + − ∈ H p p m m
1 1 1 1 1 1 1 1 1 1 1
( ) 2( ) ( ) 3 ( ) 3 ( )
i i i i i i i i i i i i i i i i i i i i i
t t t t t t t t t t t t t t
+ − + − + − − + − + − +
− − − + − + − = − + − − − m m m p p p p
Allow the user to supply arbitrary values for the 2 tangent vectors
Geometric conditions, taking into account the shape of the curve near its ends, are applied
0, n
88
ends, are applied
0, n
1 1 1 1 1 1 1 1
1 ... 1 ... 1
n n n n n n n
α β γ α β γ
− − − − −
= m c m c m c m c
⋱ ⋱ ⋱ ⋮ ⋮ ⋮
1 1 1 1 1 1 1 1 1 1
( ), 2( ), 3 ( ) 3 ( ) ( ),
i i i i i i i i i i i i i i i i i i i i i i n n
t t t t t t t t t t t t t t α β γ
+ + − + − − + − + −
= − = − − = − = − + − − − = − = c m c p p p p c m
89
Bessel tangents, computed above for , are used so that the
0, n
m m
n
90
Bessel tangents, computed above for , are used so that the tangents at the ends are those of the parabolas that interpolate the first and last 3 control points It suffices to replace in the previous linear system with these expressions
0, n
m m
0, n
c c
Requires that the 2nd derivatives of the interpolation curve at the first (and last) 2 knots are equal: By differentiating the Hermite curve twice, we can deduce that under this assumption:
2 2 2 2 1 1 1 1 2 2 2 2
( ) ( ) and ( ) ( )
n n n n
d d d d t t t t du du du du
− − −
= = H H H H
1 1
n n− −
91
These relations must be plugged into the linear system, replacing the first and last lines in full The system remains tridiagonal after the changes efficiently solved
1 1 1 1 1 1
n n n n n n
− − −
Requires that the 2nd derivatives are equal to 0 at the ends of the curve Then, the interpolation curve becomes a straight line near its ends (desirable or not, depending on application) The generated curve resembles the mechanical (physical) spline, which is pinned at its ends so that its curvature vanishes Working similarly to the quadratic end condition we get:
92
We should replace the first and last equation of the linear system, with these equations
1 1 1 1 1 1
n n n n n n
− − −
Graphics & Visualization: Principles & Algorithms Chapter 7 93
2 1 1 2
n n n
− − + +
1 3
n j j i j i
−
Graphics & Visualization: Principles & Algorithms Chapter 7 94
First, evaluate the quadratic B-Spline basis function at the knots to get:
3 j j i j i i=−
3( ) i
N t
1 2 2 3 2 3 1
0, 1, , 1, ( ) , 2, 0, otherwise
i i i i i j i i i i
j t t j i t t N t t t j i t t
+ + + + + +
= − = + − = − = + −
1 1 1 1 1 1
r r r i r i i i i i r i i r i
− − + + + + + + +
1 1
i i i i
+ +
Graphics & Visualization: Principles & Algorithms Chapter 7 95
3 2 2 3 2 4 2 2 1 2 3 3 1 4 1 3 1 4 3 4 3 4 1 4
i i i i i i i i i i i i i i i i i i i i i j i i i i i i i
+ + + + + + + + + + + + + + + + + + + + + + +
2
i
1 1 3 1 2 1 1 1 2 1 2 1 3 2 1 2 1 1 2 1 1 1
j j j j j j j j j j j j j j j j j j j j j j j j j j j j
− − − + − + − − + + − − + − + − + − + −
3( ) i
Graphics & Visualization: Principles & Algorithms Chapter 7 96
1 2 1 1 2 1 1 1 1 1 3 3 1 2 1 1
j j j j j j j j j j j j j j j j j j
+ − + − + − + − + + − + − + −
3 3 3 3 3 2 2 1 1
j j j j j j j j j j
− − − − − −
3( ) i j
2 1 3 1 1 2 1 2 1 2 1 2 2 1 2 1
j j j j j j j j j j j j j j j j j j j j
+ − + − − + + − − + − + − −
Graphics & Visualization: Principles & Algorithms Chapter 7 97
1 1 1 1 2 1
j j j j j j j j
− − + − + −
In the former case, the curve was expressed as a piecewise Hermite curve In the later case, it is given as a B-Spline curve
Graphics & Visualization: Principles & Algorithms Chapter 7 98
1 1 1 n-1 n-1 n-1
1 ... 0 0 1 ... 0 ... 0 ... ⋮ ⋱ ⋱ ⋱ ⋮ α β γ α β γ
3 2 1 3 2 1
0 0 ... 0 0 1 0 0 0 0 ... 0 0 0
n n n
q q q q q q ⋮
− − − − − −
1 2 1 2 1 2
( ) ( )
n n n n
t t t t p r p p r p ⋮
− −
− = −
Graphics & Visualization: Principles & Algorithms Chapter 7 99
Equations will be expressed in terms of the given points pi instead of the tangent vectors
At the start of the curve, the tangent is Equating this with: we get:
2 3 2 1 1
− − −
2 1 2 1 1 2 2 1 2 1 1 2 1 2
2 ( )( ) ( )( ) ( )( ) t t t t t t t t t t t t t t t t t t t − − + − − = + + − − − − − − m p p p
100
we get: Working similar for the end of the curve we get: These expressions for q-2, qn-2 must replace r1 and r2 in the linear system
2 2 1 2 1 2 1 2 2 2 1 2 1 2
−
2 1 2 2 1 2 1 2 1 2 2 1 2
n n n n n n n n n n n n n n n n n n n
− − − − − − − − − − − −
We may write the first (and similarly the last) segment of B-Spline curve, defined over a parametric interval [t0, t1], as a cubic Bézier curve and differentiate this form twice:
2 2 1 1 1 2 3 2 1 1
( ) 3( ) ( ) 3( )
n n n n n n n n
t t t t t t t t q q p p q q p p
− − − − − − −
− − = − − − − = − −
Graphics & Visualization: Principles & Algorithms Chapter 7 101
The above must replace the 2nd and the penultimate equation of the system, in full The system remains tridiagonal after the changes
Applied similarly and the respective equations are:
2 1 2 1 1 2 1 3 1 2 2 2
n n n n n n n n n n
− − − − − − − −
1
3( )
n n
t t − −
We can use the given points to generate better shaped curves
Graphics & Visualization: Principles & Algorithms Chapter 7 102
In Uniform the knots are equidistant
Simplifies the linear systems that must be solved to produce C2 cubic interpolating curves
2 1 2 1 1 1 i i i i i i i i
+ + + + + +
2 1 2 1 1 1 i i i i i i i i
+ + + + + +
Graphics & Visualization: Principles & Algorithms Chapter 7 103
B-Spline parameterizations use the control points of the curve
Parameterizations of interpolating curves use the points being interpolated the shape of the curve should be adopted to them
1 1 i i i i
+ +
Graphics & Visualization: Principles & Algorithms Chapter 7
104
Every point of the initial curve will trace a Bézier curve of degree n.
( ) ( ) , [0,1]
m m m i i i
u B u u
=
= ∈
P p
,
( ) ( ) , [0,1]
n n n i j i j j
v B v v
=
= ∈
P p
Graphics & Visualization: Principles & Algorithms Chapter 7
105
n i v
, ( , ) m n u v
, , ,
( , ) ( ) ( ) ( ) ( ) , [0,1], [0,1]
m n m m n m n m n n i j j i j i j i j i j i
u v B u B v B u B v u v
= = = =
= = ∈ ∈
P p p
Graphics & Visualization: Principles & Algorithms Chapter 7
106
, ( , ) m n u v
P
Graphics & Visualization: Principles & Algorithms Chapter 7
107
, ( , ) m n u v
P
point bezierSurfacePoint ( int m, int n, point[][] controlPt, float u, float v ) { point tmpPt[n+1]; point curvePt[n+1]; for (i=0; i <= m; i++) {
Graphics & Visualization: Principles & Algorithms Chapter 7
for (i=0; i <= m; i++) { for (j=0; j <= n; j++) { tempPt[j] = controlPt[i][j]; } curvePt[i] = bezierPoint(n, tempPt, v); } return bezierPoint(m, curvePt, u); }
108
Graphics & Visualization: Principles & Algorithms Chapter 7
Planar precision
surface
109
, ,
( , ) ( ) ( )
n m m n n m j i i j j i
u v B v B u u u
= =
∂ ∂ = ∂ ∂
P p
Graphics & Visualization: Principles & Algorithms Chapter 7
110
if the control points are coplanar draw the polygon defined by the 4 extreme control points else subdivide the surface into 4 subsurfaces for an arbitrary pair (u , v )
Graphics & Visualization: Principles & Algorithms Chapter 7
pair (u0, v0) perform the same procedure recursively to each of the subsurfaces
111
Graphics & Visualization: Principles & Algorithms Chapter 7
112
,
m n k i j i j i j
= =
ℓ
Graphics & Visualization: Principles & Algorithms Chapter 7
113
v [vj, vj+1]
[ui, ui+1]
Graphics & Visualization: Principles & Algorithms Chapter 7
114
apply the Boehm algorithm to the columns of the control net
Graphics & Visualization: Principles & Algorithms Chapter 7
◆
apply the Boehm algorithm to the columns of the control net
◆
a full row of control points is added to the control net
◆
apply the Boehm algorithm to the rows of the control net
◆
a full column of control points is added to the control net
115
Graphics & Visualization: Principles & Algorithms Chapter 7
multiplicity
116
3 for both u and v
determine the (m+3)×(n+3) control points qi,j of Q(u, v) that satisfy:
,
( , ) , 0,1, , and 0,1,...,
i j i j
u v i m j n = = … = Q p
Graphics & Visualization: Principles & Algorithms Chapter 7
◆
Compute the control points si,j of the respective interpolation curves
◆
Each of the curves has (m+3) control points and requires also r0,j and r1,j , j=0,1,…,n
◆
Compute the control points qi,j
◆
Each of the (m+3) curves has (n+3) control points and requires ci,0 and ci,1
117