-
line segments intersect
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
-
also in both these equation if the denomator turns out to be 0 are the lines not intersecting??
-
Factorise??
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.
-
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 gives a solution using matrices.