Hello
I am using RUCCUS code for line intersecting. I get right coordinates for lines intersecting when line 1 is exactly horizontal coming from left or right. I have 8 direction movement. I do get a line intersect true from the other directions but not the right coordinates :-(
It is intX# and intY# that is not coming out right :-P Can anybody with math skills help out?
FUNCTION intersectLines(x1#,y1#,x2#,y2#,x3#,y3#,x4#,y4#)
denominator# = ((y4# - y3#)*(x2# - x1#)) - ((x4# - x3#)*(y2# - y1#))
`If denominator = 0, then the lines are parallel
IF denominator# <> 0
numerator# = ((x4# - x3#)*(y1# - y3#)) - ((y4# - y3#)*(x1# - x3#))
uA# = numerator# / denominator#
numerator# = ((x2# - x1#)*(y1# - y3#)) - ((y2# - y1#)*(x1# - x3#))
uB# = numerator# / denominator#
`Calculate the point of intersection and store it
`Remove these 2 lines if you're sure you wont need the
`x/y coordinate of intersection.
intX# = x1# + (uA#*(x2# - x1#))
intY# = y1# + (uB#*(y2# - y1#))
`If uA and uB > 0 and < 1 then an intersection occured
IF (uA# > 0) AND (uA# < 1) AND (uB# > 0) AND (uB# < 1)
collision = 1
ELSE
collision = 0
ENDIF
ELSE
collision = 0
ENDIF
ENDFUNCTION collision
The byte chrunchers are coming...
DIVIDING BY ZERO/BECAUSE WE SUCK...