POLYGON: add polygon module
This commit is contained in:
parent
ddb97aa8c7
commit
edd4ec38d7
26
Algebra/Polygon.hs
Normal file
26
Algebra/Polygon.hs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
{-# OPTIONS_HADDOCK ignore-exports #-}
|
||||||
|
|
||||||
|
module Algebra.Polygon where
|
||||||
|
|
||||||
|
import Algebra.Vector
|
||||||
|
import MyPrelude
|
||||||
|
{- import Diagrams.Coordinates -}
|
||||||
|
|
||||||
|
|
||||||
|
splitPoly :: [PT]
|
||||||
|
-> Segment
|
||||||
|
-> [[PT]]
|
||||||
|
splitPoly pts (a, b)
|
||||||
|
| elem a pts && elem b pts =
|
||||||
|
[b : takeWhile (/= b) shiftedPoly, a : dropWhile (/= b) shiftedPoly]
|
||||||
|
| otherwise = [[]]
|
||||||
|
where
|
||||||
|
shiftedPoly = shiftM' a pts
|
||||||
|
|
||||||
|
|
||||||
|
polySegments :: [PT] -> [Segment]
|
||||||
|
polySegments p@(x':_:_:_) = go p ++ [(last p, x')]
|
||||||
|
where
|
||||||
|
go (x:y:xs) = (x, y) : go (y:xs)
|
||||||
|
go _ = []
|
||||||
|
polySegments _ = []
|
@ -54,7 +54,8 @@ executable Gtk
|
|||||||
main-is: GtkMain.hs
|
main-is: GtkMain.hs
|
||||||
|
|
||||||
-- Modules included in this executable, other than Main.
|
-- Modules included in this executable, other than Main.
|
||||||
other-modules: Algebra.Vector
|
other-modules: Algebra.Polygon
|
||||||
|
Algebra.Vector
|
||||||
Algorithms.GrahamScan
|
Algorithms.GrahamScan
|
||||||
Algorithms.PolygonIntersection
|
Algorithms.PolygonIntersection
|
||||||
Algorithms.PolygonTriangulation
|
Algorithms.PolygonTriangulation
|
||||||
@ -103,7 +104,8 @@ executable Gif
|
|||||||
main-is: GifMain.hs
|
main-is: GifMain.hs
|
||||||
|
|
||||||
-- Modules included in this executable, other than Main.
|
-- Modules included in this executable, other than Main.
|
||||||
other-modules: Algebra.Vector
|
other-modules: Algebra.Polygon
|
||||||
|
Algebra.Vector
|
||||||
Algorithms.GrahamScan
|
Algorithms.GrahamScan
|
||||||
Algorithms.PolygonIntersection
|
Algorithms.PolygonIntersection
|
||||||
Algorithms.PolygonTriangulation
|
Algorithms.PolygonTriangulation
|
||||||
@ -149,7 +151,8 @@ executable Test
|
|||||||
main-is: TestMain.hs
|
main-is: TestMain.hs
|
||||||
|
|
||||||
-- Modules included in this executable, other than Main.
|
-- Modules included in this executable, other than Main.
|
||||||
other-modules: Algebra.Vector
|
other-modules: Algebra.Polygon
|
||||||
|
Algebra.Vector
|
||||||
Algorithms.GrahamScan
|
Algorithms.GrahamScan
|
||||||
Algorithms.PolygonIntersection
|
Algorithms.PolygonIntersection
|
||||||
Algorithms.PolygonTriangulation
|
Algorithms.PolygonTriangulation
|
||||||
|
Loading…
Reference in New Issue
Block a user