ALGO: simplify monotoneDiagonals
This commit is contained in:
parent
f383cc65b2
commit
ba3cfb879e
@ -129,16 +129,16 @@ monotoneDiagonals :: [PT] -> [(PT, PT)]
|
|||||||
monotoneDiagonals pts = catMaybes . go $ classifyList pts
|
monotoneDiagonals pts = catMaybes . go $ classifyList pts
|
||||||
where
|
where
|
||||||
go (x:xs) = case snd x of
|
go (x:xs) = case snd x of
|
||||||
VMerge -> getSeg (belowS (fst x) pts) (fst x) pts : go xs
|
VMerge -> getSeg (belowS . fst $ x) (fst x) : go xs
|
||||||
VSplit -> getSeg (aboveS (fst x) pts) (fst x) pts : go xs
|
VSplit -> getSeg (aboveS . fst $ x) (fst x) : go xs
|
||||||
_ -> [] ++ go xs
|
_ -> [] ++ go xs
|
||||||
go [] = []
|
go [] = []
|
||||||
getSeg [] _ _ = Nothing
|
getSeg [] _ = Nothing
|
||||||
getSeg (z:zs) pt pts'
|
getSeg (z:zs) pt
|
||||||
| isInsidePoly pts (z, pt) = Just (z, pt)
|
| isInsidePoly pts (z, pt) = Just (z, pt)
|
||||||
| otherwise = getSeg zs pt pts'
|
| otherwise = getSeg zs pt
|
||||||
aboveS pt pts' = tail . dropWhile (/= pt) $ sortedYX pts'
|
aboveS pt = tail . dropWhile (/= pt) $ sortedYX pts
|
||||||
belowS pt pts' = reverse . takeWhile (/= pt) $ sortedYX pts'
|
belowS pt = reverse . takeWhile (/= pt) $ sortedYX pts
|
||||||
|
|
||||||
|
|
||||||
-- |Triangulate a y-monotone polygon.
|
-- |Triangulate a y-monotone polygon.
|
||||||
|
Loading…
Reference in New Issue
Block a user