ALGO: add isYmonotone function

This commit is contained in:
hasufell 2015-01-07 19:16:12 +01:00
parent 2bc3aec80a
commit 211731af0c
No known key found for this signature in database
GPG Key ID: 220CD1C5BDEED020
1 changed files with 10 additions and 1 deletions

View File

@ -12,7 +12,7 @@ data VCategory = VStart
| VRegular
| VSplit
| VMerge
deriving (Show)
deriving (Show, Eq)
-- |Classify all vertices on a polygon into five categories (see VCategory).
@ -108,3 +108,12 @@ above :: PT -- ^ is this one above the other?
-> PT
-> Bool
above = flip below
-- |Check if polygon is y-monotone.
isYmonotone :: [PT] -> Bool
isYmonotone poly =
not
. any (\x -> x == VSplit || x == VMerge)
. fmap snd
$ classifyList poly