Let's say that a line segment
intersects (or touches) a line
if
and
have at least one point in
common, and, more specially, that
crosses
if
and
are not on
but some other point of
is on
.
Similarly, one line segment could intersect or cross another
line segment. Thus, intersecting is a little more general
than crossing. In this discussion, let's concentrate on
crossing and then see what changes are necessary to handle
intersecting. There are different cases, depending on
whether we're dealing with lines or line segments and
depending on how they are expressed. Two cases are the most
important:
Case 1. Does a line segment
cross a line
expressed in the relational form
, and if so, where?
This case is the most useful and also the easiest.
Method.
crosses
if
and
are nonzero and of opposite signs. To
find the crossing point
, let
and then let
. See Figure
.
Explanation: The key is to observe that if you
follow the line segment from to
, the value
of
changes at a constant rate. So, for example, if
and
, then since
,
ought to be
of the way from
to
, i.e.,
. The
is the change in value from
to
divided by the change from
to
, i.e.,
.
Case 2. Do line segments
and
cross each other, and if so, where?
Method: Use the method of Case 1 both ways
around:
should cross the line containing
and
, and vice versa. For each of the two
lines, you can use the two-point relational form.
In other words, if the segments are
and
, find all four of
,
,
, and
. The line segments cross each other when
all four of these numbers are nonzero, the first two have
opposite signs, and the last two have opposite signs. If
they do cross each other, the crossing point is
, where
. See Figure
.
Note. It is not enough just to check that, say,
crosses the line containing
and
. That can happen even if the two line segments are each
an inch long but are a mile from one other. A less extreme
example is shown in Figure
.
What if we are interested in intersecting instead of
just crossing, for the case of two line segments
,
? The answer is that the
circumstances will always be clear from the values of
,
,
,
and
, provided not all four of these
numbers are zero. For example, if
,
,
,
, then
intersects
at
, somewhere between
and
.
If all four of the values are zero,
then
all lie on one line, and a different
method is needed: Look at the
-coordinates
,
,
,
or at the
-coordinates
,
,
,
to see the situation. For example, if
, then
is contained
entirely in
. (Which should you use, the
-coordinates or the
-coordinates? A good
choice is to use whichever are the more spread out. The
``spread'' of the
-coordinates is the maximum of the
four
-coordinates minus their minimum, and similarly
for the ``spread'' of the
-coordinates; check which is
the greater.)