Fix bug when forming convex hull of game room bounds
This commit is contained in:
+6
-1
@@ -121,6 +121,10 @@ orderPolygonAround
|
||||
orderPolygonAround _ [] = []
|
||||
orderPolygonAround cen ps = sortOn (\p -> argV (p -.- cen)) ps
|
||||
|
||||
orderAroundFirstReverse :: [Point2] -> [Point2]
|
||||
orderAroundFirstReverse [] = []
|
||||
orderAroundFirstReverse (a:as) = a : reverse (orderPolygonAround a as)
|
||||
|
||||
orderAroundFirst :: [Point2] -> [Point2]
|
||||
orderAroundFirst [] = []
|
||||
orderAroundFirst (a:as) = a : orderPolygonAround a as
|
||||
@@ -141,8 +145,9 @@ convexHull :: [Point2] -> [Point2]
|
||||
convexHull (x:y:z:xs) = grahamScan $ orderAroundFirst $ sortOn (\(V2 a b) -> (b,a)) (x:y:z:xs)
|
||||
convexHull _ = error "Tried to create the convex hull of two or fewer points"
|
||||
-- | Creates the convex hull of a set of points.
|
||||
-- it appears that the output may NOT be ordered
|
||||
-- assumes no repetition of points: try nubbing!
|
||||
convexHullSafe :: [Point2] -> [Point2]
|
||||
--convexHullSafe (x:y:z:xs) = grahamScan $ orderAroundFirst $ sortOn (\(V2 a b) -> (b,a)) (x:y:z:xs)
|
||||
convexHullSafe (x:y:z:xs) = grahamScan $ orderAroundFirst $ sortOn (\(V2 a b) -> (b,a)) (x:y:z:xs)
|
||||
convexHullSafe _ = []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user