| Copyright | (C) Frank Staals |
|---|---|
| License | see the LICENSE file |
| Maintainer | Frank Staals |
| Safe Haskell | None |
| Language | GHC2024 |
HGeometry.Polygon.Convex.Internal
Contents
Description
A Simple polygon and some basic functions to interact with them.
Synopsis
- type ConvexPolygon = ConvexPolygonF (Cyclic NonEmptyVector)
- newtype ConvexPolygonF (f :: k -> Type) (point :: k) = ConvexPolygon {
- toSimplePolygon :: SimplePolygonF f point
- 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)
- _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)
- _UncheckedConvexPolygon :: forall {k1} {k2} (f1 :: k1 -> Type) (point :: k1) (f' :: k2 -> Type) (point' :: k2) p f2. (Profunctor p, Functor f2) => p (SimplePolygonF f1 point) (f2 (SimplePolygonF f' point')) -> p (ConvexPolygonF f1 point) (f2 (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
- maxInDirection :: (Num r, Ord r, ConvexPolygon_ convexPolygon point r) => Vector 2 r -> convexPolygon -> point
- findMaxWith :: ConvexPolygon_ convexPolygon point r => (point -> point -> Ordering) -> convexPolygon -> point
- inConvex :: (ConvexPolygon_ convexPolygon point r, Point_ queryPoint 2 r, Num r, Ord r) => queryPoint -> convexPolygon -> PointLocationResultWith (VertexIx convexPolygon)
- type HalfPlaneConvexPolygonIntersection (f :: Type -> Type) r vertex = PossiblyDegenerateSimplePolygon vertex (ConvexPolygonF f (OriginalOrExtra vertex (Point 2 r)))
Documentation
type ConvexPolygon = ConvexPolygonF (Cyclic NonEmptyVector) Source #
By default we use a cyclic non-empty vector to represent convex polygons.
newtype ConvexPolygonF (f :: k -> Type) (point :: k) Source #
Convex polygons
Constructors
| ConvexPolygon | |
Fields
| |
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.
_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
_UncheckedConvexPolygon :: forall {k1} {k2} (f1 :: k1 -> Type) (point :: k1) (f' :: k2 -> Type) (point' :: k2) p f2. (Profunctor p, Functor f2) => p (SimplePolygonF f1 point) (f2 (SimplePolygonF f' point')) -> p (ConvexPolygonF f1 point) (f2 (ConvexPolygonF f' point')) Source #
ConvexPolygons are isomorphic to SimplePolygons with the added constraint that all vertices are strictly convex.
Note that this is unchecked; i.e. one can turn an arbitrary simple polygon into a suposedly convex one.
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) \)
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)\)
findMaxWith :: ConvexPolygon_ convexPolygon point r => (point -> point -> Ordering) -> convexPolygon -> point Source #
Find the maximum vertex in a convex polygon using a binary search. \( O(\log n) \)
inConvex :: (ConvexPolygon_ convexPolygon point r, Point_ queryPoint 2 r, Num r, Ord r) => queryPoint -> convexPolygon -> PointLocationResultWith (VertexIx convexPolygon) Source #
Check if a point lies inside a convex polygon, on the boundary, or outside of the convex polygon.
\( O(\log n) \)
type HalfPlaneConvexPolygonIntersection (f :: Type -> Type) r vertex = PossiblyDegenerateSimplePolygon vertex (ConvexPolygonF f (OriginalOrExtra vertex (Point 2 r))) Source #
A single Component of a HalfPlane x ConvexPolygon intersection.
Orphan instances
| (Point_ corner 2 r, Num r, Ord r) => HasIntersectionWith (HalfSpaceF (LinePV 2 r)) (Rectangle corner) Source # | |
Methods intersects :: HalfSpaceF (LinePV 2 r) -> Rectangle corner -> Bool Source # | |
| (Point_ corner 2 r, Num r, Ord r) => HasIntersectionWith (HalfSpaceF (LinePV 2 r)) (Triangle corner) Source # | |
Methods intersects :: HalfSpaceF (LinePV 2 r) -> Triangle corner -> Bool Source # | |
| (Point_ corner 2 r, Fractional r, Ord r) => IsIntersectableWith (HalfSpaceF (LinePV 2 r)) (Rectangle corner) Source # | |
Methods intersect :: HalfSpaceF (LinePV 2 r) -> Rectangle corner -> Intersection (HalfSpaceF (LinePV 2 r)) (Rectangle corner) Source # | |
| (Point_ corner 2 r, Fractional r, Ord r) => IsIntersectableWith (HalfSpaceF (LinePV 2 r)) (Triangle corner) Source # | |
Methods intersect :: HalfSpaceF (LinePV 2 r) -> Triangle corner -> Intersection (HalfSpaceF (LinePV 2 r)) (Triangle corner) Source # | |