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
View File
@@ -4,6 +4,7 @@
{- Testing for and finding intersection points. -}
module Geometry.Intersect where
import Data.Monoid
import Data.List (sortOn)
import Control.Applicative
import Control.Lens
@@ -272,6 +273,12 @@ intersectLinePoly a b (p:ps) = sortOn (dotV (b - a))
$ zipWith (\x y -> intersectSegLine x y a b) (p:ps) (ps ++[p])
intersectLinePoly _ _ [] = error "intersectLinePoly empty polygon"
intersectRayPoly :: Point2 -> Point2 -> [Point2] -> Maybe Point2
intersectRayPoly a b (p:ps) = getFirst . mconcat $ zipWith f (p:ps) (ps++[p])
where
f x y = First $ intersectSegRay x y a b
intersectRayPoly _ _ _ = error "intersectRayPoly: polygon too small"
{- | Given a line and a point return the point on the line closest to the
point.