ALGO: add partitioning of polygons for triangulation

This commit is contained in:
2015-01-09 03:24:09 +01:00
parent c96474e6fd
commit f53207b48c
2 changed files with 51 additions and 2 deletions

View File

@@ -3,6 +3,7 @@
module Algebra.Polygon where
import Algebra.Vector
import Data.Maybe
import MyPrelude
{- import Diagrams.Coordinates -}
@@ -33,3 +34,19 @@ isInsidePoly pts seg =
. fmap (intersectSeg'' seg)
$ polySegments pts
adjacent :: PT -> PT -> [PT] -> Bool
adjacent u v = any (\x -> x == (u, v) || x == (v, u)) . polySegments
isTrianglePoly :: [PT] -> Bool
isTrianglePoly [_, _, _] = True
isTrianglePoly _ = False
triangleOnly :: [[PT]] -> [[PT]]
triangleOnly = filter isTrianglePoly
nonTriangleOnly :: [[PT]] -> [[PT]]
nonTriangleOnly = filter (not . isTrianglePoly)