Recursive algorithms for the representation of parametric curves and surfaces L Piegl Recursive algorithms for the representation o f parametric curves and surfaces are presented which are based upon a geometric property of the de Casteljau algorithm. The algorithms work with triangular and pyramidal arrays that provide an easy handling o f the curve and the surface 'in a large' design.
was found by de Casteljau 3 (see Figure I):
pf+ 1 (t) = (1 - t)pr(t)
r=O,...,n-1
i=O,...,n-r-1
with pO (t) = Pi" Then
Bernstein-Bezier method, curve and surface design, recursion
P(t) = pn(t) .
Parametric curves and surfaces form an essential part of computer-aided design. Schemes for defining these entities have evolved which employ a wide range of mathematical sophistication. The basic aim is to enable the designer to create curves and surfaces which behave as he wants them to. The Bezier method I is a powerful tool for this purpose that is capable of representing most of the geometric entities of practical interest. The author has recently proposed a generalization of this technique ~ in an attempt to increase the conformity between the curve and the polygon and between the surface and the net. While generalized curves and surfaces are useful for many purposes (eg local manipulations and approximation effects can be produced) the resemblance to the shape of the polygon or to the net as well as the value of the local and global manipulations cannot be enhanced without limitation. This paper examines generalized curves from the standpoint of the de Casteljau algorithm and the geometric principle behind this algorithm is used to develop another one for the representation of parametric curves. An extension to surfaces is also considered and is achieved in a purely geometric manner.
THE DE CASTELJAU A L G O R I T H M
(4)
For a theoretical development and background see Lane and Riesenfeld4. Let us focus our attention on a geometric property of equation (3). The construction of P (t), for a fixed yet arbitrary t, uses the points P7 (t) (i = 0 , . . . , n -2) as the points of the parabolas B/+ 2 (Pi, Pi+ 1, Pi+ 2 ; t) defined by the points in the brackets. Similarly, the points P~(t) (i= 0 , . . . , n - a ) are on Bf +2 (P~, P~+I, P~+2;t), etc. This observation suggests that equation (3) can be written in the following form (see also Figure 2): r+l
Pi (t)=B;
"+2
r
r
(Pi,Pi+I,
r=O,...,k-1
pr
(5)
i+2;t);
i=O,...,n-2(r+l)
ff
1
P,
The simplest algorithm for the generation of the non-
(,)
rational Bezier curve n
P(Po,...,Pn;t)=
(3)
+ t P f i l (t) ;
Y.
¢i(t)Pi,
tE[0,1],
(1)
i=0
¢i(t)=(n)ti(1-t) n-i,
-", i=0,1
n
Angewandte Geometrie und Geometrische EDV, Technische Universit~it Braunschweig, FRG
volume 17 number 5 june 1985
(2)
PO Figure I. The de Casteljau algorithm
0010-4485/85[050225-05 $03.00 © 1985 Butterworth & Co (Publishers) Ltd
225
where
pr+l(t ): B/+2(pr n
k:
INT( ~ ) a n d P °
: Pi, i : 0 , . . . , n .
r=O,...,k i = 0,...,
Then if n is even P (t) = Po# (t)
(6)
,
Pi+l,
pr
. r
1+2,ci+1;
t)
(13)
;
-1 n - 2 ( r + 1)
where k and pO are the same as in equation (5). Then if n is even
otherwise P(t) = Po#(t) P(t) = (1 - t) Pok (t) + tP~ (t).
Clearly, the calculations of the intermediate points of equation (3) are contained in algorithm (5) also. However, equation (5) has a geometric peculiarity that makes it suitable for further purposes.
ALGORITHM
otherwise using the curve obtained by equation (12) we have P(t) = Bo2 (Po# (t), , P1# (t); 1; t).
FOR C U R V E S
n -2
i=0
Pn; Cl
....
j=O,...,k [el
, C n _ l ; t)
--i+2 ~i(t) Bi (Pi, Pi+I, Pi+2; Ci+l; t)
(8)
B(+2 / (Pi, Pi+ 1, Pi+2; Ci+l '"t)
(9)
with w i = wi+ 2 = 1 and wi+ 1 = 1 - ci+ 1 where ci+ 1 is a certain double ratio s . It is clear that equation (9) has only one degree of freedom, ieci+ 1 . Its geometric meaning shows that the condition for avoiding singularities is ci+ ] < 2 ( w i + 1 > - 1)
-1
]
(16) i= l,...,n-2j-1
~i+2 where - i are rational conic segments
2 ~, w i + j P i + j ~ / ( t ) j=0 2 Wi+/¢/(t) j=0
(15)
For further purposes let us denote the curve generated by equation (13) by P(Po. . . . , Pn; c / ; t), where c/denotes the triangular array:
The generalized Bezier curve 2 has been defined as follows:
P(Po . . . . .
(14)
(7)
(lO)
This array can effectively be used for shape modification that can be divided into levels from 0 up to k-1. Figures 3 - 6 illustrate this curve design as the array fills up from level by level. The extra degrees of freedom inherent to the definition Can be exploited to obtain, say, a large pulling (see Figure 7) or other diverse and practical shapes. In some practical applications it is desirable to have a tight conformity between the polygon and the curve. The curve of equation (8) is not capable of satisfying this requirement as it tends to a Bezier curve of order n-2 as all the cio tend to -oo. This limit curve can be removed by using c] and the curve obtained by equation (13) will be bounded by another Bezier curve of order n-4. This can also be removed by ci 2 etc. That is, the curve P(P0, • • •, Pn; c / ; t) tends to the polygon as all the c i ] tend to -oo. Since these weights are constants, the conformity can be enhanced without increasing the cost of computing. An important feature of the Bezier scheme is the convex hull property. Since the restriction of equation (11 ) ensures that the conics of equation (9) are contained within PiPi+I Pi+2, the curve obtained through equation (13) also
and the restriction ci+ 1 ~<1 (wi+ 1 9 0 )
(11)
ensures that equation (9) satisfies the convex hull property. It is worth mentioning here that the entire spectrum of conic arcs can be covered by ci+i, eg the (double) line PiPi+2 is obtained by setting ci+ I = I : ~i+2[- , (1 - t ) 2 P i + t 2 P i + 2 i ,l'i, P i + 2 ; 1 ; t ) = I -2t(1 - t )
(12)
The space between Pi and Pi+2 means that this 'curve' is independent of Pi+I • Note that from a mathematical point of view equation (12) is a conic as the point spacing along PiPi+2 is not uniform. We have shown that equation (8) suffers from the limitation of a Bezier curve defined by PI, • • • , Pn-1 • This drawback can be avoided if we replace the parabolas in equation (5) by the conics in equation (9). Then equation (5) becomes
226
e
po Figure 2. A rearranged form o f the de Casteljau algorithm
computer-aided design
I
/ Figure 3. A basic curve obtained by setting aft c Ji = 0
Figure 4. c o = - 2 0 while the rest are 0
Figure 5. The zero and the first levels are filled by -20
Figure 6. The whole array is filled by -20
I
I Figure 7. Pull effect: c~ = c~ = cg = -20, the rest are 0
satisfies this property, as all the conics lie within the convex hull of Po . . . . , Pn. Nevertheless, if only the condition of equation (10) is applied then one can generate more diverse curve shapes than would be useful for practical purposes. In this case, however, care has to be taken since the curve may run out of the specified domain.
where it is assumed that m/> n, Ri+2,j+2 -ij denote biquadratic Bezier patches, # = INT(n/2) and P~ = Pij, i = 0 , . . . , n ; j = O , . . . ,m. Then ifn is even P(u, v) = P(P0ko(U),..., P#o,m-n(U); v)
(21)
otherwise
EXTENSION TO SURFACES
P(u, v) = (1 _ u)P(Po#o(u), . . . ,Po, # m-n+l(U);V)
The de Casteljau algorithm can be applied for the generation of a point on the tensor product Bezier surface n m P(u,v) = % ~; Pij~i(u) i=0 /=0
L~j(V)
(17)
First one definesm+l Bezier points: Pj(u) =
n ~ Pi/~i(u), i=0
j=0 ..... m
(18)
+ uP(P~,o(U) , . . . ,
# P,,m-n+l (u); v)
(22)
For a proof it is sufficient to refer to Figure 8 and to note that the point P (u, v) belongs to the hyperbolic paraboloid spanned by the warped quadrilateral ABCD. In the previous part the algorithm used needed rational conic segments. This suggests that for a surface representation algorithm it would be suitable to use rational quadric patches:
and then m
P(u,v) = ]C P/(u)~i(v). j=0
(19)
This algorithm can be written in the following form: P;i +1 (u, v) = -;+2'J+2/p ~ij ~-ij,
• •
., Pi+2, j+2; u, v)
(20)
r = 0 . . . . ,#-1 i = 0, . . . , n - 2 ( r + 1) j=0,...,m-2(r+l)
volume 17 number 5 june 1985
Figure 8. Generation of a ooint on the tensor product Bezier surface
227
. Bi+2,/+2 ii (P;+p,/+q'wi+n,/+q {n~°'1'2 q=0, I,2 2
where w 6 : wi+2, / : wi, i+ 2 = wi+2,/+2 ::: I and it ~.alq be shown s that the other- weights have simi;.~E geometmic mean-
"u,v)
'
ing as w/+ I above, eg w / + l , / - I - el+ I, i wh. ~ ~/+ 1 / i> a certain cross-ratio. Furthermore, the restrictions
2
p=Oq=O 2
Wi+p, i+q Pi+p,/+q~p (U) Cq (v) ~
p=O
(23)
2
Cj;j+l,Ci+l,j',Ci+l,i+2,Ci+2,/+
I ~2 (24)
Wi+p,j+q~Jp(U)~Jq(V)
q=O
Ci+l,j+ 1 "~4-
c4 i+1 +Ci+l'j+Ci+l'j+2-+-C-/+~2-'/~-l-
/
2
Figure 9. The control network o f an arbitrary surface patch
Figure 10. The basic surface obtained by setting all cijh = 0
Figure 11. Example modifying the basic surface: the first row o f the zero level is filled by -20, the rest are 0
Figure 12. The first and the second rows are filled by - 2 0
Figure 13. The first three rows are filled
Figure 14. The zero level is entirely filled by -20: the elements o f the first level are still chosen as 0
Figure 15. c ~1 = - 2 0 0 ,
Figure 16. c l m = c' 12
Figure 17. Local control: c~2 = - 2 0 while the rest are 0
c~2 = 0
and c ~ = - 20
=
-200
while c ~ = - 2 0
ensure that singularities do not occur and if all the ciis are less than or equal to 1 then equation (23) satisfies the convex hull property. Now, if we use rational quadric patches then algorithm (20) becomes: p.r.+l (u, v) = - R i + 2 ' j + 2 l p r .r P = O ' I ' 2 ; U , V); I d ~ij ~'i+p,J+q'Ci+P, j + q Iq=0,1,2
(2s) Figure 18. M o d i f i e d local control: c°2 = c~1 = - 2 0 and the remaining elements are 0
228
r=0,...
,k-1
i =0 .....
n-2(r+l)
j =0 .....
m-2(r+
1)
computer-aided design
0
where # and Pij are the same as in equation (20):. Then i f n
is even
p(.,
(pok,o(u),
=
k m_n(u);d s ; Po,
...,
v)
the control array introduced, allows the designer to create more diverse and practical surface shapes or in other words, it makes him capable of describing surfaces 'in the large'.
(26) CONCLUSIONS
t
where d s is a triangular array t = 0,...,
t
INT ( ( m - n ) / 2 )
- 1
[ ds ]
(27) s = 1,...
,m-n-2t
- 1
Otherwise P(u, v) = Bo2 (P (Pok,o (u) . . . .
(pk, o(u),
k m-n
• .. , PI,
+1
# m - n + l ( u ) ; e sot ; v ) , , , Po,
(u) ; es ; v);
1 ; U)
(28)
where
t=0,...,INT(
]
)-1
m-n+1 2
(i=o, 1)
(29)
s=l,...,m-n-2t
We have presented recursive algorithms for the representation of parametric curves and surfaces. The algorithms simply rely on conic segments and quadric patches and work with triangular and pyramidal arrays, respectively. The development uses a rearranged form of the de Casteljau algorithm. The designing process is divided into levels which could help the designer to create curves and surfaces for special practical requirements. Instead of subdividing a curve or a surface into parts the paper investigates a way to treat them as a whole and the control arrays introduced provide a useful guide for this purpose. It is important to note that the constructions are invariant under perspective transformations. The reason for this is that the algorithms use rational curves and surfaces that are invariant under perspective transformations.
ACKNOWLEDGEMENTS The author is grateful to Professor W B6hm for his sugges-
The algorithm co n;rains &pyramidal array: h=0,...,#-I h
[ cij ]
i :0,...,n-2h-1
(30)
j =0,...,m-2h-1 t
it
and one or two triangular ones ds or es . These arrays can be used to modify the shape of the surface. In Figure 9 a control network can be seen that generates a basic surface if all the weights are nought (see Figure 10). The change in shape of this surface is demonstrated through the examples of Figures 1 1 - 1 6 as the array fills up from row by row at each level. Figures 17-18 show two pull effects. Observe that the boundary curve is also transformed if the highest level is used too. The restrictions of equation (24) ensure that the surface obtained by equation (25) does not suffer from singularities and if all the weights are less than or equal to 1 then the surface satisfies the convex hull property. We should finally note that algorithm (25), compared to the Bezier surface generation algorithm, requires an enlarged number of items of input information, however,
volume 17 number 5 june 1985
tion of investigating the generalization of the BernsteinBezier method from the standpoint of the de Casteljau algorithm. This paper was revised while the author was supported by the Alexander yon Humboldt Foundation.
REFERENCES 1 Bezier, P E Numerical control - mathematics and applications, John Wiley and Sons (1972) 2 Piegl, L 'A generalization of the Bernstein-Bezier method' Comput.-Aided Des. Vol 16 No 4 (July 1984) pp 209-215 3 de Casteljau, P Courbes et surfaces a poles S A Andre Citroen, Paris (1959) 4 Lane, l M and Riesenfeld, R F 'A theoretical development for the computer generation and display of piecewise polynomial surfaces' IEEE Trans PAMI Vol PAMI-2 No 1 (1980) pp 3 5 - 4 6 5 Piegl, L 'Representation of quadric primitives by rational polynomials' to appear in Barnhill, R E and B~ihm, W (eds) Surfaces in CA GD, North-Holland, Amsterdam
229