Tweak wall cutting, removes inverse walls

This commit is contained in:
jgk
2021-04-23 21:17:37 +02:00
parent 4c611ba4aa
commit 108b66f3ad
7 changed files with 289 additions and 121 deletions
+13
View File
@@ -164,6 +164,19 @@ orderPolygon ps = sortBy (compare `on` \p -> argV (p -.- cen)) ps
where
cen = 1/ fromIntegral (length ps) *.* foldr1 (+.+) ps
-- | Adds a point to a convex polygon.
-- If the point is inside, returns the original.
-- Points ordered anticlockwise, input not checked.
addPointPolygon :: Point2 -> [Point2] -> [Point2]
addPointPolygon p ps
| pointInOrOnPolygon p ps = ps
| otherwise = orderPolygon $ p : ps
-- | Creates the convex hull of a set of points.
convexHull :: [Point2] -> [Point2]
convexHull (x:y:z:xs) = foldr addPointPolygon (orderPolygon (x:y:z:[])) xs
convexHull _ = error "Tried to create the convex hull of two or less points"
-- | Return distance between two points.
dist :: Point2 -> Point2 -> Float
{-# INLINE dist #-}