C¢,mput & Graphits Vol. 8. NO. 2. pp. 177-182. 1984 Printed in the U.S.A.
~
0097-8493/84 $3.00+.00 1984 Pergamon Press Ltd.
Technical Section
D E F I N I N G C ~ C U R V E S C O N T A I N I N G CONIC S E G M E N T S L. PIEGL Technical University of Budapest, P.O. Box 91, Budapest 1502, Hungary. (Received 6 February 1984)
Al~tmet--In computer graphics the problem of defining a curve may often be regarded as the problem of constructing a transformation. This transformation takes an interval in the parameter line into some curve usually in 2-D or 3-D. In this paper a quadratic transformation is proposed which is defined purely by means of geometric data and a double ratio. The shape and the type of the curve depend on the value of the double ratio and the entire spectrum of conic arcs can continuously be covered by changing this value. An interactive curve design is considered and an extension to higher order curve construction is suggested.
INTRODUCTION
In computer graphics the conic sections forms predominate. This is because they are the lowest degree curves, their geometric properties are well known and they are medial curves [7], i.e. "midpoint" algorithms are useful to plot any of their segments. There is an increasing need to be able to specify a general conic arc between two points in a reliable way. For example, in mechanical drafting quadratic curve constructions may often be needed. By a reliable way we mean the following requirements: - - T h e representation should be well conditioned for computation. --Since the straight line is a special ease of a general conic arc, the representation should be capable of including special cases without embarrassment. - - T h e representation should not be sensitive to the type of conic. We now seek a method for defining a general conic arc under the following assumptions appropriate to computer graphics: - - T h e arcs containing asymptotes should be avoided. - - T h e arcs should be defined purely by means of geometric data, points and slopes. - - T h e method should be concerned with the shapes rather than the types of arcs. The case of the circular arc has been well covered by Sabin[l], using the bulge-factor notation. An extension of this method has been treated by Gossling[2], using the shear-and squash-factor notation for general conic arcs. Liming[3] has described how the theory of pencils of conics can easily be used to define a general conic segment by four points: the two points of tangency, the intersection of the tangents and some fourth point, known as the shoulder point. Faux and Pratt[4] have dealt with the parametrization of a conic segment given by Liming's method. Ball[5] has defined a general conic arc as a special case of the rational cubic segment which is determined by four points Vt, V2, V3, V4 and four weights w~, w2, w3, w4. If 177
V2 = V3 and w2 = w3 then the resulting curve is a conic. Ahuja and Coons[8] and Forrest[6] have derived a general conic by transforming the "primitive" parabola: x---u 2 y=u,
u~[--oo, oo].
The purpose of this paper is to describe a method which derives a general conic arc by a quadratic transformation using an appropriate parabola as basic curve. The transformation is defined purely by means of geometric data, has purely geometric meaning and enables us to extend the method to interactive curve design.
REPRESENTATION OF THE GENERAL CONIC ARC
A convenient method for defining a general conic arc is the following: consider a triangle P~P2P3. The conic arc will start at P~ and terminate at P3. At Pt it will be tangent to PIP2 and at P3 it will be tangent to P2P3. We distinguish two cases: the tangents are parallel or not. (1) The tangents are not parallel In this case the triangle P1P2P3 is not degenerate and determines a parabolic arc between PI and P3 (Fig. 1.). Other conic sections are underdetermined, they will, however, become determined by adding a constant factor it which defines a quadratic transformation in the following manner: let S be an arbitrary point on P~P3. Denote the intersection of the parabola and P2S by M. Consider the S--*S~ correspondence, where S~ satisfies the following condition: (P2, M, S, S~) = X, where (P2, M, S, S~) denotes the double ratio of the four points P2, M, S, Sin. It is evident that S~ will draw a curve while S travels from Pt to P3. Now we plan to describe this curve in a somewhat simplistic way.
178
L. PmGL which takes the line segment PiP3 into the curve Ca(s). This curve has all the properties important for defining a general conic arc under the mentioned requirements. It is immediately clear that Ca(0) -- P~, Ca(l) = P3, C~(0) = 2(1 - 2)(P2 - Pt), C'~(I) = 2(1 - 2)(P3 - P2) and Co(s) is the parabolic arc. Since the transformation holds the double ratio, the arc (6) is contained within the triangle P1P2P3 provided an arbitrary point St is chosen inside the triangle, i.e. the curve (6) has no unwanted asymptotes. The value of 2 determines the n u m b e r of infinite points and the shape of the curve as well. We may call it the conic shape factor[6]. It is easy to see, by virtue of (6), that the arc has infinite point(s) if
g
o, Fig. 1.
2 = (2s(l -- s ) ) - I
The vectors S and M can be expressed as follows: S -- (1 - u ) P I + u P 3 ,
(1) (2)
M = (1 - w ) S + w P 2,
M = (1 -- s)2pt 4- 2s(l -- $)P2 4- $2P3.
(3)
Substituting (1) into (2) and comparing (2) and (3) we have: $2
u =
w = 2s(1 - s). 1 - 2s(l - s)
(4)
If St = (1 - t)S + tP2 then by virtue of (2) St can be expressed with M and P2:
St=l__
1 --t M+ w
w -tp ~
2'
(5)
1 - 0.5~
0.5 l
S-l_
W
w M+
w_l
This means that the value of 2 defines the type of conic section:
P2.
Since 0P2, M, S, SO = 2, thus t ~
w(2 - l) 2w - 1 "
Substituting t into (5) and taking (1), (2) and (4) into consideration, we have
1 - 22s(1 - s)
[(1 - $ ) 2 p t + 2(1 - 2 ) s ( 1 - s ) P 2 + $ 2P3],
for fixed sE[0, 1]. If s varies from 0 to 1, Si will draw a curve segment having equation: G(s)
---2 = 1: the arc is independent of P~ and merely the line segment joining Pt and P3 - - 2 = - ~ : the arc is a special case of the hyperbola consisting of the semi-infinite line segment starting at Pt and passing through P2 and the semi-infinite line segment through P2 terminating at P3. Further inspection shows that i r a conic segment cuts the line P2S at S~ and (P2, M, S, S~) = ~, furthermore denoting the second intersection point of the whole conic section and P2S by S~, then (P2, M, S; S~) = X' holds for ~,'
Similarly,
S 1 ~---
The function 2(s) = (2s(1 - s ) ) - 1 takes its m i n i m u m value at s --0.5 which is 2 = 2. If 2 < 2 then no infinite point will occur, there is one infinite point if 2 = 2 and two infinite points can be found if 2 > 2. Taking 2 into consideration two special cases require particular attention:
1 1 -- 23.s(1 -- s)L( lr
8)2p I
+ 2(1 -- 2)s(1 -- s)P2 + s2P3], so=[0, 1].
(6)
We have constructed a quadratic transformation
- - 2 = 0 - . 2 ' = 2 : one infinite point will occur, the curve is a parabola. ---0 < ~, < I --. 1 < ~,' < 2: no infinite point will occur, the curve is an ellipse. --)~ < 0 - . ~,' > 2: two infinite points will occur, the curve is a hyperbola. Note that if 0 < 2 < 1 then 2' may be used to define a second arc to complete the closed curve (Fig. 2.). In Fig. 3, piecewise quadratic curves can be seen, the conic shape factors have been specified within - 3 and 1. (2) The tangents are parallel The eqn (6) describes a general conic arc only when the tangents at Pt and P~ are not parallel, i.e. P2 is a finite point. This is because in the case of parallel tangents the basic parabola does not exist because the line at infinity is tangential to the parabola and three tangents to a second order curve from an infinite point cannot be drawn. Forrest[6] has derived a
Defining C 1 C ~
containing conic segments
179
curves can be defined conveniently for computation. In the previous part the transformation used needed a basic curve and a double ratio. Now, since P2 is an infinite point, it is convenient to use the single ratio (St, M , S ) instead of the double one (P2, M, S, S~). If (St, M, S) = ~ then S~ can be expressed as follows:
M
9
St = (1 + 2 ) S - 2 M .
(7)
Since M and S are finite points, S~ will also be a finite point for finite 2, i.e. if M moves along an ellipse, St will sweep an ellipse too. Now we deal with the basic curve. If in the triangle PtP~P3 the line PtP 3 is perpendicular to PtP~ ° and P~P3, then a semi-circle with diameter P~P3 is the most simple basic curve. If this is not so, then a simple basic curve can be defined by a shear of this curve segment (Fig. 4). The parametric form of such a curve segment is given by Gossling[2]:
Fig. 2.
2820p, q- P3 -- Pro) q- s ( 2 P . - 3P~ - P3) -t- Pt C(s) =
2s 2 - 2s + 1
s~[O, II, (8)
Fig. 3. parametric form for such curves but the form is without the conic shape factor. This is the point where we should mention that the theorems of projective or other geometries, although the designer need know nothing about them, are of great use for defining a general conic arc. Namely, if the tangents are parallel, there are a pencil of ellipses which are defined by the degenerate triangle PtP~:P3 and a constant factor. Here we want to show how such
where P#, is the apexpoint of the elliptic arc (Fig. 4. makes this clear). Simple substitutions show that C(0) = P~, C(1) = P3, C(0.5) = Pro, C'(0) = 2Pro - P1 -- P3, C'(0) -- Pl + P3 - 2Pro. The image of the point I'm, reflected by the centre 0.5(Pt + P3), may be used to define a second arc to complete the closed curve (denote this point by px). The parametrization in (8) is generated by considering a point T which moves uniformly along the chord P)P3 and M is the projection of this point from W, onto the arc. Let S be the projection of M from P~ onto the chord P~P3. We need to know how S varies along Pt P3 to use the transformation. It is expedient to suppose that the following is valid:
T
s--fo(s)P~ +A(s)P,,
\
Fig. 4.
(9)
180
L. PIEGL
where the functions f0 andf~ must obey the conditions l
fo(s) + f , ( s ) = !
II III
f ( J ) = fi0 f0(0.5) =f~(0.5) = 0.5.
Furthermore the points M and S must comply with the f o l l o w i n g c o n d i t i o n :
IV
M -- S = ~ ( 2 P ~ -- PI - P 3 ) -
The condition IV implies the form of the functions and simple calculations show that s 2 -- 2s + 1 s2 f0(s) = 2s 2 _ 2s + I f~(s) = 2s 2 _ 2s + 1" (10) By virtue of (7)-(10) we can write the parametric form of a general conic segment:
C~(s) =
itself to be applied recursively, i.e. to achieve the correspondences Si--.Si+ ~ for i = 0, 1. . . . , N, where So travels uniformly along P~P3. However, a simple consideration shows that the corresponding curve segment of a conic arc Ca(s) is another conic arc
PI[(I - X)s" + (X - 2)s + 1] + P3[(I - h)s" + ~s] + P,.I2L~(s - 1)] , 2 S 2 - - 2s + 1
It is easy to see that Co(s) describes the chord PIP3 and C_ ~(s) the original basic curve. Observe that this case of our transformation is a degenerate case, i.e. it is linear. Although the point S moves along P)P3, it draws a degenerate second order curve as the eqns (9) and (10) clearly show. In spite of this, the transformation and thus the form (11) are convenient to describe an arbitrary elliptic arc between P~ and P3 having parallel tangents at these points given by the point P,,. In Fig. 5, some piecewise elliptic curves can be seen, the 2 parameter has varied between - 2 and 0.5. The Fig. 6. shows some "mixed" curves containing elliptic and other conic segments. Finally, we should note that this transformation permits us to construct higher order curves in a reliable way. The transformation immediately offers //
/
Fig. 6.
//
/
s~[0, 1].
(11)
Ca.(s) containing a new conic shape factor 2*. So the correspondences mentioned for i = 1, 2 . . . . do not yield higher order curves and this redundancy is clearly to be avoided. Nevertheless, there is an attractive way to gain higher order curves which derives from the choice of 2. We have supposed thoughout this paper that 2 is constant. If, however, we choose it as a function of the parameter s, then the resulting curve will be different from the conic arc. A third and some fourth order curves, together with the original parabola, are shown in the examples of Fig. 7(a, b). In Fig. 7(a) ;t is chosen as 2(s) = s and the Fig. 7(b) shows some fourth order curves with ~(s) = As(l - s), where A equals 1,2,3 and 4, respectively. Since the function 2(s), usually bounded from above by 1, is chosen by the user, the method will not lose control over the curve to be designed.
/
EXTENSION TO INTERACTIVE DESIGN
////
Now it turns out that an extremely simple interactive technique can be found to describe C ~ curves containing conic segments. Let the parabola be defined by the triangle ~ P ~ : ~ and choose an arbitrary conic arc CA(s) with some 2 (Fig. 8.). The tangent to the parabola at M and the tangent to the curve CA(s) at S O meet on the line P ~ 3 . These tangents meet the line P~2P~3at R and P2) , respectively. Using the theorems of projective geometry, we have: (P(~:, R, P~3, P~) -- ~. Since R = (1 - s ) ~ + s ~ ,
the point P~ can be expressed as Fig. 5.
I~' = (l - w ) ~
+ w~,
(12)
Defining C ~ curves containing conic segments
181
point S ° on this curve to begin the piecewise curve with the conic arc p~,0. The tangent at S o can be used to compose a new triangle P~P~P~, where Pi = S °, P~ is defined by (12) and 1~3= P~. This triangle is used to repeat the procedure until the remaining conic segment, defined by some P~P~P~, is suitable to close the curve to ~ . It is evident that the described curve has two degrees of freedom, i.e. we can modify the shape of the curve by the points S~ and by the parameters ,l~. The Figs. 9(a--c) show three piecewise
/
(A)
/
/
/
/
\,
/ (B) Fig. 7. po
P3= P3
\',!,\
Fig. 8.
"\\
where S W
~(s - 1) + 1"
Now we can use (12) to obtain an interactive technique which is implemented as follows: if for any point M the parabolic arc P~M is not suitable to start the curve, then the user may select another conic arc C~(s) with some ~ and may choose an appropriate
\ ,
(c) Fig. 9.
L. PIEGL
182
Fig. 10.
curves with one degree of freedom containing four segments in each curve. The 2 values have been chosen in advance as - 3, 0.6, - 3, 0.3 and the shape has been modified by the points S~ for i = 1, 2, 3. The case of parallel tangents requires particular attention. The point R does not move uniformly along the line ~ ® ~ (Fig. 8.), so we cannot calculate it as simply as in the previous case. If, however, we regard the following identities R=M+aM' R - P~ = / 3 ( 2 P , , - P~ - P~3) = BY, where M' is the tangent vector to the parabola at M, then after a simple calculation we have Od ~
V × (M - P~) M'×V
where, for example, M ' x V denotes the vector product of M ' and V. If R is already known then P~ can be expressed by
S ° ~ and ~ may compose a very large triangle. The Fig. 10. illustrates such a case where the curve almost runs out of the domain we specified. In passing we only mention that the technique can be used for approximation of a given curve by conic segments. This has disadvantages and advantages. One of the disadvantages appears when the curve, to be approximated, has inflexion points. In this case it has to be divided into segments which have no points of inflexion. Nevertheless, the method has a practical advantage: the curve can be built up from segment to segment, i.e. the whole curve must not be regenerated for better approximation of a given curve. CONCLUSION
The curve construction developed above provides an easy handling of piecewise quadratic curves given by points, slopes and shape factors. The treatment encompasses both the cases of parallel and n o n parallel tangents. Particular attention is drawn to the problem of avoiding unwanted asymptotes and controlling the shape of the curve. An extention to the interactive design is considered and a suggestion for higher order curve representation is mentioned. Acknowledgement--The author is grateful to Dr. J. Hatvany for his valuable comments on the first draft of this paper. REFERENCES 1. M. A. Sabin, Use of piecewise forms for numerical representation of shape. Reports 60, Computer and 2.
3. 4.
P~ = (1 + X)P~ - XR 5. and the procedure can be continued as stated above. While in the case of triangle-bounded curves all the segments are contained within the triangle 1 ~ [ ~ 3 , in the case of parallel tangents the user has to be careful to define the second segment. This is because the tangent to the end of the first segment and the lines
6. 7. 8.
Automation Institute, Hungarian Academy of Sciences (1977). T . H . Gossling, Bulge, shear and squash: a representation for the general conic arc. CAD 13, 81-84 (1981). R. A. Liming, Practical Analitical Geometry with Applications to Aircraft. MacMiilian, New York (1944). I. D. Faux and M. J. Pratt, Computational Geometryfor Design and Manufacture. Ellis Horwood, Chichester (1979). A. A. Ball, CONSURF Part 1: Introduction of the conic lofting tile. CAD 6, 243-249 (1974). A. R. Forrest, The twisted cubic curve: a CAGD approach CAD 12, 165-172 (1980). R. J. BoRing, A theory of parametric curve plotting. CUIP 7, 139-145 (1978). D. V. Ahuja and S. A. Coons, Geometry for construction and display IBM Syst. J. 7, 188-205 (1968).