Click to See Complete Forum and Search --> : line segments intersect
dogfish227
Mar 12th, 2003, 04:01 PM
is this right equation to find wether 2 line segments intersect where
ab and cd are the segments
r=((ay-cy)(dx-cx)-)ax-cx)(dy-cy))/((ay-cy)(bx-ax)-(ax-cx)(by-ay))
s=((ay-cy)(bx-ax)-(ax-cx)(by-ay))/((bx-ax)(dy-cy)-(by-ay)(dx-cx))
and they intersect where r and s are >=0 and <=1
thanxs
dogfish227
Mar 12th, 2003, 04:29 PM
also in both these equation if the denomator turns out to be 0 are the lines not intersecting??
sql_lall
Mar 12th, 2003, 10:52 PM
I'm not exactly sure what the a,b,c...etc are, but i factorised them and found:
r=((ay-cy)(dx-cx)-(ax-cx)(dy-cy))/((ay-cy)(bx-ax)-(ax-cx)(by-ay))
=(xy(a-c)(d-c)-xy(a-c)(d-c))/(xy(a-c)(b-a)-xy(a-c)(b-a))
=((a-c)(d-c)-(a-c)(d-c))/((a-c)(b-a)-(a-c)(b-a))
=((d-c)-(d-c))/((b-a)-(b-a))
=0/0 = undefined.
Spooner
Mar 13th, 2003, 01:01 AM
I don't think he means terms like 'ay' to mean a*y; I think he means the y value of point a, ie ay.
If I have a chance I'll check the equations and respond later. Mathworld (http://mathworld.wolfram.com/Line-LineIntersection.html) gives a solution using matrices.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.