Smooth out slime splitting

There are probably possible errors from the use of cutPoly
This commit is contained in:
2026-05-08 23:44:28 +01:00
parent 34d8425520
commit 12e4a278d0
10 changed files with 243 additions and 204 deletions
+7 -1
View File
@@ -188,7 +188,7 @@ grahamEliminate (x : y : z : xs)
| not $ isLHS x y z = grahamEliminate (x : z : xs)
grahamEliminate xs = xs
-- this isn't the centroid of the polygon...
-- not sure what definition of centroid is applicable here
centroid :: (Num (f a),Functor f, Fractional a,Foldable t) => t (f a) -> f a
centroid = L.fold $ (^/) <$> L.Fold (+) 0 id <*> L.genericLength
@@ -234,9 +234,15 @@ cutPolyR a b [] e x ls rs = case intersectSegLine x e a b of
Nothing -> (reverse ls,reverse rs)
Just p -> (reverse (p\:ls), reverse (p\:rs))
polyInPoly :: Point2 -> [Point2] -> [Point2] -> [Point2]
polyInPoly p ps = mapMaybe f
where
f q = intersectRayPoly p q ps
infixr 5 \:
(\:) :: Eq a => a -> [a] -> [a]
(\:) x (y:ys)
| x /= y = x:y:ys
| otherwise = y:ys
(\:) x [] = [x]