Commit before attempting to allow for non-convex chasm shapes

This commit is contained in:
2025-10-05 15:06:19 +01:00
parent b3924fb8b8
commit 43db5a2ebc
25 changed files with 333 additions and 303 deletions
+13
View File
@@ -80,11 +80,24 @@ pointInOrOnPolygon _ _ = undefined
{- | Test whether a point is strictly inside a polygon.
Supposes the points in the polygon are listed in anticlockwise order.
Requires that the polygon is convex.
-}
pointInPoly :: Point2 -> [Point2] -> Bool
pointInPoly !p (x : xs) = all (\l -> uncurry isLHS l p) $ zip (x : xs) (xs ++ [x])
pointInPoly _ [] = False
inSimplePoly :: Point2 -> [Point2] -> Bool
inSimplePoly p (x:xs) = foldl' (flip f) True $ zip (x:xs) (xs ++ [x])
where
f (a,b) = case intersectSegRay a b p (p + V2 1 0) of
Nothing -> id
Just {} -> not
inSimplePoly _ [] = False
---- implement Dan Sunday point in polygon algorithm?
--wnPointPoly :: Point2 -> Point2 -> Point2 -> Int
--wnPointPoly p x y = 0
circInPolygon :: Point2 -> Float -> [Point2] -> Bool
circInPolygon !p !r (x : xs) = all f $ zip (x : xs) (xs ++ [x])
where