Tweak wall cutting, removes inverse walls
This commit is contained in:
@@ -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 #-}
|
||||
|
||||
Reference in New Issue
Block a user