hgeometry-polygon
Copyright(C) Frank Staals
Licensesee the LICENSE file
MaintainerFrank Staals
Safe HaskellNone
LanguageGHC2024

HGeometry.Polygon.Simple.Class

Description

A Simple polygon and some basic functions to interact with them.

Synopsis

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

uncheckedFromCCWPoints, fromPoints

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)\)

Instances

Instances details
(SimplePolygon_ simplePolygon point r, Default extra) => SimplePolygon_ (simplePolygon :+ extra) point r Source # 
Instance details

Defined in HGeometry.Polygon.Simple.Class

Associated Types

type ConstructableSimplePolygon (simplePolygon :+ extra) point r 
Instance details

Defined in HGeometry.Polygon.Simple.Class

type ConstructableSimplePolygon (simplePolygon :+ extra) point r = (ConstructableSimplePolygon simplePolygon point r, Default extra)

Methods

uncheckedFromCCWPoints :: Foldable1 f => f point -> simplePolygon :+ extra Source #

fromPoints :: (Foldable f, ConstructableSimplePolygon (simplePolygon :+ extra) point r) => f point -> Maybe (simplePolygon :+ extra) Source #

centroid :: (Fractional r, ConstructablePoint_ point' 2 r) => (simplePolygon :+ extra) -> point' Source #

(SimplePolygon_ (SimplePolygonF f point) point r, Point_ point 2 r) => SimplePolygon_ (ConvexPolygonF f point) point r Source # 
Instance details

Defined in HGeometry.Polygon.Convex.Internal

Associated Types

type ConstructableSimplePolygon (ConvexPolygonF f point) point r 
Instance details

Defined in HGeometry.Polygon.Convex.Internal

type ConstructableSimplePolygon (ConvexPolygonF f point) point r = (VertexContainer f point, Ord r, Num r)

Methods

uncheckedFromCCWPoints :: Foldable1 f0 => f0 point -> ConvexPolygonF f point Source #

fromPoints :: (Foldable f0, ConstructableSimplePolygon (ConvexPolygonF f point) point r) => f0 point -> Maybe (ConvexPolygonF f point) Source #

centroid :: (Fractional r, ConstructablePoint_ point' 2 r) => ConvexPolygonF f point -> point' Source #

(Point_ point 2 r, VertexContainer f point, HasFromFoldable1 f) => SimplePolygon_ (SimplePolygonF f point) point r Source # 
Instance details

Defined in HGeometry.Polygon.Simple

Associated Types

type ConstructableSimplePolygon (SimplePolygonF f point) point r 
Instance details

Defined in HGeometry.Polygon.Simple

type ConstructableSimplePolygon (SimplePolygonF f point) point r = (Eq r, Num r)

Methods

uncheckedFromCCWPoints :: Foldable1 f0 => f0 point -> SimplePolygonF f point Source #

fromPoints :: (Foldable f0, ConstructableSimplePolygon (SimplePolygonF f point) point r) => f0 point -> Maybe (SimplePolygonF f point) Source #

centroid :: (Fractional r, ConstructablePoint_ point' 2 r) => SimplePolygonF f point -> point' Source #