| Copyright | (C) Frank Staals |
|---|---|
| License | see the LICENSE file |
| Maintainer | Frank Staals |
| Safe Haskell | None |
| Language | GHC2024 |
HGeometry.Polygon.Simple.Class
Description
A Simple polygon and some basic functions to interact with them.
Synopsis
- class (Polygon_ simplePolygon point r, VertexIx simplePolygon ~ Int, Point_ point 2 r) => SimplePolygon_ simplePolygon point r where
- type ConstructableSimplePolygon simplePolygon point r
- uncheckedFromCCWPoints :: Foldable1 f => f point -> simplePolygon
- fromPoints :: (Foldable f, ConstructableSimplePolygon simplePolygon point r) => f point -> Maybe simplePolygon
- centroid :: (Fractional r, ConstructablePoint_ point' 2 r) => simplePolygon -> point'
Documentation
class (Polygon_ simplePolygon point r, VertexIx simplePolygon ~ Int, Point_ point 2 r) => SimplePolygon_ simplePolygon point r where Source #
A class representing simple polygons; i.e. polygons without holes (and without self intersections in the boundary.)
Minimal complete definition
Associated Types
type ConstructableSimplePolygon simplePolygon point r Source #
Constraints that allow us to construct a simple polygon
type ConstructableSimplePolygon simplePolygon point r = (Eq r, Num r)
Methods
uncheckedFromCCWPoints :: Foldable1 f => f point -> simplePolygon Source #
Given the vertices of the polygon, in CCW order, constructs the polygon. The vertices are numbered in the order they are given.
pre: - the vertices are given in CCW order - at least 3 vertices, not all colinear - no repeated vertices - no self-inttersections
fromPoints :: (Foldable f, ConstructableSimplePolygon simplePolygon point r) => f point -> Maybe simplePolygon Source #
Given the vertices of the polygon, constructs the polygon. This function will make sure the polygon is a valid simple polygon, i.e. it has at least three vertices, is given in CCW order, no repeated vertices etc.
In particular, it will drop repeated vertices.
centroid :: (Fractional r, ConstructablePoint_ point' 2 r) => simplePolygon -> point' Source #
Compute the centroid of a simple polygon.
running time: \(O(n)\)