By Daniel · January 12, 2009
Tests whether the line (NOT line segment) running from (x1, y1) to (x2, y2) intersects the line running from (x3, y3) to (x4, y4).
/* line_intersects_line(x1, y1, x2, y2, x3, y3, x4, y4)
*
* Tests whether the line (NOT line segment) running from (x1, y1) to
* (x2, y2) intersects the line running from (x3, y3) to (x4, y4).
*
* The .13974 was added to prevent division by zero errors without having
* to do extensive condition checking.
*/
return (argument0 - argument2) / (argument1 - argument3 + .13974)
!= (argument4 - argument6) / (argument5 - argument7 + .13974)
|| (argument0 - argument2) / (argument1 - argument3 + .13974)
== (argument0 - argument4) / (argument1 - argument5 + .13974);
Categories: Geometry, Mathematics
There are no comments to display.
You must be signed in to post comments.