Commit before attempting to allow for non-convex chasm shapes
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user