Vous êtes sur la page 1sur 6

Uniform Cubic B-Splines

Christian Spielberger November 29, 2010


Abstract This report introduces a simple method how to approximate a closed uniform B-spline curve with straight line segments and circular arcs. The result is a G1 continuous curve that is at the approximation points tangential to the original. We also describe how to convert a uniform cubic B-spline curve into a sequence of cubic Bzier curves and list several prope erties of a uniform B-spline curve.

Introduction

We consider only closed cubic uniform B-spline curves in the plane. Let Q : [0, 1] R2 be such a curve with control points (C1 , C2 , . . . , Cn ) R2n . Then the i-th spline segment can be written as: 3t3 6t2 + 4 (1 t)3 Ci1 + Ci 6 6 3t3 + 3t2 + 3t + 1 t3 + Ci+1 + Ci+2 6 6

Qi (t) =

(1)

It depends on the location of four successive control points. We want to mention some properties of such a segment. The start- and end points are: 1 4 Ci1 + Ci + 6 6 4 1 Qi (1) = Ci + Ci+1 + 6 6 1 Ci+1 6 1 Ci+2 6

Qi (0) =

(2) (3)

The rst derivate in general and at t = 0, 1: 3(1 t)2 9t2 12t 9t2 + 6t + 3 3t2 Qi (t) = Ci1 + Ci + Ci+1 + Ci+2 (4) 6 6 6 6 Ci+1 Ci1 Qi (0) = (5) 2 Ci+2 Ci (6) Qi (1) = 2 The second derivate: Qi (t) = (1 t)Ci1 + (3t 2)Ci + (3t + 1)Ci+1 + tCi+2 1 (7)

In some situations an inection point arises. We denote the determinant by |.|. At an inection point the following condition is true: Qi (t), Qi (t) = 0 We denote the coordinates of the control points as Ci1 = x0 , Ci = y0 x1 , Ci+1 = y1 x2 , Ci+2 = y2 x3 . y3 (9) (8)

With constants D = (3x1 (y0 y2 ) + x3 (y0 y2 ) + x2 (4y0 + 3y1 + y3 ) 8(x2 (y0 + y1 ) + x1 (y0 y2 ) + x0 (y1 + y2 )) (x3 (y0 2y1 + y2 ) x2 (2y0 3y1 + y3 ) x0 (y1 2y2 + y3 ) + x1 (y0 3y2 + 2y3 )), x0 (3y1 4y2 + y3 ))2

(10)

N = 2(x3 (y0 2y1 + y2 ) x2 (2y0 3y1 + y3 ) x0 (y1 2y2 + y3 ) + x1 (y0 3y2 + 2y3 )), the solution of Equ. (8) is

A = 3x1 y0 4x2 y0 + x3 y0 3x0 y1 + 3x2 y1 + 4x0 y2 3x1 y2 x3 y2 x0 y3 + x2 y3 ,

A D . (11) t1,2 = N We are only interested in real solutions with 0 t 1. Thus if D < 0 we omit the complex solutions. Using an adequate solution t, the inection point is Q(t). We use the inection point as approximation point on the spline. Additionally, we add the start- and end points of the spline segment to the approximation points. Optionally more approximation points can be added. We produce a G1 continuous approximation which is tangential to the B-spline curve at the chosen approximation points.

Fitting an arc into a corner

As basic procedure for our approximation of the B-spline curve we explain how to t a circular arc and straight line segment G1 continuous into a corner. See Fig. 1! For A, a R2 let GA,a := {A + a : R} and GB,b be two straight lines in the plane. Then the intersection point between the two straight lines can be computed by solving the equation A + a = B + b. If |b, a| = 0 the straight lines are parallel. Otherwise the solution is |b, (B A)| , |b, a| |a, (B A)| , S = A + a. = |b, a| = 2 (13) (14) (12)

S B A T T A B A

T B

S Figure 1: A tting tangential seg-arc chain.

The center point for the tting arc is computed by the intersection of the angle bisector with the normals onto A, resp. B. We choose the intersection point closer to S. Thus A or B is one end point of the arc. For the moment suppose B is the end point. The other end point T can be found by using the fact S B = S T . The tting seg-arc curve is composed of a straight line segment from A and T and a circular arc from T to B. See Fig. 2! S

B T

Figure 2: The center of the tting arc.

Approximation

Equ. (2), (3), (5), (6) show us that Qi and Qi+1 are connected C1 continuous in the end point of Qi and the start point of Qi+1 . That is Qi (1) = Qi+1 (0) Qi (1) = Qi+1 (0). (15) (16)

We approximate each B-spline segment separately and ensure a tangential approximation in the start- and end point. Let Ti = (ti,0 = 0, ti,1 , ti,2 , . . . , ti,mi 1 = 1) Rmi be a sequence of parameter values for the i-th B-spline segment. If 3

there is a solution for Equ. (8), the parameter t for the inection point can be i computed. If t (0, 1) it should also be in Ti . i We dene Q = (Qi (ti,j ))(j=0,1,...,mi 1),i=1,...,n and call them approximation points. Furthermore we dene Q = (Qi (ti,j ))(j=0,1,...,mi 1),i=1,...,n the tangent directions at the approximation points. Fig. 3 shows the tangents at the approximation points. We place a tting seg-arc combination as described in Section 2 at each tangent intersection. Fig. 4 shows the result.

Figure 3: Tangents at the end- and inection points. The black dots are the control points. The white dots are the end points of the B-spline segments. The red crosses are the inection points.

Figure 4: A piece of the uniform B-spline (the black line) and its approximation (the red line).

Uniform cubic B-spline to cubic Bzier e

A uniform cubic B-spline curve segment Qi can be represented by a cubic Bzier e curve R, if the control points are chosen adequately. Thus it is possible to nd control points for a Bzier curve R so that Qi (t) = R(t) for 0 t 1. A cubic e Bzier curve is written as e R(t) = (1 t)3 P0 + 3t(1 t)2 P1 + 3t2 (1 t)P2 + t3 P3 . (17)

We repeat at this point the denition of the uniform cubic B-spline segment Qi (t) = 3t3 6t2 + 4 3t3 + 3t2 + 3t + 1 t3 (1 t)3 Ci1 + Ci + Ci+1 + Ci+2 . 6 6 6 6 (18)

We rewrite both into polynomials by t R(t) = (P0 + 3P1 3P2 + P3 ) t3 + (3P0 6P1 + 3P2 ) t2 + (3P1 3P0 )t + P0 , Qi (t) = (19) t2 (20)

Ci1 Ci1 Ci Ci+1 Ci+2 3 Ci+1 t + + + Ci + 6 2 2 6 2 2 Ci1 Ci1 2Ci Ci+1 Ci+1 t+ + + + 2 2 6 3 6

and equate the coecients. The result is Ci1 + 4Ci + Ci+1 , 6 2Ci + Ci+1 , P1 = 3 Ci + 2Ci+1 P2 = , 3 Ci + 4Ci+1 + Ci+2 P3 = . 6 P0 = (21) (22) (23) (24)

If the polynomial coecients in Eqn.(19), or Eqn.(20) (which are just points in R2 ) are computed and the rst and second derivate are used to compute a solution for Eqn. (8), then the formulas for the inection point could be simplied. But our formulas use the control points directly. Remark: When a uniform cubic B-spline curve is replaced by a sequence of cubic Bzier curves, then twice as many control points are needed. That is e because two successive cubic B-spline segments share three control points but two successive Bzier curves only one. e

Further properties of a uniform cubic B-spline


(1 t)3 , 6 3t3 6t2 + 4 , a1 (t) = 6 3t3 + 3t2 + 3t + 1 , a2 (t) = 6 t3 a3 (t) = 6

We rewrite the four coecients of the control points in Qi (t). a0 (t) = (25) (26) (27) (28)

Compare with Eqn. (18)! These coecients have the properties: 0 ai (t) 1
3

for i = 0, 1, 2, 3 and 0 t 1, for t R.

(29) (30)

ai (t) = 1
i=0

Thus the segment is covered completely by the convex hull of the four control points. See Fig. 5!

Figure 5: The cubic B-spline segment is contained in the convex hull of its control points.

Vous aimerez peut-être aussi