ALGO: use isInsidePoly

This commit is contained in:
hasufell 2015-01-09 03:20:13 +01:00
parent 5b092715aa
commit c96474e6fd
No known key found for this signature in database
GPG Key ID: 220CD1C5BDEED020
2 changed files with 10 additions and 5 deletions

View File

@ -24,3 +24,12 @@ polySegments p@(x':_:_:_) = go p ++ [(last p, x')]
go (x:y:xs) = (x, y) : go (y:xs) go (x:y:xs) = (x, y) : go (y:xs)
go _ = [] go _ = []
polySegments _ = [] polySegments _ = []
isInsidePoly :: [PT] -> Segment -> Bool
isInsidePoly pts seg =
null
. catMaybes
. fmap (intersectSeg'' seg)
$ polySegments pts

View File

@ -131,11 +131,7 @@ monotoneDiagonals pts = catMaybes . go $ classifyList pts
go [] = [] go [] = []
getSeg [] _ _ = Nothing getSeg [] _ _ = Nothing
getSeg (z:zs) pt pts' getSeg (z:zs) pt pts'
| null | isInsidePoly pts (z, pt) = Just (z, pt)
. catMaybes
. fmap (intersectSeg'' (z, pt))
$ polySegments pts
= Just (z, pt)
| otherwise = getSeg zs pt pts' | otherwise = getSeg zs pt pts'
aboveS pt pts' = tail . dropWhile (/= pt) $ sortedYX pts' aboveS pt pts' = tail . dropWhile (/= pt) $ sortedYX pts'
belowS pt pts' = reverse . takeWhile (/= pt) $ sortedYX pts' belowS pt pts' = reverse . takeWhile (/= pt) $ sortedYX pts'