Work on detecting floor items near analyser

This commit is contained in:
2025-09-08 11:37:08 +01:00
parent f278af0f30
commit 203919933c
9 changed files with 25 additions and 26 deletions
+3 -10
View File
@@ -11,7 +11,7 @@ module Geometry.ConvexPoly (
-- , centroid
pointsToPoly,
convexPolysOverlap,
pointInPolyPoints,
-- pointInPolyPoints,
) where
import Control.Lens
@@ -59,18 +59,11 @@ convexPolysOverlap cp1 cp2 =
-- | Test whether two polygons intersect or if one is contained in the other.
polyPointsOverlap :: [Point2] -> [Point2] -> Bool
polyPointsOverlap (p : ps) (q : qs) =
pointInPolyPoints p (q : qs)
|| pointInPolyPoints q (p : ps)
pointInPolygon p (q : qs)
|| pointInPolygon q (p : ps)
|| polyPointsIntersect (p : ps) (q : qs)
polyPointsOverlap _ _ = False
{- | Test whether a point is strictly inside a polygon.
Supposes the points in the polygon are listed in anticlockwise order.
-}
pointInPolyPoints :: Point2 -> [Point2] -> Bool
pointInPolyPoints !p (x : xs) = all (\l -> uncurry isLHS l p) $ zip (x : xs) (xs ++ [x])
pointInPolyPoints _ [] = False
polyPointsIntersect :: [Point2] -> [Point2] -> Bool
polyPointsIntersect (a : b : xs) ps = go a (a : b : xs) ps
where