On Spline Interpolation of Space Data Yu Yu Feng and Jernej Kozak
Abstract. In this paper the interpolation by G2 continuous B´ezier spline curves Bn in IRd is outlined. Each segment of the spline curve interpolates r interior and two boundary points. The general approach is followed in detail for the case d = 3, n = 3, r = 1. For the single component case, the optimal approximation order is proved, and asymptotic existence established. The interpolation scheme is demonstrated by practical experiments.
§1. Introduction Let IRd denote Euclidean space, with the dot product ., and the implied norm √ k.k := .. Let T0 , T1 , . . . , TN ∈ IRd be a sequence of given points that is to be interpolated by a spline curve of degree n. Recall the fact deduced from [6] for the particular case n = 3: a cubic planar curve can interpolate six, but a cubic space curve only five points. Thus, in order to make the interpolation problem correct, let us choose d in advance, and let us assume that the points Ti lie on a smooth regular parametric curve f : I = [α, β] ⊂ IR → IRd , with f (ξi ) = Ti for some α = ξ0 < ξ1 < · · · < ξN = β, where f is a convex “true” IRd curve, i.e., its d − 1 curvatures nowhere vanish. This implies that if the points will be sampled close enough they will be “true” IRd data. In order to make the spline interpolant parametrisation independent, we shall assume that the polynomial pieces will be joined together by geometric continuity conditions, and we shall restrict ourselves to G2 spline curves. Let us consider one spline segment. The reparametrisation t 7→ at + b preserves the degree of the polynomial curve, and one is free to choose two parameter values at which two particular data points will be interpolated. However, the parameter values at which the other data points will be interpolated will be unknown. So it is natural to prescribe that the spline curve interpolates two boundary, and r ≥ 0 interior points per each spline section. This implies N = m(r+1), where m denotes the number of spline segments. At the boundary, two additional interpolating conditions have to be added. Perhaps it is best to require that Mathematical Methods for Curves and Surfaces II Morten Dæhlen, Tom Lyche, Larry L. Schumaker (eds.), pp. 167–174. Copyright c 1998 by Vanderbilt University Press, Nashville, TN. ISBN 1-xxxxx-xxx-x. All rights of reproduction in any form reserved.
o
167
168
Y. Y. Feng and J. Kozak
also tangent directions d0 , dN of f at α, β are interpolated too. We shall express the interpolating spline curve in the B´ezier form. Let Bn denote the B´ezier spline curve with breakpoints ζ` := ξ`(r+1) , ` = 0, 1, . . . , m, and B`n
³t − ζ
`−1
∆ζ`−1
´ = Bn (t),
t ∈ [ζ`−1 , ζ` ],
` = 1, 2, . . . , m
Pn its polynomial components. Then B`n (t) = i=0 bn(`−1)+i Bin (t), t ∈ [0, 1], ¡ ¢ with Bernstein polynomials given as Bin (t) := ni ti (1 − t)n−i . The segment B`n should interpolate the data points T(r+1)(`−1) , T(r+1)(`−1)+1 , . . . , T(r+1)` , i.e., for some t`,0 := 0 < t`,1 < t`,2 < · · · < t`,r < t`,r+1 := 1 one has B`n (t`,i ) = T(r+1)(`−1)+i ,
i = 1, . . . , r,
(1)
and bn(`−1) = T(r+1)(`−1) , bn` = T(r+1)` at the boundary. The geometric continuity will be formulated in the form that does not require additional constants. Let ³ ´ d d d d d ( ) 2 ∧ : IR × IR → IR : (xi )i=1 , (yi )i=1 7→ x ∧ y := (xi yj − xj yi )i 0. 1! 2!
(9)
170
Y. Y. Feng and J. Kozak
With the help of (8) one computes f 00 (s) = e01 (s) = κ1 (s)e2 (s), f 000 (s) = (κ1 (s)e2 (s))0 = −κ21 (s)e1 (s) + κ01 (s)e2 (s) + κ1 (s)κ2 (s)e3 (s), ··· = ········· (10) and the expansions (9) inserted in (10) are used to express f (j) (0) in the required expansion of f , 1 00 1 000 f (s) = f (0) + f 0 (0)s + 2! f (0)s2 + 3! f (0)s3 + · · · 1 2 3 = f (0) + (s − 6 κ1,0 s + · · ·)e1 (0) +( 12 κ1,0 s2 + 16 κ1,1 s3 + · · ·)e2 (0) + ( 61 κ1,0 κ2,0 s3 + · · ·)e3 (0) + · · · (11) 2
Note that the compound matrix ∧ A is nonsingular iff the matrix A is. So difi=1
ferent nonsigular matrices A could be used to simplify the expanded equations (5) and (6) by using the fact 2
x ∧ y = 0 ⇐⇒ ∧ A(x ∧ y) = Ax ∧ Ay = 0, i=1
(12)
and similarly for the curvature continuity equation. In particular, A may be a rotation that brings the Frenet frame at the particular breakpoint ζ` to ³ ´d d (δij )j=1 . i=1 In order to tackle the asymptotic approximation order for a smooth curve f , it is usually enough to consider the single component case, i.e., N = r + 1, and follow [7] to estimate the parametric approximation order. This requires a regular reparametrisation of Bn and f with the same parameter that satisfies certain additional requirements. The number of the data values, r + 4 = n+1+(n−1)/(d−1) is the expected best approximation order. A particularly simple local reparametrisation can be traced to [2], and works in the more general setup too. Let ξ0 = 0, ξN = h, and xi := f .ei (0). The expansion (11) reveals that f 0 (s).e1 (0) = 1 + O(s2 ). So x1 is invertible on [x1 (0), x1 (h)] for sufficiently small h. But then the curve f may be reparametrised by u = x1 (s), x0i (s) d with xi (s) = xi (x−1 (u)). Note that , so the derivative with x (s) = i 1 du x01 (s) respect to u is independent of the length of f (s). But Bn interpolates f at boundary points. So Bn (0).e1 (0) = x1 (0), Bn (1).e1 (0) = x1 (h). Thus if Bn .e1 (0) is also invertible, Bn and f can be reparametrised by the same parameter u. This implies that Bn and f agree (r + 4)-fold. So for a smooth f dr+4 the approximation order r+4 would be achieved if r+4 Bn could be bounded du d` independently of h. The chain rule gives xi (s) as the sum of terms du` P Y (j ) X (k) xi x1 ν /(x01 )k+ jν , jν = `. k+ ν
ν
On Spline Interpolation of Space Data
171
Since the derivatives of the reparametrised Bn are computed in the same manner it is enough to establish ˙ n .e1 (0) = const h + O(h2 ), const 6= 0, B(`) = O(h` ), ` = 2, 3, . . . , n. B n (13) The general approach outlined here is followed in detail for the case d = 3, n = 3, r = 1, i.e., cubic spline interpolation of the space data, and practical examples given. §2. Cubic G2 Interpolation in IR3 Let us consider now a particular case, i.e., the cubic G2 interpolation of the space data. In this case one has d = 3, and r = 1 ≤ n = 3. So one control point can be expressed by the other 2(d − 1) = 4 free parameters. This gives B` := B`3 that interpolates T2`−1 at t` := t`,1 as ³ ´ 2 2 (1 − t) (1 − t) t` − t(1 − t` ) (1 − t) t B` (t) = T2(`−1) + T2`−1 t` (1 − t` ) t` ¡ ¢ t t2 (1 − t` ) − (1 − t) t` 2 + T2` + 3 (1 − t) t (t − t` ) ∆b3`−2 . 1 − t` (14) From here ∆b3`−3 = g1 (t` )∆T2`−2 − g2 (t` )∆T2`−1 − t` ∆b3`−2 , ∆b3`−1 = −g2 (1 − t` )∆T2`−2 + g1 (1 − t` )∆T2`−1 − (1 − t` )∆b3`−2 , (15) with functions g1 and g2 given as ´ 1³ 1 1 t2 (16) g1 (t) := 1 + + t , g2 (t) := . 3 t 31−t By inserting (15) in (5) and (6) one obtains a system of 6m nonlinear equations m F(t, ∆b) = 0 for the unknowns t := (t` )m `=1 , ∆b := (∆b3`−2 )`=1 . Only 4m equations are independent. Let us consider the case m = 1, ` = 1. The elimination of ∆b1 from (15) gives 1 1 ∆b0 − ∆b2 = g(t1 )∆T0 − g(1 − t1 )∆T1 , (17) t1 1 − t1 with 1³2 1´ g(t) := + 2 . 3 t t . Further, let us multiply (17) by d0 and ∧d2 . By (5), the left hand side vanishes, what reveals the equation g(t1 ) det(d0 , ∆T0 , d2 ) = g(1 − t1 ) det(d0 , ∆T1 , d2 )
(18)
for the unknown t1 . The function g is strictly decreasing on (0, ∞), and unbounded at 0. Thus if det(d0 , ∆T0 , d2 ) det(d0 , ∆T1 , d2 ) > 0 the equation (18) has a unique solution t1 ∈ (0, 1). Further, (17) and (5) then yield ∆b0 = t1 (1, 0)(d0 d2 )+ (g(t1 )∆T0 − g(1 − t1 )∆T1 )d0 ,
(19)
and consequently ∆b1 if d0 ∧ d2 6= 0. This proves the following observation.
172
Y. Y. Feng and J. Kozak
Theorem 1. The cubic parametric curve that interpolates the data d0 , T0 , T1 , T2 , d2 is determined uniquely iff det(d0 , ∆T0 , d2 ) det(d0 , ∆T1 , d2 ) > 0. In order to study the asymptotic behaviour of the unknowns let us recall (8), (10), and (11) with the curvature κ := κ1 , and the torsion τ := κ2 . By (12) we may assume that T0 is at origin, and that the Frenet frame at T0 is the identity matrix. Let f be parametrised by the arclength, with f (0) = T0 , f (η1 h) = T1 , 0 < η1 < 1, f (h) = T2 . Then
s − 61 κ20 s3 − 18 κ0 κ1 s4 1 f (s) = 12 κ0 s2 + 16 κ1 s3 − 24 (κ30 + κ0 τ02 − κ2 )s4 + O(s5 ). 1 1 3 4 6 κ0 τ0 s + 24 (2τ0 κ1 + κ0 τ1 )s
(20)
This produces the expansions 1 h4
det(d0 , ∆T0 , d2 ) =
1 2 2 12 (3 − 2η1 )η1 κ0 τ0 1 2 2 + 24 η1 (2 − η1 )κ0 (2τ0 κ1
+ τ1 κ0 )h + O(h2 ),
and 1 h4
det(d0 , ∆T1 , d2 )
=
1 2 2 12 (1 + 2η1 )(1 − η1 ) κ0 τ0 1 (1 − η12 )2 κ0 (2τ0 κ1 + τ1 κ0 )h + 24
From here and (18), the asymptotic expansion of t1 reads ³ κ 1 τ1 ´ 1 t1 = η1 − (1 − η1 )η1 2 + h + O(h2 ), 12 κ0 τ0 and further from (19), and the expansions (20), (21) 1 1 κ1 1 3h 3 h + 36 (2 κ0 + ∆b1 = 16 κ0 h2 + O(h3 ), b1 = 0 0 0
τ1 2 τ0 )h
+ O(h2 ).
(21)
+ O(h3 ). (22)
From here and (20)
1 3h ∆bi = 0 + O(h2 ), 0
i = 0, 1, 2,
what confirms that the second and the third component of the B´ezier curve B1 can be reparametrised by the first one for h small enough, and 1 κ1 − 36 (2 κ0 + ττ10 )h2 1 2 + O(h3 ), i = 0, 1, ∆3 b0 = O(h3 ). ∆2 b i = 6 κ0 h 0 This verifies (13) in this particular case. In view of more general discussion in the introduction we have thus proved the following. Theorem 2. The parametric approximation order of the interpolation sheme considered is optimal, i.e., r + 1 = 5. We shall omit the existence and error analysis of the composite case, and illustrate it by numerical examples only.
On Spline Interpolation of Space Data
173
§3. Numerical Examples The main part of the numerical procedure is to provide an efficient and reliable way to solve the nonlinear system F(t, ∆b) = 0. As in [4] and [5] the continuation method ([1]) was applied. The solution of the homotopy equation H(t, ∆b, λ) := F(t, ∆b) − λF(t0 , ∆b0 ) = 0 was followed from λ = 1 to λ = 0, starting with initial guess obtained by solving the single component problems for data d2(`−1) , T2(`−1) , T2`−1 , T2` , d2` . Here, d2` is the difference approximation of the direction of the curve f at T2` . In order to assure stability, at each Euler predictor step of the method two equations with the largest residuals were selected (out of three) to represent the wedge product equation in (3) and (4). As the first example let us consider the interpolation of the spiral sin ξ f1 : [0, 15] → IR3 : ξ 7→ f1 (ξ) := ln(2 + ξ) cos ξ ln(1 + ξ) with positive curvature and negative torsion. Tab. 2 shows that the computed error and approximation order (estimated from two consecutive m). The error column is an estimated parametric distance ([7]), obtained by reparametrisation of Bn as suggested in [3]: the point Bn (t(ξ)) is the intersection of the curve Bn and the normal plane for f at f (ξ). This implies (Bn (t(ξ)) − f (ξ)).f˙ (ξ) = 0, so one has to solve a cubic equation to produce t(ξ) for each ξ. The estimated approximation order clearly tends to 5, and the numbers of function and Jacobian matrix evaluations (#F , #H 0 ) are rather small. m 6 8 10 12 14 16 18 20
Error 0.72818 ∗ 10−1 0.17944 ∗ 10−1 0.67640 ∗ 10−2 0.30128 ∗ 10−2 0.14750 ∗ 10−2 0.77685 ∗ 10−3 0.43515 ∗ 10−3 0.25687 ∗ 10−3
Rate 4.87 4.37 4.44 4.63 4.80 4.92 5.00
#F 14 11 11 10 9 9 9 9
Tab. 2. The results for f1
#H 0 10 9 10 8 8 8 8 8
m 8 10 12 16 18 22
Error 0.56932*10−4 0.46259*10−2 0.73456*10−5 0.18523*10−4 0.14192*10−4 0.43003*10−5
#F 15 63 13 24 34 14
#H 0 11 63 8 10 22 9
Tab. 3. The results for f2
The second example is the interpolation of the part of the closed curve (2 + cos ξ) cos( 23 ξ) f2 : [π, 2π] → IR3 : ξ 7→ f2 (ξ) := (2 + cos ξ) sin( 32 ξ) . sin ξ
174
Y. Y. Feng and J. Kozak
Here, the torsion of f2 changes sign. Tab. 3 shows that some m produce better results that the others, and the estimated rate would be meaningless. The algorithm even failed to obtain the solution for some m. This is due to the fact that if the tension changes sign, the data may be planar even if they are sampled very closely. Acknowledgments. Jernej Kozak is supported by the Ministry of Science and Technology of Slovenija. References 1. Allgower, E. L., and K. Georg, Numerical Continuation Methods, Springer-Verlag, 1990. 2. de Boor, C., K. H¨ollig, and M. Sabin, High accuracy geometric Hermite interpolation, Comput. Aided Geom. Design 4 (1987), 269–278. 3. Degen, W. L. F., Best approximations of parametric curves by splines, in Mathematical Methods in Computer Aided Geometric Design II, T. Lyche and L. L. Schumaker (eds.), Academic Press, New York, 1992, 171–184. 4. Feng Y. Y., and J. Kozak, On G2 continuous interpolatory composite quadratic B´ezier curve, J. Comput. Appl. Math. 72 (1996), 141–159. 5. Feng Y. Y., and J. Kozak, On G2 continuous cubic spline interpolation, BIT 37 (1997), 312–332. 6. Goldman R. N., The method of resolvents: a technique for the implicitization, inversion, and intersection of non-planar parametric, rational cubic curves, Comput. Aided Geom. Design 2 (1985), 237–255. 7. Lyche T., and K. Mørken, A metric for parametric approximation, in Curves and Surfaces in Geometric Design, P. J. Laurent, A. Le M´ehaut´e, and L. L. Schumaker (eds.), A. K. Peters, Wellesley MA, 1994, 311–318. 8. Schaback R., Interpolation in IR2 by piecewise quadratic visually C 2 B´ezier polynomials, Comput. Aided Geom. Design 6 (1989), 219–233. 9. Schaback R., Planar curve interpolation by piecewise conics of arbitrary type, Constr. Approx. 9 (1993), 373–389. Yu Yu Feng Department of Mathematics, University of Science and Technology 230026 Hefei, Anhui, PEOPLE’S REPUBLIC OF CHINA
[email protected] Jernej Kozak Department of Mathematics, University of Ljubljana Jadranska 19, 1000 Ljubljana, SLOVENIJA
[email protected]