Wow, that is quite an extensive answer. One I wish I could fully comprehend.
With the help of a good friend, we were able to come up with a solution that looks like this:
Code:
function checkLineCollision(x1,y1,x2,y2, circlex, circley, circler)
for n=0,1,0.001 do
local x = x1 + ((x2 - x1) * n)
local y = y1 + ((y2 - y1) * n)
local dist = math.sqrt((x - circlex)^2 + (y - circley)^2)
if(dist <= circler) then return true end
end
end
It divides the line into a hundred points and checks each of those points to see if the distance from the point lower than the radius of the circle. It's not optimal, but there will never be more than one line to check, and probably less than 5 circles to check, so it should be fast enough.
Bookmarks