hgeometry-0.12.0.0: Geometric Algorithms, Data structures, and Data types.
Copyright(C) 1ndy
Licensesee the LICENSE file
MaintainerDavid Himmelstrup
Safe HaskellNone
LanguageHaskell2010

Data.Geometry.Polygon.Monotone

Description

A polygon is monotone in a certain direction if rays orthogonal to that direction intersects the polygon at most twice. See https://en.wikipedia.org/wiki/Monotone_polygon

Synopsis

Documentation

isMonotone :: (Fractional r, Ord r) => Vector 2 r -> SimplePolygon p r -> Bool Source #

\( O(n \log n) \) A polygon is monotone if a straight line in a given direction cannot have more than two intersections.

randomMonotone :: (RandomGen g, Random r, Ord r, Num r) => Int -> Rand g (SimplePolygon () r) Source #

\( O(n \log n) \) Generate a random N-sided polygon that is monotone in a random direction.

randomMonotoneDirected :: (RandomGen g, Random r, Ord r, Num r) => Int -> Vector 2 r -> Rand g (SimplePolygon () r) Source #

\( O(n \log n) \) Generate a random N-sided polygon that is monotone in the given direction.

monotoneFrom :: (Ord r, Num r) => Vector 2 r -> [Point 2 r] -> SimplePolygon () r Source #

\( O(n \log n) \) Assemble a given set of points in a polygon that is monotone in the given direction.

randomNonZeroVector :: (RandomGen g, Random r, Eq r, Num r) => Rand g (Vector 2 r) Source #

\( O(1) \) Create a random 2D vector which has a non-zero magnitude.