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

HGeometry.Polygon.Simple

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 #

type SimplePolygon = SimplePolygonF (Cyclic NonEmptyVector) Source #

By default we store simple polygons as non-empty circular vectors.

newtype SimplePolygonF (f :: k -> Type) (point :: k) Source #

Simple polygons just store their vertices in CCW order

Constructors

MkSimplePolygon (f point) 

Instances

Instances details
HasIntersectionWith geom (SimplePolygonF f vertex) => HasIntersectionWith geom (SimplePolygonF f vertex :+ extra) Source # 
Instance details

Defined in HGeometry.Polygon.Simple

Methods

intersects :: geom -> (SimplePolygonF f vertex :+ extra) -> Bool Source #

(Point_ point 2 r, Num r, Ord r, VertexContainer f point, HyperPlane_ line 2 r) => HasIntersectionWith (HalfSpaceF line) (SimplePolygonF f point) Source # 
Instance details

Defined in HGeometry.Polygon.Simple

Methods

intersects :: HalfSpaceF line -> SimplePolygonF f point -> Bool Source #

Foldable1 f => Foldable1 (SimplePolygonF f) Source # 
Instance details

Defined in HGeometry.Polygon.Simple.Type

Methods

fold1 :: Semigroup m => SimplePolygonF f m -> m Source #

foldMap1 :: Semigroup m => (a -> m) -> SimplePolygonF f a -> m Source #

foldMap1' :: Semigroup m => (a -> m) -> SimplePolygonF f a -> m Source #

toNonEmpty :: SimplePolygonF f a -> NonEmpty a Source #

maximum :: Ord a => SimplePolygonF f a -> a Source #

minimum :: Ord a => SimplePolygonF f a -> a Source #

head :: SimplePolygonF f a -> a Source #

last :: SimplePolygonF f a -> a Source #

foldrMap1 :: (a -> b) -> (a -> b -> b) -> SimplePolygonF f a -> b Source #

foldlMap1' :: (a -> b) -> (b -> a -> b) -> SimplePolygonF f a -> b Source #

foldlMap1 :: (a -> b) -> (b -> a -> b) -> SimplePolygonF f a -> b Source #

foldrMap1' :: (a -> b) -> (a -> b -> b) -> SimplePolygonF f a -> b Source #

Eq1 f => Eq1 (SimplePolygonF f) Source # 
Instance details

Defined in HGeometry.Polygon.Simple.Type

Methods

liftEq :: (a -> b -> Bool) -> SimplePolygonF f a -> SimplePolygonF f b -> Bool Source #

Ord1 f => Ord1 (SimplePolygonF f) Source # 
Instance details

Defined in HGeometry.Polygon.Simple.Type

Methods

liftCompare :: (a -> b -> Ordering) -> SimplePolygonF f a -> SimplePolygonF f b -> Ordering Source #

Functor f => Functor (SimplePolygonF f) Source # 
Instance details

Defined in HGeometry.Polygon.Simple.Type

Methods

fmap :: (a -> b) -> SimplePolygonF f a -> SimplePolygonF f b Source #

(<$) :: a -> SimplePolygonF f b -> SimplePolygonF f a Source #

Foldable f => Foldable (SimplePolygonF f) Source # 
Instance details

Defined in HGeometry.Polygon.Simple.Type

Methods

fold :: Monoid m => SimplePolygonF f m -> m Source #

foldMap :: Monoid m => (a -> m) -> SimplePolygonF f a -> m Source #

foldMap' :: Monoid m => (a -> m) -> SimplePolygonF f a -> m Source #

foldr :: (a -> b -> b) -> b -> SimplePolygonF f a -> b Source #

foldr' :: (a -> b -> b) -> b -> SimplePolygonF f a -> b Source #

foldl :: (b -> a -> b) -> b -> SimplePolygonF f a -> b Source #

foldl' :: (b -> a -> b) -> b -> SimplePolygonF f a -> b Source #

foldr1 :: (a -> a -> a) -> SimplePolygonF f a -> a Source #

foldl1 :: (a -> a -> a) -> SimplePolygonF f a -> a Source #

toList :: SimplePolygonF f a -> [a] Source #

null :: SimplePolygonF f a -> Bool Source #

length :: SimplePolygonF f a -> Int Source #

elem :: Eq a => a -> SimplePolygonF f a -> Bool Source #

maximum :: Ord a => SimplePolygonF f a -> a Source #

minimum :: Ord a => SimplePolygonF f a -> a Source #

sum :: Num a => SimplePolygonF f a -> a Source #

product :: Num a => SimplePolygonF f a -> a Source #

Traversable f => Traversable (SimplePolygonF f) Source # 
Instance details

Defined in HGeometry.Polygon.Simple.Type

Methods

traverse :: Applicative f0 => (a -> f0 b) -> SimplePolygonF f a -> f0 (SimplePolygonF f b) Source #

sequenceA :: Applicative f0 => SimplePolygonF f (f0 a) -> f0 (SimplePolygonF f a) Source #

mapM :: Monad m => (a -> m b) -> SimplePolygonF f a -> m (SimplePolygonF f b) Source #

sequence :: Monad m => SimplePolygonF f (m a) -> m (SimplePolygonF f a) Source #

Traversable1 f => Traversable1 (SimplePolygonF f) Source # 
Instance details

Defined in HGeometry.Polygon.Simple.Type

Methods

traverse1 :: Apply f0 => (a -> f0 b) -> SimplePolygonF f a -> f0 (SimplePolygonF f b) Source #

sequence1 :: Apply f0 => SimplePolygonF f (f0 b) -> f0 (SimplePolygonF f b) Source #

(Num r, Ord r, SimplePolygon_ (SimplePolygonF nonEmpty vertex) vertex r) => HasIntersectionWith (LinePV 2 r) (SimplePolygonF nonEmpty vertex) Source # 
Instance details

Defined in HGeometry.Polygon.Simple

Methods

intersects :: LinePV 2 r -> SimplePolygonF nonEmpty vertex -> Bool Source #

(SimplePolygon_ (SimplePolygonF f point) point r, Num r, Ord r) => HasIntersectionWith (Point 2 r) (SimplePolygonF f point) Source # 
Instance details

Defined in HGeometry.Polygon.Simple

Methods

intersects :: Point 2 r -> SimplePolygonF f point -> Bool Source #

(SimplePolygon_ (SimplePolygonF f point) point r, Num r, Ord r) => IsIntersectableWith (Point 2 r) (SimplePolygonF f point) Source # 
Instance details

Defined in HGeometry.Polygon.Simple

Methods

intersect :: Point 2 r -> SimplePolygonF f point -> Intersection (Point 2 r) (SimplePolygonF f point) Source #

(HasFromFoldable1 f, FromJSON point) => FromJSON (SimplePolygonF f point) Source # 
Instance details

Defined in HGeometry.Polygon.Simple.Type

(Foldable f, ToJSON point) => ToJSON (SimplePolygonF f point) Source # 
Instance details

Defined in HGeometry.Polygon.Simple.Type

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

Defined in HGeometry.Polygon.Simple.Type

Methods

rnf :: SimplePolygonF f point -> () Source #

Generic (SimplePolygonF f point) Source # 
Instance details

Defined in HGeometry.Polygon.Simple.Type

Associated Types

type Rep (SimplePolygonF f point) 
Instance details

Defined in HGeometry.Polygon.Simple.Type

type Rep (SimplePolygonF f point) = D1 ('MetaData "SimplePolygonF" "HGeometry.Polygon.Simple.Type" "hgeometry-polygon-1.0.0.0-inplace" 'True) (C1 ('MetaCons "MkSimplePolygon" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (f point))))

Methods

from :: SimplePolygonF f point -> Rep (SimplePolygonF f point) x Source #

to :: Rep (SimplePolygonF f point) x -> SimplePolygonF f point Source #

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

Defined in HGeometry.Polygon.Simple

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

Defined in HGeometry.Polygon.Simple

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

Defined in HGeometry.Polygon.Simple.Type

Methods

(==) :: SimplePolygonF f point -> SimplePolygonF f point -> Bool Source #

(/=) :: SimplePolygonF f point -> SimplePolygonF f point -> Bool Source #

Ord (f point) => Ord (SimplePolygonF f point) Source # 
Instance details

Defined in HGeometry.Polygon.Simple.Type

Methods

compare :: SimplePolygonF f point -> SimplePolygonF f point -> Ordering Source #

(<) :: SimplePolygonF f point -> SimplePolygonF f point -> Bool Source #

(<=) :: SimplePolygonF f point -> SimplePolygonF f point -> Bool Source #

(>) :: SimplePolygonF f point -> SimplePolygonF f point -> Bool Source #

(>=) :: SimplePolygonF f point -> SimplePolygonF f point -> Bool Source #

max :: SimplePolygonF f point -> SimplePolygonF f point -> SimplePolygonF f point Source #

min :: SimplePolygonF f point -> SimplePolygonF f point -> SimplePolygonF f point Source #

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

Defined in HGeometry.Polygon.Simple.Type

Associated Types

type ElemCyclic (SimplePolygonF f point) 
Instance details

Defined in HGeometry.Polygon.Simple.Type

type ElemCyclic (SimplePolygonF f point) = point

Methods

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

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

Defined in HGeometry.Polygon.Simple.Type

Methods

boundingBox :: forall (d :: Nat) r0. (d ~ Dimension (SimplePolygonF f point), r0 ~ NumType (SimplePolygonF f point), Ord r0) => SimplePolygonF f point -> Box (Point d r0) Source #

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

Defined in HGeometry.Polygon.Simple

HasHoles (SimplePolygonF f point) Source # 
Instance details

Defined in HGeometry.Polygon.Simple

Associated Types

type HoleIx (SimplePolygonF f point) 
Instance details

Defined in HGeometry.Polygon.Simple

type HoleIx (SimplePolygonF f point) = Void
type HoleF (SimplePolygonF f point) 
Instance details

Defined in HGeometry.Polygon.Simple

VertexContainer f point => HasOuterBoundary (SimplePolygonF f point) Source # 
Instance details

Defined in HGeometry.Polygon.Simple

VertexContainer f vertex => HasEdges' (SimplePolygonF f vertex) Source # 
Instance details

Defined in HGeometry.Polygon.Simple.Type

Associated Types

type Edge (SimplePolygonF f vertex) 
Instance details

Defined in HGeometry.Polygon.Simple.Type

type Edge (SimplePolygonF f vertex) = ()
type EdgeIx (SimplePolygonF f vertex) 
Instance details

Defined in HGeometry.Polygon.Simple.Type

type EdgeIx (SimplePolygonF f vertex) = VertexIx (SimplePolygonF f vertex)

Methods

edgeAt :: EdgeIx (SimplePolygonF f vertex) -> IndexedTraversal' (EdgeIx (SimplePolygonF f vertex)) (SimplePolygonF f vertex) (Edge (SimplePolygonF f vertex)) Source #

numEdges :: SimplePolygonF f vertex -> Int Source #

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

Defined in HGeometry.Polygon.Simple.Type

Associated Types

type Vertex (SimplePolygonF f point) 
Instance details

Defined in HGeometry.Polygon.Simple.Type

type Vertex (SimplePolygonF f point) = point
type VertexIx (SimplePolygonF f point) 
Instance details

Defined in HGeometry.Polygon.Simple.Type

type VertexIx (SimplePolygonF f point) = Int
(VertexContainer nonEmpty vertex, HasFromFoldable1 nonEmpty, Point_ vertex 2 r, Fractional r) => HasPickPoint (SimplePolygonF nonEmpty vertex) r Source # 
Instance details

Defined in HGeometry.Polygon.Simple

Methods

pointInteriorTo :: SimplePolygonF nonEmpty vertex -> Point 2 r Source #

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

Defined in HGeometry.Polygon.Simple

(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 #

SimplePolygon_ (SimplePolygonF f point) point r => HasInPolygon (SimplePolygonF f point) point r Source # 
Instance details

Defined in HGeometry.Polygon.Simple

Methods

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

VertexContainer f vertex => HasEdges (SimplePolygonF f vertex) (SimplePolygonF f vertex) Source # 
Instance details

Defined in HGeometry.Polygon.Simple.Type

Methods

edges :: IndexedTraversal (EdgeIx (SimplePolygonF f vertex)) (SimplePolygonF f vertex) (SimplePolygonF f vertex) (Edge (SimplePolygonF f vertex)) (Edge (SimplePolygonF f vertex)) Source #

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

Defined in HGeometry.Polygon.Simple.Type

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

Defined in HGeometry.Polygon.Simple.Type

Methods

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

type Intersection (HalfSpaceF line) (SimplePolygonF f point) Source #

A HalfPlane and a simple polygon intersect in a bunch of components, each of which is a possiblyDegenerate simple polygon.

Instance details

Defined in HGeometry.Polygon.Simple.PossiblyDegenerate

type Intersection (HalfSpaceF line :+ extra) (SimplePolygonF f point :+ extra') Source #

If we drag along extra information in the halfplane polygon intersection we lose it

Instance details

Defined in HGeometry.Polygon.Simple.PossiblyDegenerate

type Intersection (HalfSpaceF line :+ extra) (SimplePolygonF f point :+ extra') = Intersection (HalfSpaceF line) (SimplePolygonF f point)
type Intersection (Point 2 r) (SimplePolygonF f point) Source # 
Instance details

Defined in HGeometry.Polygon.Simple

type Intersection (Point 2 r) (SimplePolygonF f point) = Maybe (Point 2 r)
type Rep (SimplePolygonF f point) Source # 
Instance details

Defined in HGeometry.Polygon.Simple.Type

type Rep (SimplePolygonF f point) = D1 ('MetaData "SimplePolygonF" "HGeometry.Polygon.Simple.Type" "hgeometry-polygon-1.0.0.0-inplace" 'True) (C1 ('MetaCons "MkSimplePolygon" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (f point))))
type ElemCyclic (SimplePolygonF f point) Source # 
Instance details

Defined in HGeometry.Polygon.Simple.Type

type ElemCyclic (SimplePolygonF f point) = point
type HoleF (SimplePolygonF f point) Source # 
Instance details

Defined in HGeometry.Polygon.Simple

type HoleIx (SimplePolygonF f point) Source # 
Instance details

Defined in HGeometry.Polygon.Simple

type HoleIx (SimplePolygonF f point) = Void
type Dimension (SimplePolygonF f point) Source # 
Instance details

Defined in HGeometry.Polygon.Simple.Type

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

Defined in HGeometry.Polygon.Simple.Type

type NumType (SimplePolygonF f point) = NumType point
type Edge (SimplePolygonF f vertex) Source # 
Instance details

Defined in HGeometry.Polygon.Simple.Type

type Edge (SimplePolygonF f vertex) = ()
type EdgeIx (SimplePolygonF f vertex) Source # 
Instance details

Defined in HGeometry.Polygon.Simple.Type

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

Defined in HGeometry.Polygon.Simple.Type

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

Defined in HGeometry.Polygon.Simple.Type

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

Defined in HGeometry.Polygon.Simple

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

toCyclic :: forall {k} (v :: k -> Type) (point :: k). SimplePolygonF (Cyclic v) point -> Cyclic v point Source #

Get the underlying cyclic vector.

type VertexContainer (f :: Type -> Type) point = (IxValue (f point) ~ point, Index (f point) ~ Int, TraversableWithIndex Int f, Traversable1 f, Ixed (f point), HasDirectedTraversals f) Source #

shortcut for all default properties of f we need to store the vertices.

class HasInPolygon polygon point r | polygon -> point, point -> r where Source #

Types that implement a point-in-polygon test.

Minimal complete definition

Nothing

Methods

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

Check if a point lies inside a polygon, on the boundary, or outside of the polygon. If the point lies on the boundary we also return an edge e containing the point (identified by the vertex v so that e follows v in the CCW order along the boundary). No guarantees are given about which edge is returned if the query point lies on multiple edges (i.e. when it coincides with a vertex.)

default inPolygon :: (Num r, Ord r, Point_ point 2 r, Point_ queryPoint 2 r, SimplePolygon_ polygon point r) => queryPoint -> polygon -> PointLocationResultWith (VertexIx polygon) Source #

Instances

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

Defined in HGeometry.Polygon.Convex.Internal

Methods

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

SimplePolygon_ (SimplePolygonF f point) point r => HasInPolygon (SimplePolygonF f point) point r Source # 
Instance details

Defined in HGeometry.Polygon.Simple

Methods

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

inSimplePolygon :: forall queryPoint simplePolygon point r. (Num r, Ord r, Point_ point 2 r, Point_ queryPoint 2 r, SimplePolygon_ simplePolygon point r) => queryPoint -> simplePolygon -> PointLocationResultWith (VertexIx simplePolygon) Source #

Check if a point lies inside a polygon, on the boundary, or outside of the polygon. If the point lies on the boundary we also return an edge e containing the point (identified by the vertex v so that e follows v in the CCW order along the boundary). No guarantees are given about which edge is returned if the query point lies on multiple edges (i.e. when it coincides with a vertex.)

Running time: O(n).

>>> Point2 1 1 `inPolygon` simplePoly
StrictlyInside
>>> Point2 0 0 `inPolygon` simplePoly
OnBoundaryEdge 0
>>> Point2 10 0 `inPolygon` simplePoly
OnBoundaryEdge 1
>>> Point2 5 13 `inPolygon` simplePoly
StrictlyInside
>>> Point2 5 10 `inPolygon` simplePoly
StrictlyInside
>>> Point2 10 5 `inPolygon` simplePoly
OnBoundaryEdge 1
>>> Point2 20 5 `inPolygon` simplePoly
StrictlyOutside

containedIn :: (ClosedLineSegment_ lineSegment point, SimplePolygon_ simplePolygon vertex r, Intersection (ClosedLineSegment vertex) lineSegment ~ Maybe (LineSegmentLineSegmentIntersection lineSegment'), IsIntersectableWith (ClosedLineSegment vertex) lineSegment, NumType lineSegment' ~ r, HasInPolygon simplePolygon vertex r, Point_ point 2 r, Point_ vertex 2 r, Ord r, Fractional r) => lineSegment -> simplePolygon -> Bool Source #

test if the given line segment is contained in the polygon. It is also ok if the segment lies partially on the boundary

hasNoSelfIntersections :: (Foldable1 f, Functor f, Point_ point 2 r, Ord r, Real r) => f point -> Bool Source #

verify that some sequence of points has no self intersecting edges.

Orphan instances

HasIntersectionWith geom (SimplePolygonF f vertex) => HasIntersectionWith geom (SimplePolygonF f vertex :+ extra) Source # 
Instance details

Methods

intersects :: geom -> (SimplePolygonF f vertex :+ extra) -> Bool Source #

(Point_ point 2 r, Num r, Ord r, VertexContainer f point, HyperPlane_ line 2 r) => HasIntersectionWith (HalfSpaceF line) (SimplePolygonF f point) Source # 
Instance details

Methods

intersects :: HalfSpaceF line -> SimplePolygonF f point -> Bool Source #

(Num r, Ord r, SimplePolygon_ (SimplePolygonF nonEmpty vertex) vertex r) => HasIntersectionWith (LinePV 2 r) (SimplePolygonF nonEmpty vertex) Source # 
Instance details

Methods

intersects :: LinePV 2 r -> SimplePolygonF nonEmpty vertex -> Bool Source #

(SimplePolygon_ (SimplePolygonF f point) point r, Num r, Ord r) => HasIntersectionWith (Point 2 r) (SimplePolygonF f point) Source # 
Instance details

Methods

intersects :: Point 2 r -> SimplePolygonF f point -> Bool Source #

(SimplePolygon_ (SimplePolygonF f point) point r, Num r, Ord r) => IsIntersectableWith (Point 2 r) (SimplePolygonF f point) Source # 
Instance details

Methods

intersect :: Point 2 r -> SimplePolygonF f point -> Intersection (Point 2 r) (SimplePolygonF f point) Source #

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

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

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

HasHoles (SimplePolygonF f point) Source # 
Instance details

Associated Types

type HoleIx (SimplePolygonF f point) 
Instance details

Defined in HGeometry.Polygon.Simple

type HoleIx (SimplePolygonF f point) = Void
type HoleF (SimplePolygonF f point) 
Instance details

Defined in HGeometry.Polygon.Simple

VertexContainer f point => HasOuterBoundary (SimplePolygonF f point) Source # 
Instance details

(VertexContainer nonEmpty vertex, HasFromFoldable1 nonEmpty, Point_ vertex 2 r, Fractional r) => HasPickPoint (SimplePolygonF nonEmpty vertex) r Source # 
Instance details

Methods

pointInteriorTo :: SimplePolygonF nonEmpty vertex -> Point 2 r Source #

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

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

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 #

SimplePolygon_ (SimplePolygonF f point) point r => HasInPolygon (SimplePolygonF f point) point r Source # 
Instance details

Methods

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