You are on page 1of 7

Computer-Aided Design, Vol. 27. No. 1, pp.

41-47, 1995
Copyright 0 1895 Ekevier Science Ltd
Printed in Great Britain. All rights reeerved
cm@-l4&s/g5 510.00+0.00

Common tangents to planar


parametric curves:
a geometric solution
Laxmi Parida and S P Mudur*

The task of determining common tangent lines to a pair (or


by convenient circumscribing polygons. The polygonal
more) of parametric curves has important applications in
envelope computation of regions requires the computation
of tangent lines. In particular, if the regions are
draughting systems, enveloping polygon computation, bin-
nonconvex, construction of lines tangential to more than
packing and compaction problems, and a host of other
one boundary curve piece is very useful (see Figure I).
areas. In the paper, an efficient and robust algorithm to detect
Construction of common tangent lines to curves is a
all common tangent lines between a pair of planar parametric
quick and straightforward solution to silhouette com-
curves has been presented. The algorithm uses a geometric
putation in the line drawing renderings of 3D mechanical
search on the curves, and, by quickly rejecting large portions
objects (it is typically used for hard copy devices such as
that are not likely to have a common tangent, it rapidly zeros
pen driven plotters). Consider, for example, a linearly
in on the solution. The aigorithm has been implemented on an
swept surface obtained from a linearly varying closed
IBM-compatible PC, and it works fast enough for realtime
cross-section with its boundary specified by parametric
interactive use.
curves. Under isometric projection, cross-sections con-
tinue to be parametric curves and the silhouettes are
Keywords: planar cubits, parametric curves, divide-and-conquer
straight lines tangential to these cross-sections.
paradigm
We have also encountered the use of common tangent
lines to parametric curves in the high-level boundary
evaluation of swept objects’, used as part of a font design
Detecting common tangent lines to pairs of curves is a
system Vinyas2,3 based on the brush trajectory approach4.
widely necessary task at a fundamental level in a variety
In the high-level boundary evaluation method, the
of geometric applications such as draughting systems,
boundary is obtained by tracing the endpoints of the pen
polygonal envelope constructions and silhouette com-
(i.e. the object being swept). However, there is trouble
putations. Most draughting systems support basic
when the two boundaries cross over as shown in Figure
geometric primitives, such as lines, tonics, parametric
2. The common tangent line construction gives the correct
curves, that are defined in say the Hermite, Bezier or
boundary definition of the swept object. The reader may
B-spline form. These systems support geometric con-
note that the two boundaries, corresponding to each end
struction facilities for drawing tangents to tonics.
of the pen, are not necessarily translates of each other.
Usually, the designer resorts to circumlocutory methods
The pen may rotate as well as scale as it moves over the
to draw tangent lines to general parametric curves. The
contour path (see Figure 3). Reference 1 discusses in detail
curves are segmented unnaturally such that the foot of
the sweep of an object over a contour and the subsequent
the required tangent line is a junction point of two curve
evaluation of the boundary of such a region/volume
pieces. This process, apart from being nonintuitive and
description.
time consuming, also compromises design modifiability,
We believe that methods for detection of common
and significantly increases the size of the definition of the
tangents to parametric curves also have applications
design.
other than the ones mentioned above. The problem of
In the bin-packing and compaction problems, the sets
detecting tangents to circles/circular arcs has been
of objects to be packed are generally polygonal. If regions
adequately addressedsS6. However, we have not found
with curvilinear boundaries are used, they are represented
any references containing solutions to the case of
parametric curves. Further references to tangent line
Courant Institute of Mathematical Sciences, New York University, computation for tonics are cited in Reference 6.
251 Mercer Street, New York, NY 10012, USA
*National Centre for Software Technology, 9 Gulmohar Cross Road,
In this paper we present a robust and efficient
Juhu, Bombay 400 049, India algorithm for detecting the tangents to two planar curves
Paper received: 7 May 1993. Revised: 7 October 1993 defined in their parametric form. The algorithm uses a

Computer-Aided Design Volume 27 Number 1 January 1995 41


Common tangents to planar parametric curves: a geometric solution: L Parida and S P Mudur

tangents at F(u) and G(u) respectively. F, G are of degree


n, and F’, G’ are of degree n- 1; thus each equation is
of order n +(n - I) in two variables. The pair of equations
could possibly give rise to (2n - 1)2 different solutions.
For two cubic curves there are 25. However, as has been
seen in the case of common tangent lines to two circle@,
many of them could possibly be complex or might lie
outside the bounds of the given curve segments. The
number of tangent lines will therefore depend on the
actual shape characteristics of the two curves and their
relative configuration. By shape characteristics, we mean
Figure 1 Use of tangent line construction in computation of polygonal the number of maxima/minima and by relative configura-
envelopes for regions tion we mean spatial interference, the relative orientation
of the maxima/minima, and the linear separability of the
two curves. For example, two semicircular curve pieces
can have at most four common tangent lines.
Numerical methods could be used to solve these
equations. However numerical methods have several
drawbacks: a good starting solution is needed, robustness
is not guaranteed and finding all the solutions is not
always possible.
Another possibility is to subdivide the curve until we
get manageable linear pieces and then attempt to locate
the common tangents to the resulting polygons. However
the approximate solution obtained by this method is not
acceptable in most geometric design applications. In this
context, it may be mentioned that a blind scan or search
of the two curve pieces is equally ineffective.
Figure 2 Region defined as swept object (say the pen)
[The broken line denotes the contour path, and the solid line the
boundary. The heavy rule is the common tangent line. Notice that the
inclusion of the common tangent line yields the correct boundary
description.]
GEOMETRIC SEARCH FOR COMMON
TANGENTS

We present the algorithm for cubic curves in detail and


geometric search strategy and uses the divide and discuss the issues involved in extending it to higher order
conquer paradigm. Basically, given two bounded curves, curves. The first stage of the algorithm is to preprocess
a simple and fast method of detecting the absence of a the curves suitably.
common tangent is used to zero in to the subsegments
of the curves where the tangents are likely to lie. Also
the segmentation is so devised that a tangent line Preprocessing
falls exactly on either of the endpoints of the given
curve segments. This results in very high accuracy. We The preprocessing can be divided into two steps:
first present the algorithm and then discuss some
implementation strategies. l partitioning of the curve,
a reparameterization of each partitioned piece.

EQUATION FORMULATION

If F(u)=(F,(u), F,(u)), UE [uo, u,], and G(c)=(G,(c),


G,(u)), UE[C~, ~7~1,are the polynomials defining the two
curves, then the points at which there are common
tangents to the two curves are given by the values of U, I
which simultaneously satisfy Equations I and 2,

F,(u)- G,(a) =pF;(u)


(1)
F,(u) - G,(a) F:(u)

F,(u) - G,,(v)=--G;(c)
(2)
F,(u) - G,(c) G:(v)
Figure 3 Tangent lines to curves used in high level boundary
where F’ and G’ are obtained by differentiating once. extractlon of swept objects
Note that, for some u and u, the two equations state that [These are fonts from Indian scripts designed on Vinyas. The tangents
the line segment joining F(u) and G(Y) is along the are shown by heavy rules.]

42 Computer-Aided Design Volume 27 Number 1 January 1995


Common tangents to planar parametric curves: a geometric solution: L Parida and S P Mudur

Note that for a cubic the parametric value of the point


with a given tangent angle, say (dx, dy), can be determined
analytically by solving the quadratic equation given
below:

WF;(u)) = MW)) (3)

Also, the extremum points and inflection points can be


computed as solutions to quadratic and linear equations
respectively.

S Reparameterization of partitioned pieces


Figure 4 C-shaped curve and its bounding quadrilateral PQRS
Now, let F(u) and G(u) be the two trimmed pieces whose
[Alternatively, the curve is bounded by the triangles PQT and TRS.] common tangents we wish to detect. Reparameterize both
the pieces so that the parametric range for both is the
same, i.e. ZJE [uO, uJ and the tangent directions at u0 for
both the curves are identical+. It follows that the tangent
Partitioning of curve
directions at u1 are identical too.
Definition I: For a given bounded curve F(u), u E [uo, uJ,
&= CO,,O,] is defined as the included tangent angle Definition 3: If F(u) and G(u), u E [u,, u,], are two curve
range, where 8, is the minimum (or maximum) of the segments such that &= &, then let F’(u,)=ctG’(u,)
slope angle of all tangents to the bounded curve F(u), d2 where GIis some scalar. If CI< 0, then two curve segments
is the maximum (or minimum), and, for all 0~ [e,, e,], are said to be in opposite directions and if a>0 then
the curve has at least one point with that tangent angle. the curve segments are said to be in the same direction.

Definition 2: A bounded curve F(u), u E [u,, u,], is defined


to be a C-shaped curve if it satisfies the following Rejection criteria
conditions*:
We use two rejection criteria in the algorithm. The first
l II+Fll < % rejection criterion is for any pair of C-shaped curves. The
0 the tangent slope angle varies in a strictly monotonic second one is an added rejection criterion for an
manner as u varies from u0 to ul. oppositely directed pair of C-shaped curves with equal
tangent range.
The following properties of a C-shaped curve must be
noted:
Rejection criterion 1: The tangent lines at the two
l The minimum and maximum of the tangent angles endpoints and the C-shaped curve together divide the
occur at the endpoints. Euclidean plane into tangent-included and tangent-
l For any angle value, i.e. the slope given by say excluded zones (see Figure 5). In all further references,
(dx, dy), either there does not exist any point or there the two tangent excluded zones shown in Figure 5 are
exists exactly one point whose tangent angle is equal referred to as the upper zone and the lower zone. It is
to this value. clear that any C-shaped curve lying completely in the
l The convex quadrilateral bounding the C-shaped
curve is given by the quadrilateral formed by the two
end tangent directions and a tangent to the curve
parallel to the chord. Further, two disjoint triangles
enclosing the curve are also defined (see Figure 4).
In Figure 4, T corresponds to the point on the curve
where the tangent is parallel to the chord PS.

The partitioning of the curves is done as follows:

l Each curve is partitioned into C-shaped pieces. This


involves splitting the curve at the extremum points
and inflection points of the curves. All possible pairs
of curves are then formed for searching for common
tangent lines, It may be noted that, for quadratic
parametric curves, this step is not required.
l Let F and G be the two curves in a pair of C-shaped
curves resulting from Step 1. F and G are trimmed
so that they have a range of common tangents, i.e.
4F=db
Figure 5 C-shaped curve and its tangent excluded zones (tinted)

*Note that 11&1/= 110,-Q21/. As 0 and n denote the same angle (albeit +In our implementation, we carry out a linear reparameterization. This
in opposite directions), the maximum angle range permitted is strictly algorithm is independent of the reparameterization and works as long
less than A. as the tangent computation is correct.

Computer-Aided Design Volume 27 Number 1 January 1995 43


Common tangents to planar parametric curves: a geometric solution: L Parida and S P Mudur

determining whether a curve lies in the lower zone


we choose a slightly looser polygonally bounded zone
by taking the two chordal lines of the curve instead
of the curve. In Figure 4 these are the lines PT and
TS. Thus the zone is bounded by four linear segments.
l To check whether a curve lies in the upper or lower
zone of the other, we check for overlap between the
pair of triangles bounding the curve and the
polygonal zone which is again quite straightforward.

ALGORITHM

Before describing the algorithm, we give a brief description


of the different steps used in the algorithm.

Reject(C,,C,) is true if C,, C, satisfy either rejection


Figure 6 No common tangents by rejection criterion 2
criterion 1 or rejection criterion 2.
TerminationCondition(C,,CJ is true if II4,-,II =
lldkll zo.
OutputTungent(C,,C,) outputs the tangent line at uO
upper or lower zone of another curve cannot have a and/or u1 when the tangent lines are coincident.
common tangent with the latter. SolutionFound(C,,C,) is true if at either u,, or ur the
tangent lines are coincident.
Rejection criterion 2: For a pair of oppositely directed
TrimEndPoints(C,,CJ trims the endpoints of the
C-shaped curves F and G, with 4F = &, if at least one curve where the common tangent line was detected.
point of one curve lies in the lower zone of the other, For example, if a common tangent line was detected
there can be no common tangents (see Figure 6). at uO, then the trimmed curve is now defined over
the semiopen parametric domain (u,, UJ for further
The first rejection criterion is quite obvious and works processing.
for curves in the same directions as well as opposite
directions. The algorithm is as follows.
The second rejection criterion is based on the following
arguments. Given two C-shaped curves, F and G, with
4F=4G? Procedure CommonTangent(C,, C,: curves)
Preconditions: 1. Both the curves are C-shaped.
l A common tangent line does not cross either the
upper zone or the lower zone of any of the curves. 2. +c, = 40
l A common tangent line does not cross any of the if Reject(C,, C,) then no common tangent
curves. else
l Further, if F and G are oppositely directed, the if TerminationCondition(C,, C,) then
common tangent line is a separator line and the two begin
curves lie in the two distinct half planes of the if SolutionFound(C,, C,) then OutputTangent
common tangent line. (C,, C,)
end
Clearly, for a pair of oppositely directed curves, when a else
curve has at least one point in the lower zone of the other begin
curve, the separator line, if any, must pass through the if SolutionFound(C,, C,) then
lower zone. Hence there can be no common tangent line begin
by the first and third conditions above. OutputTungent(C,, C,)
TrimEndPoints(C,, C,)
end
Detection of tangent lines divide C, at T to get C,, and C,,
divide C, at a point where the tangent angle is
A common tangent exists at u=uO (or u=ur) if the same as that at T to get C,, and C,,
unbounded and undirected tangent lines at uO (or ul) of CommonTangent(C,,, C,,)
the two curve pieces are coincident. CommonTangent(C,,, C,,)
The following points may be noted: end

l Detection of the solution involves checking for


coincident unbounded lines, which is quite straight- Notice that the preconditions for the procedure are met
forward. in all the subsequent recursive calls.
l The upper zone is bounded by two straight lines. As the algorithm does a selective binary search on the
l The lower zone is bounded by two straight lines and curve segments, it does not miss any solution. As the
the curve. In order to simplify the computation of search is binary, it does further subdivisions of portions

44 Computer-Aided Design Volume 27 Number 1 January 1995


Common tangents to planar parametric curves: a geometric solution: L Parida and S P Mudur

tangent line with angle R +cr. It is convenient to define


an angle range where every angle has exactly one
representation. This range is [x, x + 7~), for some x,
0 Qx < II. Let us term this the normal range. Thus it
is always possible to map any angle to an angle in
the semiopen set [x, x + IC). A complete set of angles
4 can then be mapped to a subset of [x, X+X).
Clearly, the normal range will depend on the pair of
curve pieces at hand. The major advantage of such
a range is that we may now apply standard interval
/--\- (0,431- (lWl371
intersection techniques to obtain the common angle
range of two curves. The curves may be suitably
Figure 7 Angle range of tangents of C-shaped curve and split curves
after mapping to normal range [0,180) trimmed to have a common tangent angle range.
However, in some cases, a single curve may have to
be split to fit into the normal range. For example, if
that may have a tangent and picks up common tangents, the normal range for a pair is [0, a), a single range
if any. Further, since a geometric approach is used it is of angle [45, -431 say of one curve may have to be
also numerically stable. split into two subranges [45,0] and (180, 1373 (see
Figure 7)*.
The application of the rejection criteria and subsequent
EXTENSION TO HIGHER ORDER CURVES subdivision of the pieces in the implementation are
carried out as per the algorithm presented.
There are two steps in the algorithm which need special In principle, the rejection criteria should be checked
consideration when dealing with curves of higher order. after the preprocessing of the curves. However, in
practice, we have found that the application of rejection
l The first such step is subdividing a curve into criterion 1 to the C-shaped pieces, even before the
C-shaped segments. This is done by splitting at common tangent angle range has been computed, has
extremum points and inflection points of the curve. helped us to very quickly detect the absence of tangents
For curves of order up to 6 (5th degree), the in a large number of cases.
polynomial equations whose roots have to be Figure 8 shows the trace of the algorithm for a
determined are of a degree not higher than 4, and typical pair of curves and Figure 9 shows a number
hence can be solved analytically. For higher order
curves, however, other efficient methods have to be
devised. One possible solution is to carry out
parametric midpoint subdivision until all segments
are C-shaped. A curve segment could be checked for
being C-shaped by looking at the Bezier control
polygon. The variation diminishing and convex hull
properties of the Btzier curve imply that, if the Btzier
control polygon is C-shaped, the Btzier curve is also
guaranteed to be C-shaped. Of course, while robust-
ness is guaranteed the resulting number of segments
may be so many that the algorithm may not perform
as efficiently as for lower order curves.
l The second is determining a point on a C-shaped
curve that has a given tangent direction at that point.
Once again, while this is straightforward for lower
order curves, for higher order curves this could be
done quite efficiently using a simple binary search. (4

IMPLEMENTATION

The tangent line construction algorithm has been


implemented in PASCAL, on an IBM-compatible PC.
It is at the core of a font design system, Vinyas, which
uses a swept object model to implement the brush (4 (9
trajectory approach of defining strokes. The boundary
is defined by a sequence of BCzier curves and linear Figure 8 Trace of tangent detecting algorithm for single solution
configuration; (a) two input curves, (b) detection of common range of
segments. The typeface definition is produced in Type tangents, (c) rejected by first criterion, (d) rejected by first criterion,
3 Postscript format’. (e) after four subdivision levels, (fj common tangent line
The implementation of the common tangent range [Notice the quick rejection of large portions of the curve that are not
detection, in the partitioning stage of the preprocessing likely to yield results.]
step, needs a brief mention here. It may be noted that
the tangent line with angle c1 is coincident with the *Note that [45, -433 = [4X0] +(0, -431, and (0, -433 =(180, 1371.

Computer-Aided Design Volume 27 Number 1 January 1995 45


Common tangents to planar parametric curves: a geometric solution: L Parida and S P Mudur

Table 1 Processing times on IBM-compatible PC 286 for representative set of curve pairs

Number Preprocessing time Number of For each pair


for both curves, s partitioned pieces

Number of
tangent points Computation time, s

0.04 2. I I 0.450
0 0.088
0.09 3. 2 0 0.056
0 0.000
0 0.000
0 0.000
1 0.146
0 O.OOQ
3 0.04 I. 2 0 0.034
0 O.ooO
4 0.04 1
-.
7
- 0 0.042
0 O.OCMI
0 0.044
0 0.044
5 0.11 2. 2 0 0.044
0 0.000
0 0.044
0 0.000
6 0.04 I. 2 0.704
0 O.ooO
7 0.05 7 7
.-_ - 2 0.824
0 0.146
0.000
0.824
7 7 0.000
8 0.04 -. -
0.044
0.714
0.658
9 0.10 2. I 0.692
0.570
IO 0.09 2. 1 0.044
0.044
II 0.04 2. 2 0.044
0.012
0.044
0.000

[The samples were picked up as the end user carried out the design process on Vinyas, the font design system.]

of different unusual input curve pairs and the common


tangents detected by the algorithm.
Table I gives the preprocessing time, the number
of segments after initial partitioning for each curve, the
number of common tangent lines, and the computation
time of 11 pairs of representative input cubits.

CONCLUSIONS

The construction of common tangent lines to curves has


important applications in a variety of tasks such as
polygonal envelope constructions, silhouette computations
and a host of other areas. An algorithm to detect the
common tangent lines between two parametric curves
has been presented. This algorithm detects all the
tangents and is fast enough to give the results in realtime
on an IBM-compatible PC/AT for lower order curves.
This is primarily based on rejecting large portions of the
curves which are guaranteed not to include common
tangents. The rejection criteria are based on dividing up
the Euclidean space into zones which can and zones
which cannot include a common tangent. The algorithm
Figure 9 Results of tangent construction algorithm for some rather
has been built into a font design system which is based
unusual curve pieces
[The algorithm has yielded u/l possible common tangent lines to these on the pen-stroke model and computes resulting regions
curves. Notice that the first and the last pair give nonintuitive but with their boundaries defined by Bezier cubits and line
correct results.] segments.

46 Computer-Aided Design Volume 27 Number 1 January 1995


Common tangents to planar parametric curves: a geometric solution: L Parida and S P Mudur

ACKNOWLEDGEMENT Laxmi Parida has been active in the field


of computer graphics research and
The work described in this paper was carried out development for over eight years, and
when L Parida was at the National Centre for she has carried out substantial im-
plementations in the areas of font
Software Technology, Bombay, India.
design and geometric modelling. Her
research interests include computer-
aided geometric design, font design,
computational geometry and data visual-
REFERENCES ization. She received a master’s degree
in computer science from the University
of Bombay, India, in 1985.
Parida, L and Mudur, S P ‘Computational methods for evaluating
swept object boundaries’ Visual Comput. (to be published)
Parida, L ‘Vinyas users manual’ NCST TechnicalReport(Feb 1990)
Parida, L ‘Vinyas: an interactive calligraphic type design system’ S P Mudur is an associate director and
Proc. ICCG93: Int. Conf. Computer Graphics Bombay, India (1993) the head of the Graphics & CAD
Knuth, D ‘Mathematical typography’ Bull. Amer. Math. Sot. No Division of the National Centre for
1 (1979) Software Technology in Bombay, India.
Rogers, D F ‘Interactive graphics and numerical control’ He received a PhD in computer science
Comput.-Aided Des. Vol 12 No 5 (1980) from the University of Bombay in 1976.
Parida, L and Koparkar, P ‘A closed form solution to the problem He has been actively working in the field
of tangential circles, lines, points with extension of 3D’ Compur. of computer graphics since 1970. His
& Graph. Vol 15 No 1 (1991) interests include geometric modelling.
Postscript Language: Reference Manual Addison-Wesley, USA graphic arts and typesetting, image
(1985) processing and visualization techniques.
Koparkar, P and Mudur, S P ‘Computational techniques for
processing parametric surfaces’ Comput. Vision, Graph. & Image
Proc. Vol 28 No 3 (1984)

Computer-Aided Design Volume 27 Number 1 January 1995 47

You might also like