Here's how it works. The script checks for a collision between two lines through the line segments of x1,y1 to x2,y2 and x3,y3 to x4,y4. The script then returns the x and y chords of the intersection between those two lines.

Remember that a line continues infinitely in either direction, and this script checks

*lines*not

*line segments*. This means that it can return a intersection beyond the lengths of the line segments given in the arguments.

There are two scripts, one returning the x choord, the other returning the y. They both take the exact same arguments.

**The script also assumes there is a collision.**So this will not work for parallel or coinciding lines. Well, at least they're untested. The scripts are not meant to check

*if*there is a collision, but rather

*where*the collision happens.

linelineintersection_x()

/* LineLineIntersection_X(x1,y1,x2,y2,x3,y3,x4,y4) Calculates the x coordinate of the intersection point of two lines from x1,y1 to x2,y2 and x3,y3 to x4,y4 This script assumes that there is an intersection, and the lines are not parallel or coinciding. Remember that a line extends infinetly in either direction, unlike a line segment. So this script will treat the segments given in the arguments as lines, so even if there would be no intersection between the segments, this script will still return an intersection between the lines. */ return ((argument0*argument3-argument1*argument2)*(argument4-argument6)-(argument0-argument2)*(argument4*argument7-argument5*argument6))/((argument0-argument2)*(argument5-argument7)-(argument1-argument3)*(argument4-argument6))linelineintersection_y()

/* LineLineIntersection_Y(x1,y1,x2,y2,x3,y3,x4,y4) Calculates the y coordinate of the intersection point of two lines from x1,y1 to x2,y2 and x3,y3 to x4,y4 This script assumes that there is an intersection, and the lines are not parallel or coinciding. Remember that a line extends infinetly in either direction, unlike a line segment. So this script will treat the segments given in the arguments as lines, so even if there would be no intersection between the segments, this script will still return an intersection between the lines. */ return ((argument0*argument3-argument1*argument2)*(argument5-argument7)-(argument1-argument3)*(argument4*argument7-argument5*argument6))/((argument0-argument2)*(argument5-argument7)-(argument1-argument3)*(argument4-argument6))

Hope someone finds a use for them

~Zach