hgeometry
Copyright(C) Frank Staals
Licensesee the LICENSE file
MaintainerFrank Staals
Safe HaskellSafe-Inferred
LanguageGHC2021

HGeometry.Polygon.Convex

Description

A type for representing Convex polygons, and some basic functions on Convex polygons.

Synopsis

Documentation

class SimplePolygon_ convexPolygon point r => ConvexPolygon_ convexPolygon point r Source #

Class modelling convex polygons.

Instances

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

Defined in HGeometry.Polygon.Convex.Implementation

type ConvexPolygon = ConvexPolygonF (Cyclic NonEmptyVector) Source #

By default we use a cyclic non-empty vector to represent convex polygons.

data ConvexPolygonF f point Source #

Convex polygons

Instances

Instances details
(Read point, SimplePolygon_ (ConvexPolygonF f point) point r) => Read (ConvexPolygonF f point) Source # 
Instance details

Defined in HGeometry.Polygon.Convex.Implementation

(Show point, SimplePolygon_ (ConvexPolygonF f point) point r) => Show (ConvexPolygonF f point) Source # 
Instance details

Defined in HGeometry.Polygon.Convex.Implementation

Methods

showsPrec :: Int -> ConvexPolygonF f point -> ShowS #

show :: ConvexPolygonF f point -> String #

showList :: [ConvexPolygonF f point] -> ShowS #

NFData (f point) => NFData (ConvexPolygonF f point) Source # 
Instance details

Defined in HGeometry.Polygon.Convex.Implementation

Methods

rnf :: ConvexPolygonF f point -> () #

Eq (f point) => Eq (ConvexPolygonF f point) Source # 
Instance details

Defined in HGeometry.Polygon.Convex.Implementation

Methods

(==) :: ConvexPolygonF f point -> ConvexPolygonF f point -> Bool #

(/=) :: ConvexPolygonF f point -> ConvexPolygonF f point -> Bool #

HasHoles (ConvexPolygonF f point) Source # 
Instance details

Defined in HGeometry.Polygon.Convex.Implementation

Associated Types

type HoleIx (ConvexPolygonF f point) Source #

type HoleF (ConvexPolygonF f point) :: Type -> Type Source #

(HasOuterBoundary (SimplePolygonF f point), VertexIx (SimplePolygonF f point) ~ Int) => HasOuterBoundary (ConvexPolygonF f point) Source # 
Instance details

Defined in HGeometry.Polygon.Convex.Implementation

(VertexContainer f point, Point_ point 2 r, Num r, HasFromFoldable1 f) => IsBoxable (ConvexPolygonF f point) Source # 
Instance details

Defined in HGeometry.Polygon.Convex.Implementation

Methods

boundingBox :: forall (d :: Nat) r. (d ~ Dimension (ConvexPolygonF f point), r ~ NumType (ConvexPolygonF f point), Ord r) => ConvexPolygonF f point -> Box (Point d r)

(VertexContainer f point, DefaultTransformByConstraints (ConvexPolygonF f point) 2 r, Point_ point 2 r) => IsTransformable (ConvexPolygonF f point) Source # 
Instance details

Defined in HGeometry.Polygon.Convex.Implementation

Methods

transformBy :: Transformation (Dimension (ConvexPolygonF f point)) (NumType (ConvexPolygonF f point)) -> ConvexPolygonF f point -> ConvexPolygonF f point

(ShiftedEq (f point), ElemCyclic (f point) ~ point) => ShiftedEq (ConvexPolygonF f point) Source # 
Instance details

Defined in HGeometry.Polygon.Convex.Implementation

Associated Types

type ElemCyclic (ConvexPolygonF f point) Source #

Methods

isShiftOf :: ConvexPolygonF f point -> ConvexPolygonF f point -> Bool Source #

HasVertices' (SimplePolygonF f point) => HasVertices' (ConvexPolygonF f point) Source # 
Instance details

Defined in HGeometry.Polygon.Convex.Implementation

Associated Types

type Vertex (ConvexPolygonF f point) Source #

type VertexIx (ConvexPolygonF f point) Source #

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

Defined in HGeometry.Polygon.Convex.Implementation

Methods

extremes :: Vector 2 r -> ConvexPolygonF f point -> (point, point) Source #

ccwPredecessorOf :: VertexIx (ConvexPolygonF f point) -> IndexedLens' (VertexIx (ConvexPolygonF f point)) (ConvexPolygonF f point) (Vertex (ConvexPolygonF f point)) Source #

ccwSuccessorOf :: VertexIx (ConvexPolygonF f point) -> IndexedLens' (VertexIx (ConvexPolygonF f point)) (ConvexPolygonF f point) (Vertex (ConvexPolygonF f point)) Source #

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

Defined in HGeometry.Polygon.Convex.Implementation

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

Defined in HGeometry.Polygon.Convex.Implementation

Associated Types

type ConstructableSimplePolygon (ConvexPolygonF f point) point r Source #

Methods

uncheckedFromCCWPoints :: Foldable 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 #

ConvexPolygon_ (ConvexPolygonF f point) point r => HasInPolygon (ConvexPolygonF f point) point r Source # 
Instance details

Defined in HGeometry.Polygon.Convex.Implementation

Methods

inPolygon :: (Num r, Ord r, Point_ queryPoint 2 r) => queryPoint -> ConvexPolygonF f point -> PointLocationResultWith (VertexIx (ConvexPolygonF f point)) Source #

HasVertices (SimplePolygonF f point) (SimplePolygonF f point') => HasVertices (ConvexPolygonF f point) (ConvexPolygonF f point') Source # 
Instance details

Defined in HGeometry.Polygon.Convex.Implementation

VertexContainer f point => HasPoints (ConvexPolygonF f point) (ConvexPolygonF f point') point point' Source # 
Instance details

Defined in HGeometry.Polygon.Convex.Implementation

Methods

allPoints :: forall (d :: Nat) r r'. (Point_ point d r, Point_ point' d r', NumType (ConvexPolygonF f point) ~ r, NumType (ConvexPolygonF f point') ~ r', Dimension (ConvexPolygonF f point) ~ d, Dimension (ConvexPolygonF f point') ~ d) => Traversal1 (ConvexPolygonF f point) (ConvexPolygonF f point') point point'

type HoleF (ConvexPolygonF f point) Source # 
Instance details

Defined in HGeometry.Polygon.Convex.Implementation

type HoleIx (ConvexPolygonF f point) Source # 
Instance details

Defined in HGeometry.Polygon.Convex.Implementation

type HoleIx (ConvexPolygonF f point) = Void
type Dimension (ConvexPolygonF f point) Source #

Polygons are per definition 2 dimensional

Instance details

Defined in HGeometry.Polygon.Convex.Implementation

type Dimension (ConvexPolygonF f point) = 2
type NumType (ConvexPolygonF f point) Source # 
Instance details

Defined in HGeometry.Polygon.Convex.Implementation

type NumType (ConvexPolygonF f point) = NumType point
type ElemCyclic (ConvexPolygonF f point) Source # 
Instance details

Defined in HGeometry.Polygon.Convex.Implementation

type ElemCyclic (ConvexPolygonF f point) = point
type Vertex (ConvexPolygonF f point) Source # 
Instance details

Defined in HGeometry.Polygon.Convex.Implementation

type Vertex (ConvexPolygonF f point) = Vertex (SimplePolygonF f point)
type VertexIx (ConvexPolygonF f point) Source # 
Instance details

Defined in HGeometry.Polygon.Convex.Implementation

type VertexIx (ConvexPolygonF f point) = VertexIx (SimplePolygonF f point)
type ConstructableSimplePolygon (ConvexPolygonF f point) point r Source # 
Instance details

Defined in HGeometry.Polygon.Convex.Implementation

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

fromSimplePolygon :: (Ord r, Num r, Point_ point 2 r, VertexContainer f point) => SimplePolygonF f point -> Maybe (ConvexPolygonF f point) Source #

Smart constructor to construct a strictly convex polygon from a simple polygon.

toSimplePolygon :: ConvexPolygonF f point -> SimplePolygonF f point Source #

Convert to a simple polygon, i.e. forget the polygon is convex.

_ConvexPolygon :: forall f point r. (Num r, Ord r, Point_ point 2 r, VertexContainer f point) => Prism' (SimplePolygonF f point) (ConvexPolygonF f point) Source #

Prism that can forget that the polygon is convex

isStrictlyConvex :: (Ord r, Num r, Point_ point 2 r, VertexContainer f point) => SimplePolygonF f point -> Bool Source #

\( O(n) \) Check if a polygon is strictly convex.

isConvex :: (Ord r, Num r, Point_ point 2 r, VertexContainer f point) => SimplePolygonF f point -> Bool Source #

\( O(n) \) Check if a polygon is convex.

verifyConvex :: (Ord r, Num r, Point_ point 2 r, VertexContainer f point) => ConvexPolygonF f point -> Bool Source #

Verify that a convex polygon is strictly convex.

running time \( O(n) \)

minkowskiSum :: (Ord r, Num r, ConvexPolygon_ convexPolygon point r, ConvexPolygon_ convexPolygon' point' r) => convexPolygon -> convexPolygon' -> ConvexPolygon (point :+ point') Source #

Computes the Minkowski sum of the two input polygons with \(n\) and \(m\) vertices respectively.

Note: it takes te position of te second polyon as is; you may want to translate it to te oriin first.

running time: \(O(n+m)\).

maxInDirection :: (Num r, Ord r, ConvexPolygon_ convexPolygon point r) => Vector 2 r -> convexPolygon -> point Source #

Finds the extreme maximum point in the given direction. Based on http://geomalgorithms.com/a14-_extreme_pts.html

pre: The input polygon is strictly convex.

running time: \(O(\log n)\)