Function RayIntersect(ax#,ay#,bx#,by#,cx#,cy#,dx#,dy#,rx# Var, ry# Var) Local u_b# = (dy - cy) * (bx - ax) - (dx - cx) * (by - ay) If ( u_b <> 0 ) Local ua_t# = (dx - cx) * (ay - cy) - (dy - cy) * (ax - cx) Local ub_t# = (bx - ax) * (ay - cy) - (by - ay) * (ax - cx) Local ua# = ua_t / u_b Local ub# = ub_t / u_b If ( 0 <= ua And ua <= 1 And 0 <= ub And ub <= 1 ) rx# = ax + ua * (bx - ax) ry# = ay + ua * (by - ay) Return True EndIf EndIf EndFunction
rx# and ry# are the points of intersection