Sunteți pe pagina 1din 29

History

The term spline comes


from the shipbuilding
industry: long, thin strips of
wood or metal would be
bent and held in place by
heavy ducks, lead weights
which acted as control
points of the curve.
Wooden splines can be
described by Cn-continuous
Hermite polynomials which
interpolate n+1 control
points. Top: Fig 3, P.7, Bray and Spectre, Planking and Fastening, WoodenBoat Pub (1996)
Bottom: http://www.pranos.com/boatsofwood/lofting%20ducks/lofting_ducks.htm
History
Curves which must have n+1
control points are hard to work
with. (n+1)x(m+1) patches are
even moreso.
But continuitysmooth curvesis
essential to the perception of quality
of manufacture. Especially in cars,
and some Apple products.
Splines were generalized in the
1960s by Bezier (Renault), de
Casteljau (Citroen), de Boor (GM).
Beziersa quick review
A Bezier cubic is a function P(t)
defined by four control points:
P0 and P3 are the endpoints of the P1
P2
curve; P1 and P2 define the other
two corners of the bounding
trapezoid. P0

The curve fits entirely within the


P3

bounding trapezoid.
Joining Bezier splines
To join two Bezier splines with C0
continuity, set P3=Q0.
To join two Bezier splines with C1
continuity, require C0 and make the tangent
vectors equal: set P3=Q0 and P3-P2=Q1-Q0.
Q1

Q0
P3

P2
Joining Bezier patches
This works for Bezier patches as well: to join
two patches with C1 continuity at an edge,
ensure that their control points and tangent
vectors on that edge are equal.
NURBS patches are
joined in exactly the
same way.
Beziers
Cubics, of course, are just one example of
Bezier splines:
Linear: P(t) = (1-t)P0 + tP1
Quadratic: P(t) = (1-t)2P0 + 2t(1-t)P1 + t2P2
Cubic: P(t) = (1-t)3P0 + 3t(1-t)2P1 + 3t2(1-t)P2 + t3P3
... n choose v = n! / i!(n-i)!
n
n
General: P (t ) (1 t ) t Pi , 0 t 1
n i i

i 0 i
P1
Beziers (1-t)P1+tP2

(1-t)P0+tP1
Thinking about Beziers P(t) P2

Linear interpolations P0
The linear Bezier is a linear interpolation between two points.
The quadratic Bezier can be seen as a linear interpolation
between two lines:
P(t) = (1-t) ((1-t)P0+tP1) + (t) ((1-t)P1+tP2)
The cubic is a linear interpolation between linear
interpolations between linear interpolations etc.
Another way to see Beziers is as a weighted average
between the control points.
Bernstein polynomials
P(t) = (1-t)3P0 + 3t(1-t)2P1 + 3t2(1-t)P2 + t3P3
1 1
0.4 0.4
0.8 0.8

0.3 0.3
0.6 0.6

0.2 0.2
0.4 0.4

0.2 0.1 0.1 0.2

0.2 0.4 0.6 0.8 1 0.2 0.4 0.6 0.8 1 0.2 0.4 0.6 0.8 1 0.2 0.4 0.6 0.8 1

The four control functions are the four Bernstein


polynomials for n=3.
n v
General form: bv ,n (t ) t (1 t ) n v
v
Bernstein polynomials in 0 t 1 always sum to 1:
n v
v0 v t (1 t ) nv (t (1 t ))n 1
n


Parameterizing a chain of Beziers
Q1 Q2
We can parameterize this chain
Q0 Q3 over t by saying that instead of
P3 R0 going from 0 to 1, t moves
smoothly through the intervals
[0,1,2,3]
P2 R1
The curve C(t) would be:
Consider a chain of splines C(t) = P(t) ((0 t <1) ? 1 : 0) +
with many control points Q(t-1) ((1 t <2) ? 1 : 0) +
P = {P0, P1, P2, P3} R(t-2) ((2 t <3) ? 1 : 0)
Q = {Q0, Q1, Q2, Q3}
R = {R0, R1, R2, R3} [0,1,2,3] is, in a way, a type of
with C1 continuity knot vector. 0, 1, 2, and 3 are
P3=Q0, P2-P3=Q0-Q1 the knots.
Q3=R0, Q2-Q3=R0-R1 This is not strictly true, but the
idea is right: knots define
intervals.
NURBS
NURBS (Non-Uniform Rational B-
Splines) are a generalization of Beziers.
NU: Non-Uniform. The control points dont have
to be weighted equally.
R: Rational. The spline may be defined by
rational polynomials (homogeneous coordinates.)
BS: B-Spline. A chained series of Bezier splines
with controllable degree.
B-Splines
A Bezier cubic is a polynomial of degree three: it
must have four control points per spline, it must
begin at the first and end at the fourth, and it
assumes that all four control points are equally
important.
Beziers are actually a type of B-spline. B-splines
are a piecewise parameterization of Beziers that
supports an arbitrary number of control points and
lets you specify the degree of the polynomial
which interpolates them.
B-Splines
Well build our definition of a B-spline from:
n+1, the number of control functions
k, the degree of the curve
{P0Pn}, a list of n+1 control points
[t0,t1,,tk+n+1], a knot vector of parameter values
n intervals n+1 control points
k is the degree of the curve, so k+1 is the number of control points
which influence a single interval. k must be at least 1 (two control
points linked by each linear line segments) and no more than n
(the number of intervals.)
There are k+n+2 knots, and ti ti+1 for all ti.
B-Splines
The equation for a B-spline is
n
P (t ) N i ,k (t ) Pi , t min t t max
i 0

Ni,k(t) is the basis function of control point Pi.


Ni,k(t) is defined recursively:
1, ti t ti 1
N i , 0 (t )
0, otherwise
t ti t t
N i ,k (t ) N i ,k 1 (t ) i k 1 N i 1,k 1 (t )
ti k ti ti k 1 ti 1
B-Splines
t0 t1 t2 t3 t4

N0,0(t) N1,0(t) N2,0(t) N3,0(t)

N0,1(t) N1,1(t) N2,1(t)

N0,2(t) N1,2(t)

N0,3(t)
1, ti t ti 1
N i , 0 (t )
0, otherwise
B-Splines

0 1 1 2 2 3 3 4 4 5
N0,0(t) N1,0(t) N2,0(t) N3,0(t) N3,0(t)

N 0,0 (t) 1, 0 t 1 N1,0 (t) 1, 1 t 2


N 2,0 (t) 1, 2t3 N 3,0 (t) 1, 3 t 4
N 4,0 (t) 1, 4t5

Knot vector = {0,1,2,3,4,5}, k = 0


t ti ti k 1 t
N i ,k (t ) N i ,k 1 (t ) N i 1,k 1 (t )
ti k ti ti k 1 ti 1
B-Splines
1 1 1 1

0.8 0.8 0.8 0.8

0.6 0.6 0.6 0.6

0.4 0.4 0.4 0.4

0.2 0.2 0.2 0.2

-1 1 2 3 4 5 -1 1 2 3 4 5 -1 1 2 3 4 5 -1 1 2 3 4 5

N0,1(t) N1,1(t) N2,1(t) N3,1(t)


t 0 2t t 0 t 1
N 0,1 (t) N 0,0 (t ) N1, 0 (t )
1 0 2 1 (2 t ) 1 t 2
t 1 3t (t 1) 1 t 2
N1,1 (t) N1, 0 (t ) N 2,0 (t )
2 1 3 2 (3 t ) 2t3
t 2 4t (t 2) 2t3
N 2,1 (t) N 2, 0 (t ) N 3,0 (t )
3 2 43 (4 t ) 3 t 4
t 3 5t (t 3) 3 t 4
N 3,1 (t) N 2,0 (t ) N 3, 0 (t )
43 54 (5 t ) 4t5

Knot vector = {0,1,2,3,4,5}, k = 1


t ti ti k 1 t
N i ,k (t ) N i ,k 1 (t ) N i 1,k 1 (t )
ti k ti ti k 1 ti 1
B-Splines
0.7 0.7 0.7

0.6 0.6 0.6


0.5 0.5 0.5
0.4 0.4 0.4

0.3 0.3 0.3


0.2 0.2 0.2

0.1 0.1 0.1

-1 1 2 3 4 5 -1 1 2 3 4 5 -1 1 2 3 4 5
N0,2(t) N1,2(t) N2,2(t)
(t / 2)(t ) 0 t 1
t 0 3t
N 0,2 (t) N 0,1 (t ) N1,1 (t ) (t / 2)(2 t ) ((3 t ) / 2)(t 1) 1 t 2
20 3 1 ((3 t ) / 2)(3 t )
2t 3
((t 1) / 2)(t 1) 1 t 2
t 1 4t
N1,2 (t) N1,1 (t ) N 2,1 (t ) ((t 1) / 2)(3 t ) ((4 t ) / 2)(t 2) 2t 3
3 1 42 ((4 t ) / 2)(4 t )
3t 4
((t 2) / 2)(t 2) 2t 3
t 2 5t
N1,2 (t) N 2,1 (t ) N 3,1 (t ) ((t 2) / 2)(4 t ) ((5 t ) / 2)(t 3) 3t 4
42 53 ((5 t ) / 2)(5 t )
4t 5

Knot vector = {0,1,2,3,4,5}, k = 2


B-Splines
3 3

2.5 2.5

2 2

1.5 1.5

1 1

0.5 0.5

0.5 1 1.5 2 2.5 3 0.5 1 1.5 2 2.5 3

At k=1 the function is piecewise At k=2 the function is piecewise


linear, depends on P0,P1,P2,P3, and is quadratic, depends on P0,P1,P2, and is
fully defined on [t1,t4). fully defined on [t2,t3).
Each degree-k control function depends on k+1 knot values, so Ni,k depends on ti
through ti+k, inclusive. So six knots five discontinuous functions four piecewise
linear interpolations three quadratics, interpolating three control points. n+1=3
control points, k=2 degree, n+1+k+1=6 knots.

Knot vector = {0,1,2,3,4,5}


Non-Uniform B-Splines
The knot vector {0,1,2,3,4,5} is uniform:
ti+1-ti = ti+2-ti+1
Varying the size of an interval changes the
parametric-space distribution of the weights
assigned to the control functions.
Repeating a knot value reduces the continuity of the
curve in the affected span by one degree.
Repeating a knot k+1 times will lead to a control
function being influenced only by that knot value;
the spline will pass through the corresponding
control point with C0 continuity.
Multiple knots and Barycentric property
At t = t5, N4,9 = 0 N4,6(t5) + N4,7(t5) + N4,8(t5) = 1

N4,4 N4,5 N4,6 N N4,8 N N4,10


4,7 4,9

t0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10
Multiple knots and Barycentric property
For t4 = t5, N4,8 = 0 N4,6(t5) + N4,7(t5) = 1

N4,7
N4,6 N4,8 N
4,9

t0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10
Multiple knots and Barycentric property
For t3 = t4 = t5, N4,7 = 0 N4,6(t5) = 1

N4,6
N4,9
N4,7 N4,8

t0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10

Control point associated with N4,6(t) is b2: the spline passes through b2
Open vs Closed
A knotvector which repeats its first and last
knot values k+1 times is called closed,
otherwise open.
Repeating the knots k+1 times is the only way to
force the curve to pass through the first or last
control point.
Without this, the functions N0,k and Nn,k which
weight P0 and Pn would still be ramping up and
not yet equal to one at the first and last ti.
range of full support [3, 12)
Example
6

ti = i,
i = 0, , 15 2
For spline to pass through (0, 0),
the knot t4+4-1 = t7 = 7 should have multiplicity 3.
t 5 = t6 = t7 = 7
0
For spline to pass through (8, 0),
the knot t7+4-1 = t10 = 10 should have multiplicity 3.
-2 t8 = t9 = t10 = 10

-4

-6
0 2 4 6 8
Open vs Closed
Two examples you may recognize:
k=2, n+1=3 control points, knots={0,0,0,1,1,1}
k=3, n+1=4 control points, knots={0,0,0,0,1,1,1,1}
Non-Uniform Rational B-Splines
Repeating knot values is a clumsy way to
control the curves proximity to the control
point.
We want to be able to slide the curve nearer or
farther without losing continuity or introducing
new control points.
The solution: homogeneous coordinates.
Associate a weight with each control point: i.
Non-Uniform Rational B-Splines
We Know: [x, y, z, ]H [x / , y / , z / ]
Or: [x, y, z,1] [x, y, z, ] H

Thecontrol point
Pi=(xi, yi, zi)
becomes the homogeneous control point
PiH =(xii, yii, zii)
A NURBSn in homogeneous coordinates is:
PH (t ) N i ,k (t ) PiH , t min t t max
i 0
Non-Uniform Rational B-Splines
Toconvert from homogeneous coords to
normal ncoordinates:
xH (t ) ( xii )( N i ,k (t )) x(t ) xH (t ) / (t )
i 0
n
y (t ) y H (t ) / (t )
y H (t ) ( yii )( N i ,k (t )) z (t ) z H (t ) / (t )
i 0
n
z H (t ) ( zii )( N i ,k (t ))
i 0
n
(t ) (i )( N i ,k (t ))
i 0
Non-Uniform Rational B-Splines
A piecewise
n
rational curve is thus defined by:
P (t ) Ri ,k (t ) Pi , t min t t max
i 0
with supporting rational basis functions:
i N i ,k (t )
Ri ,k (t ) n

N
j 0
j j ,k (t )

This is essentially an average re-weighted by the s.


Such a curve can be made to pass arbitrarily far or
near to a control point by changing the
corresponding weight.

S-ar putea să vă placă și