Smooth out slime splitting
There are probably possible errors from the use of cutPoly
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user