[quote name='luca-deltodesco' timestamp='1323137238' post='4890946']
If you take the two line segments as rays (a + tu) and (b + sv) for t,s in [0,1] (aka given line x1 to x2, the ray is x1 + t(x2-x1)) then you can compute:
I'm having a little trouble visualizing your variables. Would it be too much trouble to request a diagram?
[/quote]
http://i.imgur.com/gfeeh.png
line segments defiend by the points a,b and vectors u,v such that the end points are a + u, and b + v and any point on the two line segments can be defined by a + tu, b + tv where u,v [font="sans-serif"]in [0,1][/font]
[font="sans-serif"]To find t, we search the point a + tu, such that (a+tu-b) perpdot v = 0. perpdot is 0 when two vectors are parallel, so looking at the diagram, the perpdot is zero when the red point is at the intersection of the infinite lines containing the segments, where the blue vector is parallel with 'v'.[/font]
[font="sans-serif"]
[/font]
[font="sans-serif"]Working it the other way, you get the value for s in b + sv for the intersection, and by checking both t,s are in [0,1] you know the intersection occurs on the line segments <=> the line segments intersect[/font]