Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Intersecting Lines

1 view
Skip to first unread message

p...@quartic.com

unread,
Feb 27, 1997, 3:00:00 AM2/27/97
to p...@quartic.com

Given to lines with the endpoints (x1, y1), (x2,y2) - what is the formula
to tell if the two lines intersect assuming the slopes of each line are
not the same ?

-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet

Vincent Johns

unread,
Feb 28, 1997, 3:00:00 AM2/28/97
to p...@quartic.com

(posted & emailed)

p...@quartic.com wrote:
>
> Given to lines with the endpoints (x1, y1), (x2,y2) - what is the formula
> to tell if the two lines intersect assuming the slopes of each line are
> not the same ?

I assume that those are the endpoints of only the first line segment;
if they're the same for both, the two segments are in the same place
(and have the same slope), and they intersect.

Let's say that the second line segment goes from point 3, at (x3, y3),
to point 4, at (x4, y4).

Then you can find a linear equation for the line going through points 1
(that's at (x1, y1)) and 2, and one for the line going through 3 and 4.

For example, assuming points 1 and 2 are in different places, the first
equation might be something like (x - x1)/(y - y1) = (x2 - x1)/(y2 -
y1).
If y1 = y2, this won't work; turn both fractions upside down if that
happens.

Find a common solution for the two equations. If the slopes are
different,
that solution should be a single point. If its x-coordinate is between
x1 and x2, and is also between x3 and x4, it lies on both line segments.
Exception: If x1 = x2 or x3 = x4, you will also need to test the
y-coordinate
for that line segment.

It's probably possible to express all this as a formula, but such
a formula would (I think) be more complex than you want to deal
with and involve some non-algebraic functions such as step
functions.

--

-- Vincent Johns

Please feel free to quote anything I say here.

David Tanenbaum

unread,
Mar 1, 1997, 3:00:00 AM3/1/97
to

On Thu, 27 Feb 1997 22:22:20 -0600, p...@quartic.com wrote:

>Given to lines with the endpoints (x1, y1), (x2,y2) - what is the formula
>to tell if the two lines intersect assuming the slopes of each line are
>not the same ?
>

>-------------------==== Posted via Deja News ====-----------------------
> http://www.dejanews.com/ Search, Read, Post to Usenet

Pat -
If the slopes of the two llines are different, then by
definition, they *must* intersect. Given the ordered-pair coordinates
for two (or any number of lines for that matter) lines, simply
determine the slopes --- if they are not identical, then they will
intersect. The formula for which you search is that for the slopes:
(y1 - y2)/(x1 - x2) = m

Rich Vento

unread,
Mar 1, 1997, 3:00:00 AM3/1/97
to

In article <8571032...@dejanews.com>,
p...@quartic.com wrote:

>Given to lines with the endpoints (x1, y1), (x2,y2) - what is the formula
>to tell if the two lines intersect assuming the slopes of each line are
>not the same ?
>
>-------------------==== Posted via Deja News ====-----------------------
> http://www.dejanews.com/ Search, Read, Post to Usenet

If these lines point emanate from the origin in 2-space (normal Cartesian
plane space)then it is obvious that they intersect in the origin.

But that is not what you really want. SOOO you need to specify two (2) start
points and two(2)end points. In geometry you learned that a straignt line is
determined by 2 distinct points.

So, here's how to proceed:
1. A line in the plane is determined by a point on the line, P1, plus some scalar
multiple of the direction vector of that line: L1 = {P1 + t1* V1},
similarly for L2.

2. Find two point on each line and write the vector equations as shown in (1).

3. The vector V1 is found by (x2,y2) - (x1,y1) for the line L1

4. The vector V2 is found by (x4,y4) - (x3,y3) for the line L2

5. Solve the line equations for either of the points known to be on that
particular line. NOTE, this will give you the scalars t1, t2.

6. Now equate P1 + t1*V1 = P2 + t2*V2

ta daa,

Rich


Mike Housky

unread,
Mar 3, 1997, 3:00:00 AM3/3/97
to p...@quartic.com

[mailed, and posted to alt.algebra.help]

p...@quartic.com wrote:
>
> Given to lines with the endpoints (x1, y1), (x2,y2) - what is the formula
> to tell if the two lines intersect assuming the slopes of each line are
> not the same ?

The lines ALWAYS intersect if the slopes are not the same.

To find out where, use the point-slope formula [y-y0 = m(x-x0), where (x0,y0)
is a point on the line and m is the slope] to construct an equation for each
line and solve the simultaneous equation system that results.

y-y1 = m1(x-x1) = m1.x - m1.x1
y-y2 = m2(x-x2) = m2.x - m2.x2

...leads to:

-m1.x + y = y1 - m1.x1
-m2.x + y = y2 - m2.x2

This is easily solved. If you have problems, pipe up. There's lots of help here.

Cheers,
Mike.

Lee Jaap

unread,
Mar 4, 1997, 3:00:00 AM3/4/97
to

[posted and emailed to pat]

In article <331B8C...@webworldinc.com> Mike Housky <mi...@webworldinc.com> writes:

|>[mailed, and posted to alt.algebra.help]
|>
|>p...@quartic.com wrote:
|>>
|>> Given to lines with the endpoints (x1, y1), (x2,y2) - what is the formula
|>> to tell if the two lines intersect assuming the slopes of each line are
|>> not the same ?
|>
|>The lines ALWAYS intersect if the slopes are not the same.

But "lines" don't have endpoints. And segments (which have endpoints)
do not always cross even if their slopes are different.

But, to solve this problem, two more points are needed, since
each segment has _two_ endpoints.
--
J Lee Jaap <Jaa...@ASMSun.LaRC.NASA.Gov> +1 757/865-7093
employed by, not necessarily speaking for,
AS&M Inc, Hampton VA 23666-1340

0 new messages