Copyright | (C) Frank Staals |
---|---|
License | see the LICENSE file |
Maintainer | Frank Staals |
Safe Haskell | None |
Language | GHC2021 |
A type for representing Convex polygons, and some basic functions on Convex polygons.
Synopsis
- class SimplePolygon_ convexPolygon point r => ConvexPolygon_ convexPolygon point r
- type ConvexPolygon = ConvexPolygonF (Cyclic NonEmptyVector)
- data ConvexPolygonF (f :: k -> Type) (point :: k)
- fromSimplePolygon :: forall r point (f :: Type -> Type). (Ord r, Num r, Point_ point 2 r, VertexContainer f point) => SimplePolygonF f point -> Maybe (ConvexPolygonF f point)
- toSimplePolygon :: ConvexPolygonF f point -> SimplePolygonF f point
- _ConvexPolygon :: forall (f :: Type -> Type) point r. (Num r, Ord r, Point_ point 2 r, VertexContainer f point) => Prism' (SimplePolygonF f point) (ConvexPolygonF f point)
- isStrictlyConvex :: forall r point (f :: Type -> Type). (Ord r, Num r, Point_ point 2 r, VertexContainer f point) => SimplePolygonF f point -> Bool
- isConvex :: forall r point (f :: Type -> Type). (Ord r, Num r, Point_ point 2 r, VertexContainer f point) => SimplePolygonF f point -> Bool
- verifyConvex :: forall r point (f :: Type -> Type). (Ord r, Num r, Point_ point 2 r, VertexContainer f point) => ConvexPolygonF f point -> Bool
- minkowskiSum :: (Ord r, Num r, ConvexPolygon_ convexPolygon point r, ConvexPolygon_ convexPolygon' point' r) => convexPolygon -> convexPolygon' -> ConvexPolygon (point :+ point')
- maxInDirection :: (Num r, Ord r, ConvexPolygon_ convexPolygon point r) => Vector 2 r -> convexPolygon -> point
Documentation
class SimplePolygon_ convexPolygon point r => ConvexPolygon_ convexPolygon point r Source #
Class modelling convex polygons.
Instances
(SimplePolygon_ (SimplePolygonF f point) point r, Point_ point 2 r) => ConvexPolygon_ (ConvexPolygonF f point) point r Source # | |
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 :: k -> Type) (point :: k) Source #
Convex polygons
Instances
fromSimplePolygon :: forall r point (f :: Type -> Type). (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 :: Type -> Type) 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 :: forall r point (f :: Type -> Type). (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 :: forall r point (f :: Type -> Type). (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 :: forall r point (f :: Type -> Type). (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)\)