Application of the Bézier curve to data interpolation

Application of the Bézier curve to data interpolation

Application of the Bezier curve to data interpolation Koichi Harada and Eihachiro Nakamae A m e t h o d o f using Bernstein--Bdzier curves for data i...

416KB Sizes 0 Downloads 26 Views

Application of the Bezier curve to data interpolation Koichi Harada and Eihachiro Nakamae

A m e t h o d o f using Bernstein--Bdzier curves for data interpolation is proposed. The curves obtained satisfy the required conditions for 'visual content'. A numerical example is executed not only on data points in a plane b u t also on the data points o f a 3D object. The proposed curves are assessed for stereoscopic effect. Comparisons o f the n e w interpolating curves with cubic splines demonstrate their merits. computer~ided design, B~zier curves, data interpolation

B-splines are the most widely used curves in the field of CAGD (computer-aided geometric design). These splines are formed by generalizing B~zier curves in order ~o include the property of locality. (Strictly speaking they should be called Bernstein-B~zier curves.) Although their equations have complicated forms, B-splines are widely used in CAGD because of their responsiveness to user control. The ultimate aim in this field is to find curves which describe designers' ideas correctly on a display. There exists another field called 'data interpolation' (or curve interpolation i ). The final operation in this field deals with curves that can depict faithfully the information contained in the given data points. No measurement has been proposed to assess results of the data interpolation, except the 'visual content'. Visual content is a human judgement and inevitably vague; the criterion is always discussed when speaking of interpolated curves. A remarkable property of curves in the data interpolation category is that they contain few control parameters. These parameters must be determined automatically by some procedures, because users have no a p r i o r i idea about the ultimate shape of the curve. Interactive operations are almost unused in this field. A common feature of CAGD and data interpolation is that the curves have to pass through given data points, differing from data smoothing 2 . Further comparisons between CAGD and data interpolation are given in Table I. This paper discusses the field of data interpolation. Cubic splines are useful in this field. These splines, however, sometimes produce undulations that are visually unpleasing 3 . An approach to get rid of undulations has been carried out by using interpolations retaining concave/convex forms 4 ; concave/convex arrangments of data points are interpolated by concave/convex curves. This approach seems to be promising in spite of the restrictions it inevitably imposes on data points. Hence, it seems to be important to investigate data interpolation problems taking into account the following aspects:

• concave/convex retainment • local calculation Local calculation is an important feature in CAGD to help user control. In data interpolation, it is desirable for on-line representations of interpolating curves, especially if the host computer and/or the display are small. In this paper, B~zier curves will be used to interpolate data points. As these curve segments will be calculated separately under each CT (characteristic triangle) the requirement for local calculation is satisfied. Further, it will be shown that the requirement for concave/convex retainment can also be satisfied using this CT. The composition of CT is done by introducing two ideas: 'faithfulness' and 'effectiveness'. The visual content criterion can be extended to the stereoscopic point of view by using two 2D images. The procedure in this paper is 2D although it is applicable to the 3D problems.

LOCAL GENERATION

OF BF.ZIER C U R V E

The B~zier curve can be written as, n P (t) = ;£"

(1)

PiJi, n (t)

i=0

where/i,n (t) = nCit/(1 - t) n-i. This curve does not possess the local property, ie any positional change o f P i (i=0, I . . . . , n) affects the entire curve. One of the simplest way to introduce locality is to use B6zier curves as curve segments. To do this, let the number of the characteristic points be even and larger than four, ie n = 2 N (N=2, 3 . . . . ) in equation (2). Figure I illustrates a particular situation. Here, P i = P2 = • • • = P N - I

= Pa

PN+I = PN+2 = P2N-I = Pb

(2)

c (Pa - Po ) = PN - Po C(Pb - P 2 N ) = P N - P 2 N

Table 1. Comparisons of CAGD and data interpolation from several points of view. 'Visual content' is important when the interpolant is displayed on a graphic device Condition Feature Object

CAGD Through data points Contain many control parameters Describe designers' aim Flexibility

Data interpolation Through data points Few control parameters Get visual content

Faculty of Engineering, Hiroshima University, Hiroshima 730, Japan

Demand

volume 14 number I january 1982

$03.00 © 1982 Butterworth & Co (Publishers) Ltd.

0010-4485/82/010055-05

Faithfulness

55

in which the Form of the B~zier curve changes according to the value of c, increases as the degree of equation (3) increases. On the other hand, the degree of equation (3) affects drastically the amount of calculations required because it is used repeatedly in each interval of the data. It is also found that the subarea inside the convex hull of the CT which the B6zier segments of low degree cannot 'cover' remains near the line PoP2N and near the point PN. Considering these facts, we postulate N=3 in the following discussion (coverage of the segment is about 70 per cent of the convex hull). Under this assumption, concavity/ convexity is retained (see Appendix.) There is an essential problem if B~zier curves are used for interpolation. One of the strict constraints on an interpolating curve is that it has to pass through the given data points. The characteristic points given by equation (1) are, however, not on the interpolating curve (except for P0 and P2N). Hence only P0 and P2N can be used for data interpolation. Therefore, we give the CT between each two successive data points, and one of the B~zier curves is generated in each CT. An algorithm to compose a CT is discussed in the next section.

COMPOSITION OF THE CT

Po

~.

Figure 1. A characteristic triangle discussed in the texl, N=3 is supposed. Parameter c controls the shape o f interpolating curve.

are assumed. The triangle composed by Po, PN and P2N is a characteristic triangle of multiplicity (N-2), because of the multiplicity of Pa and Pb. The B~zier curve defined by this CT is: 2N

P(t) = ~

ait i i=0 i=0

ai

=

]

.

(3)

-ll'2Nci[Po + z (-ll'ic~Pjl j=l

PN PIp~ P]= Pb 2N

j=N N+I~
The parameter c in equation (2) must be determined by some procedures. The simplest way is to set c at a prescribed value; this method is applied in this paper. The parameter c controls the 'curvature' of the B~zier curve. Therefore, it can be used to change the characteristic of the interpolant. The effect of c becomes obvious by investigating the relation between the B~zier curve and its characteristic points. One of the well known properties of this curve is that it lies inside the convex hull defined by characteristic points 3 (the CT composed of three points P0, PN, and P2Nin this case). It can be shown by numerical analysis that the degree of equation (3) affects the area in which the B~zier curve changes form corresponding to c: the area,

56

It seems natural to use two edges Po PN and P,V P2N of the CT as two tangent lines atP0 and P2N, respectively. Then the following holds: the curve given by connecting the chain of B~zier curves in CTs has continuity of at least C j -class (continuous up to the first derivative), if two edges Po PN and PN P2N of each CT coincide with tangent lines at P0 and P2N respectively. In general, the process of determining tangent lines at data points is included in generating interpolating curves, and it requires tedious calculations and a large memory to retain the intermediate information; this prevents the use of small-scale computers (eg microcomputers) for curve generation. Local processing is used to overcome these problems s . We suggest here a method using three circles to manipulate the local processing. (See Figure 2.) In this method, the tangent angle si at Pi is written as 3 3 s i = t a n [~ WikOikl~, Wik] k=l k=7 (4)

\ /

~ - " c;.

\

" ~,z

Figure 2. Three circles used to determine the tangent line at Pi. 8~, 82 and 83, 84 are measured on the basis o f radH C M Pi and Ci+ ~Pi, respectively, sil, Sh and si3 are derived using circles C i_l , C i and Ci+1, respectively.

computer-aided design

where weights wik (k=1,2,3) indicate the effects of sik (k=1,2,3) on si, determined by the three circles in Figure 2 and o ik (k= 1,2,3) denote the tangent angles sik (h=1,2,3), defined in the prescribed co-ordinate systems. To determine wik , the following assumptions are made: • The use of the circle Pi_2Pi_IPi is appropriate when Pi_2Pi_I = Pi_I Pi. • The effect ofPi_ 2 on si increases as Pi_2Pi_I becomes greater than Pi-1Pi. The first assumption implies that when Pi_2Pi_I = Pi_lPi, Pi-2 gives the most appropriate information for determination of si2. Hence, the information is 'faithful'. The amount of information reduces as the difference between Pi_2Pi_I and Pi_lPi increases; the information can be measured by using angles 81,62,63 and 64 in Figure 2. The second assumption shows the more straightforward effect of Pi-2 on si_ 2 . In this situation, the effect increases monotonicly as Pi_2Pi_I becomes greater than Pi-~ Pi. Therefore two quantities can be defined on Pi-2, as follows. A 'faithfulness' of Pi_~ = min 'effectiveness' of

[61,6211[(61 + 62)12]

Figure 3. A computer output o f interpolating curves applied to the first example. Twelve data points (+) are on a plane. Interpolation is carried out by using cubic splines.

P;_2 :/\621(61 + 62)

As these variables are defined on the basis of the radius Ci_IPi, 0 < 51 and 0 < 62; and the quantities'faithfulness' and 'effectiveness' take values between zero and one. Therefore, w/1 can be defined as the product of these quantities multiplied by a: w i l = 2(~62 min [61,62lI(61 +62) 2 The wi3 can be formed following the same process: Wi3 = 2c~64 min [63, 64 ]//(63 + 64) 2

A new constant c~ is introduced to compensate for the magnitudes of w i l and wi3 as compared to wi2. The numerical calculations show that ~=0.5, if wi2 is set to unit value. Local calculations to determine tangent lines at m data pointsare now possible by using wil~ (h=1,2,3; i=I , 2 , . . . ,m); they are adjacent tangent lines which compose the CT depicted in Figure I.

Figure 4. Same as Figure 3. Here, the B~zier curves are used in each data interval, c=O. 1 is assumed in this Figure.

APPLICATION First, 12 data points were selected for the comparison of the proposed method with the cubic spline method. Figures 3 and 4 show results by the cubic spline method and the proposed method, respectively. The value o f c was set to be 0.1 in Figure 4; curve segments are straighter than those in Figure 3. Another example is a torus in 3D space. The mathematical representation of this object is: xii = [g- h • COS(27Ti/L)] COS (27filM) .vii = [ g - h .

cos(27ri/L ) ] sin (2Trj/M)

(5)

zii = h • sin(21ri/L ) i = 1 , 2 , . . . , L; j = l , 2 , . . . M g = 7.5, h = 3.0, L = 8 and M = 16 are assumed in the numerical calculation; 128 ( 8 x 16 ) data points are given in 2D space by projecting the data points of equation (5) onto a 2D perspective plane. Two such planes, separated from each other by the Jistance between the human eyes, can produce a stereoscopic effect because of binocular disparity 6 . Hence, the interpolating curve of the torus described in equation (5) can be assessed from the following two points of view:

volume 14 number I january 1982

\ • •

visual content in 2D plane visual content in stereoscopic view

The first criterion is the more usual one in data interpolation. The second is a new criterion that has seldom been used in this field. Figures 5 and 6 depict the interpolating curves that are obtained b y the usual cubic splines and by the proposed method, respectively. These figures show that the proposed method is superior to the cubic spline method according to both criteria.

CONCLUSIONS A method of applying B6zier curves to the data interpolation problem was proposed. Four computer outputs (Figures 3,4, S and 6) indicate that the proposal in this paper is promising, and that it can eliminate unpleasant undulations in interpolating curves. Further studies should include the following actions: • increase the order of interpolating curve described by equation (4)

57

k

'~'\1

Figure 5. A computer output o f interpolating curves appfied to the second example. 128 data points are on a 2D perspective plane, at points o f intersections o f curves. Interpolation

is carried out by using cubic splines. Two images can be used for obtaining a stereoscopic effect.

..>C\Ii i[: 'a"

t

<,' 7 /

--lJ \

~--L

I I /

/

_/.-*:. I

, i

5 ....-../ "- ..... \

,

!, .

'%

i :

',~,

.

/

\.k-- ,, ~ ~

/

,--

: r--. ~ /'+<-----/,,Tb<---<..J,

,\

,

"f, , .v / : ><~/

~--tq ~-~

,~-: ~ ',, ',,"\"-~.M~ ~o I i/ 7----i, , '~ )',~'~r/'~ 1,:' ".~-~-,~.~ I J_~J~: - 'k--~_lJ~?'

.OY /

.M-<,"/ "-~

t

7---

'7"I

_:~

Figure 6. Same as Figure 5. Here, the Bdzier curves are used in each data interval, c=O. I is assumed in this Figure.

• •

determine thevalue ofc depending on the shape of the CT improve the algorithm to derive the CT

There is a limit on the first action because the higher the order, the more time is required for calculations. There is an interesting aspect to the second action: selecting the value of c depending on the length of interval between adjacent data points. The existence of this parameter is one of the outstanding features of our method. There exist many local procedures for data interpolation, but they include no control parameter. Akima's method 7 is one famous example of this. The interpolant by his method is a little bit too straight, whereas our method can produce a more rounded interpolant by increasing the value ofc. The investigation of the optimal choice of this parameter requires further work. Improving the algorithm to derive the CT is a common problem, as most of the calculation time is used in this process. Efficient algorithms for deriving tangent lines will enable our method to use on-line representations of complicated objects in the future.

B-spline curves for CAD' Comput. Aided Des. Vol 12 No 5 (September 1980) pp 235 238 2 Dold, A and Eckmann, B Smoothing techniques for curve estimation Springer Verlag, Berlin (1979) 3 Rogers, D F and Adams, J A Mathematical elements for computer graphics McGraw-Hill, New York, NY, USA (1976) 4 Fritsch, F N and Carson, R E 'Monotone piecewise cubic interpolation' SIAM 1. Num. Anal. Vol 17 (]980) pp 2 3 8 - 2 4 6 5 Harada, K and Nakamae, E 'Local curve fitting procedures using cubic splines' ]. Inst. Electron. Comm. Eng. ]apan (to appear)

6 0 k o s h i , T Three-dimensional imaging tehcniques Academic Press, New York, NY, USA (1976) 7 Akima, H 'A new method of interpolation and smooth curve fittings base on local procedures' ]. ACM Vol 17 No 4 (October 1970) pp 5 8 9 - 6 0 2

ACKNOWLEDGEMENTS The authors gratefully acknowledge the useful comments of the referees. Sincere thanks also go to T. Tanimoto for his skillful work on the Appendix.

REFERENCES I

58

Hartley, P J and Judd, C J 'Parametrization and shape of

APPENDIX This appendix discusses the monotonic property of equation (3). In the case N=3, equation (3) can be written as:

P(t) = Po + 6c (P3 - Po) t + 15c (P0 - P3) t2 + 20(P3 - Po)t 3 ÷ 15[(3 - 2c)Po + (3c - 4 ) P 3 + {1 -c)P6] t 4 + 6[(5c - 6)Po + (10 - 9c)P3 + (4c - 4)P6] t s

computer-aided design

+ [ ( 1 0 - 9c)Po + (18c - 20)P3 + (10- 9c)P6] t 6 (6) As the shapes of curves are free from underlying coordinate systems, we can choose the coordinates of Po, P3 and Po without loss of generality as follows: Po = (0,0) P3 = (X3, Ya) andP6 = (X6, 0) where 0 < X 3 < X 6 and 0 < Y3 are supposed. Then, the x and y components of the B6zier curve become:

x(t) = (g(t) + ch (t)) X3 + (d(t) + ce (t)) X6

(7)

(8)

=- 3(3t 6 - 8 t s + 5t 4)

d2y/dx 2 = (~_)~)1.~3,

k-=d2 xldt 2 ' ~=dxldt, (9)

Looking at the sign of the denominator is equation (9), we have that:

~.>0if0
~=G (t) xa+H (t)x 6 G(t) = 6(2t - 1)q (t, c) H ( t ) = 6 1 1 0 ( 1 - c ) t a(1 - t ) 2 + c ' t s]

(10)

q (t,O) ~ 0 q (t, 1) < 0

(11)

Therefore 0<~ t < l / 2 t=1/2

L<0

1/2 < t~
1/2 ~< t ~< 1. This concludes the proof. We can now investigate the sign of d2y/dx 2 by looking the sign of the numerator of equation (8). Let this numerator be Q(t,c), ie

Q(t,c)=180),/3 Y'6t 2 (1 -t 2 ) S (t,c) (17) where S(t,c) is a parabolic function of c. Let the coefficients ofc and c 2 be Wl (t) and w2 (t), respectively. It can be

w2(t)

:

t=~,~

L<0

~
(18)

Moreover,

(19)

s(t,1) <.o S(t,c) can be classified into three cases:

where q(t,c) is a linear function with respect to c and

I.~=,~

d

are given. Therefore, ~-- B l x (t) > 0 if0~
S(t,O) <. 0

The proof of this is as follows: by differentiating x(t) in equation (7), ,~ is given as:

G(t)

(15)

shown that w 2 (t) =0 has two real roots (say ~ and 3'; ~<7) in 0 ~< t~< 1. The sign of w2(t) is: ~__>O 0~
The second derivative o f y with respect to x is given by:

~=d2y/dt 2 , fJ=dy/dt

u=l-t

(16) This equation can be simply described by using the coordinates of Pa and P6 as follows:

where = - 2 0 ( t 6 - 3 t 5 + 3 t 4 - t 3) = 3(6t 6 - 18t s + 15t" - 5t 2 + 2t) = 10t 6 - 24t s + 15t 4

d-td a,x(t) :_~_d B 2 x ( 1 - t ) = ~ B 2 x ( U ) ,

O (t,c)=.~.~-~

y(t) = (g(t) + ch (t)) Ya g(t) h(t) d(t) e(t)

Hence

(12)

• 0~
Wl (t)

2.,2 (t)

(20)

can be given. Easy calculation gives

H(t) >~0

(13)

where the equality holds when (c,t) = (c,O) or (0,1). Equations (12) and (1 3) show that ~'>0, if 0<::c~<1 and O~
Blx(t) + a2x(1 - t) = X6

volume 14 number 1 january 1982

Here

w, (t)/2

(14)

+ .,2

(t) > 0

(21)

can be shown. The inequality w 2 (t) > 0 and (21) show that D > 1. These three classes show thatS (t,c) <~ if 0 ~< t ~< 1 and 0 ~
59