Copyright | (c) 2020 Cedric Liegeois |
---|---|
License | BSD3 |
Maintainer | Cedric Liegeois <ofmooseandmen@yahoo.fr> |
Stability | experimental |
Portability | portable |
Safe Haskell | Safe |
Language | Haskell2010 |
Types and functions for working with polygons at the surface of a spherical celestial body.
In order to use this module you should start with the following imports:
import qualified Data.Geo.Jord.Geodetic as Geodetic import qualified Data.Geo.Jord.Polygon as Polygon
Synopsis
- data Polygon a
- vertices :: Polygon a -> [HorizontalPosition a]
- edges :: Polygon a -> [MinorArc a]
- concave :: Polygon a -> Bool
- data Error
- simple :: Spherical a => [HorizontalPosition a] -> Either Error (Polygon a)
- circle :: Spherical a => HorizontalPosition a -> Length -> Int -> Either Error (Polygon a)
- arc :: Spherical a => HorizontalPosition a -> Length -> Angle -> Angle -> Int -> Either Error (Polygon a)
- contains :: Spherical a => Polygon a -> HorizontalPosition a -> Bool
- triangulate :: Spherical a => Polygon a -> [Triangle a]
The Polygon
type
A polygon whose vertices are horizontal geodetic positions.
vertices :: Polygon a -> [HorizontalPosition a] Source #
vertices of the polygon in clockwise order.
smart constructors
Error returned when attempting to create a polygon from invalid data.
NotEnoughVertices | less than 3 vertices were supplied. |
InvalidEdge | 2 consecutives vertices are antipodal or equal. |
InvalidRadius | radius of circle or arc is <= 0. |
EmptyArcRange | arc start angle == end angle. |
SeflIntersectingEdge | 2 edges of the polygon intersect. |
simple :: Spherical a => [HorizontalPosition a] -> Either Error (Polygon a) Source #
Simple polygon (outer ring only and not self-intersecting) from given vertices. Returns an error (Left
) if:
- less than 3 vertices are given.
- the given vertices defines self-intersecting edges.
- the given vertices contains duplicated positions or antipodal positions.
circle :: Spherical a => HorizontalPosition a -> Length -> Int -> Either Error (Polygon a) Source #
Circle from given centre and radius. The resulting polygon contains nb
vertices equally distant from one
another. Returns an error (Left
) if:
- given radius is 0
- given number of positions is less than 3
arc :: Spherical a => HorizontalPosition a -> Length -> Angle -> Angle -> Int -> Either Error (Polygon a) Source #
Arc from given centre, radius and given start/end angles. The resulting polygon contains nb
vertices equally
distant from one another. Returns an error (Left
) if:
- given radius is 0
- given number of positions is less than 3
- difference between start and end angle is 0
calculations
contains :: Spherical a => Polygon a -> HorizontalPosition a -> Bool Source #
contains poly p
returns True
if position p
is enclosed by the vertices of polygon
poly
- see enclosedBy
.