I didn't find this anywhere on this forum, so here you go; find the point of intersection of two 2D lines. I can't make it any simpler than this.
function LinearIntersection(line11x#, line11y#, line12x#, line12y#, line21x#, line21y#, line22x#, line22y#)
X# = line11x# + (((line22x#-line21x#)*(line11y#-line21y#)-(line22y#-line21y#)*(line11x#-line21x#))/((line22y#-line21y#)*(line12x#-line11x#)-(line22x#-line21x#)*(line12y#-line11y#)))*(line12x#-line11x#)
Y# = line11y# + (((line22x#-line21x#)*(line11y#-line21y#)-(line22y#-line21y#)*(line11x#-line21x#))/((line22y#-line21y#)*(line12x#-line11x#)-(line22x#-line21x#)*(line12y#-line11y#)))*(line12y#-line11y#)
endfunction
To make it work you must have X# and Y# global... or put it into a dll and use some "Get_Intersection_X()," "Get_Intersection_Y()" functions. Enjoy.
[EDIT]
or have two different functions and call them seperatly:
`find x
function LinearIntersectionX(line11x#, line11y#, line12x#, line12y#, line21x#, line21y#, line22x#, line22y#)
X# = line11x# + (((line22x#-line21x#)*(line11y#-line21y#)-(line22y#-line21y#)*(line11x#-line21x#))/((line22y#-line21y#)*(line12x#-line11x#)-(line22x#-line21x#)*(line12y#-line11y#)))*(line12x#-line11x#)
endfunction X#
`find y
function LinearIntersectionY(line11x#, line11y#, line12x#, line12y#, line21x#, line21y#, line22x#, line22y#)
Y# = line11y# + (((line22x#-line21x#)*(line11y#-line21y#)-(line22y#-line21y#)*(line11x#-line21x#))/((line22y#-line21y#)*(line12x#-line11x#)-(line22x#-line21x#)*(line12y#-line11y#)))*(line12y#-line11y#)
endfunction Y#