From 6909ea5d4e74d45c5a54fab48cf749628db5ef52 Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Fri, 30 Nov 2018 17:39:52 -0800 Subject: [PATCH] Delete intersect.lua. That was specific to exo-encounter and is unlikely to be useful in other games. --- lib/intersect.lua | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 lib/intersect.lua diff --git a/lib/intersect.lua b/lib/intersect.lua deleted file mode 100644 index 10ad856..0000000 --- a/lib/intersect.lua +++ /dev/null @@ -1,15 +0,0 @@ --- https://love2d.org/wiki/General_math -return function(l1p1x,l1p1y, l1p2x,l1p2y, l2p1x,l2p1y, l2p2x,l2p2y) - local a1,b1,a2,b2 = l1p2y-l1p1y, l1p1x-l1p2x, l2p2y-l2p1y, l2p1x-l2p2x - local c1,c2 = a1*l1p1x+b1*l1p1y, a2*l2p1x+b2*l2p1y - local det,x,y = a1*b2 - a2*b1 - if det==0 then return false, "The lines are parallel." end - x,y = (b2*c1-b1*c2)/det, (a1*c2-a2*c1)/det - if not (math.min(l1p1x,l1p2x) <= x and x <= math.max(l1p1x,l1p2x) and - math.min(l1p1y,l1p2y) <= y and y <= math.max(l1p1y,l1p2y)) or - not (math.min(l2p1x,l2p2x) <= x and x <= math.max(l2p1x,l2p2x) and - math.min(l2p1y,l2p2y) <= y and y <= math.max(l2p1y,l2p2y)) then - return false, "The lines don't intersect." - end - return x,y -end