| Copyright | (C) Frank Staals |
|---|---|
| License | see the LICENSE file |
| Maintainer | Frank Staals |
| Safe Haskell | None |
| Language | GHC2024 |
HGeometry.Polygon.Simple
Contents
Description
A Simple polygon and some basic functions to interact with them.
Synopsis
- class (Polygon_ simplePolygon point r, VertexIx simplePolygon ~ Int, Point_ point 2 r) => SimplePolygon_ simplePolygon point r where
- type ConstructableSimplePolygon simplePolygon point r
- uncheckedFromCCWPoints :: Foldable1 f => f point -> simplePolygon
- fromPoints :: (Foldable f, ConstructableSimplePolygon simplePolygon point r) => f point -> Maybe simplePolygon
- centroid :: (Fractional r, ConstructablePoint_ point' 2 r) => simplePolygon -> point'
- type SimplePolygon = SimplePolygonF (Cyclic NonEmptyVector)
- newtype SimplePolygonF (f :: k -> Type) (point :: k) = MkSimplePolygon (f point)
- toCyclic :: forall {k} (v :: k -> Type) (point :: k). SimplePolygonF (Cyclic v) point -> Cyclic v point
- type VertexContainer (f :: Type -> Type) point = (IxValue (f point) ~ point, Index (f point) ~ Int, TraversableWithIndex Int f, Traversable1 f, Ixed (f point), HasDirectedTraversals f)
- class HasInPolygon polygon point r | polygon -> point, point -> r where
- 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)
- 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
- hasNoSelfIntersections :: (Foldable1 f, Functor f, Point_ point 2 r, Ord r, Real r) => f point -> Bool
- module HGeometry.Polygon.Simple.Class
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
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
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
| HasIntersectionWith geom (SimplePolygonF f vertex) => HasIntersectionWith geom (SimplePolygonF f vertex :+ extra) Source # | |||||||||
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 # | |||||||||
Defined in HGeometry.Polygon.Simple Methods intersects :: HalfSpaceF line -> SimplePolygonF f point -> Bool Source # | |||||||||
| Foldable1 f => Foldable1 (SimplePolygonF f) Source # | |||||||||
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 # | |||||||||
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 # | |||||||||
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 # | |||||||||
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 # | |||||||||
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 # | |||||||||
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 # | |||||||||
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 # | |||||||||
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 # | |||||||||
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 # | |||||||||
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 # | |||||||||
Defined in HGeometry.Polygon.Simple.Type Methods parseJSON :: Value -> Parser (SimplePolygonF f point) Source # parseJSONList :: Value -> Parser [SimplePolygonF f point] Source # omittedField :: Maybe (SimplePolygonF f point) Source # | |||||||||
| (Foldable f, ToJSON point) => ToJSON (SimplePolygonF f point) Source # | |||||||||
Defined in HGeometry.Polygon.Simple.Type Methods toJSON :: SimplePolygonF f point -> Value Source # toEncoding :: SimplePolygonF f point -> Encoding Source # toJSONList :: [SimplePolygonF f point] -> Value Source # toEncodingList :: [SimplePolygonF f point] -> Encoding Source # omitField :: SimplePolygonF f point -> Bool Source # | |||||||||
| NFData (f point) => NFData (SimplePolygonF f point) Source # | |||||||||
Defined in HGeometry.Polygon.Simple.Type Methods rnf :: SimplePolygonF f point -> () Source # | |||||||||
| Generic (SimplePolygonF f point) Source # | |||||||||
Defined in HGeometry.Polygon.Simple.Type Associated Types
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 # | |||||||||
Defined in HGeometry.Polygon.Simple Methods readsPrec :: Int -> ReadS (SimplePolygonF f point) Source # readList :: ReadS [SimplePolygonF f point] Source # readPrec :: ReadPrec (SimplePolygonF f point) Source # readListPrec :: ReadPrec [SimplePolygonF f point] Source # | |||||||||
| (Show point, SimplePolygon_ (SimplePolygonF f point) point r) => Show (SimplePolygonF f point) Source # | |||||||||
Defined in HGeometry.Polygon.Simple | |||||||||
| Eq (f point) => Eq (SimplePolygonF f point) Source # | |||||||||
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 # | |||||||||
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 # | |||||||||
Defined in HGeometry.Polygon.Simple.Type Associated Types
Methods isShiftOf :: SimplePolygonF f point -> SimplePolygonF f point -> Bool Source # | |||||||||
| (VertexContainer f point, Point_ point 2 r) => IsBoxable (SimplePolygonF f point) Source # | |||||||||
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 # | |||||||||
Defined in HGeometry.Polygon.Simple Methods transformBy :: Transformation (Dimension (SimplePolygonF f point)) (NumType (SimplePolygonF f point)) -> SimplePolygonF f point -> SimplePolygonF f point Source # | |||||||||
| HasHoles (SimplePolygonF f point) Source # | |||||||||
Defined in HGeometry.Polygon.Simple Associated Types
Methods holes :: IndexedTraversal' (HoleIx (SimplePolygonF f point)) (SimplePolygonF f point) (Hole (SimplePolygonF f point)) Source # holeAt :: HoleIx (SimplePolygonF f point) -> IndexedTraversal' (HoleIx (SimplePolygonF f point)) (SimplePolygonF f point) (Hole (SimplePolygonF f point)) Source # | |||||||||
| VertexContainer f point => HasOuterBoundary (SimplePolygonF f point) Source # | |||||||||
Defined in HGeometry.Polygon.Simple Methods outerBoundary :: IndexedTraversal1' (VertexIx (SimplePolygonF f point)) (SimplePolygonF f point) (Vertex (SimplePolygonF f point)) Source # ccwOuterBoundaryFrom :: VertexIx (SimplePolygonF f point) -> IndexedTraversal1' (VertexIx (SimplePolygonF f point)) (SimplePolygonF f point) (Vertex (SimplePolygonF f point)) Source # cwOuterBoundaryFrom :: VertexIx (SimplePolygonF f point) -> IndexedTraversal1' (VertexIx (SimplePolygonF f point)) (SimplePolygonF f point) (Vertex (SimplePolygonF f point)) Source # outerBoundaryVertexAt :: VertexIx (SimplePolygonF f point) -> IndexedGetter (VertexIx (SimplePolygonF f point)) (SimplePolygonF f point) (Vertex (SimplePolygonF f point)) Source # outerBoundaryEdges :: IndexedFold1 (VertexIx (SimplePolygonF f point), VertexIx (SimplePolygonF f point)) (SimplePolygonF f point) (Vertex (SimplePolygonF f point), Vertex (SimplePolygonF f point)) Source # outerBoundaryEdgeAt :: VertexIx (SimplePolygonF f point) -> IndexedGetter (VertexIx (SimplePolygonF f point), VertexIx (SimplePolygonF f point)) (SimplePolygonF f point) (Vertex (SimplePolygonF f point), Vertex (SimplePolygonF f point)) Source # | |||||||||
| VertexContainer f vertex => HasEdges' (SimplePolygonF f vertex) Source # | |||||||||
Defined in HGeometry.Polygon.Simple.Type Associated Types
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 # | |||||||||
Defined in HGeometry.Polygon.Simple.Type Associated Types
Methods vertexAt :: VertexIx (SimplePolygonF f point) -> IndexedTraversal' (VertexIx (SimplePolygonF f point)) (SimplePolygonF f point) (Vertex (SimplePolygonF f point)) Source # numVertices :: SimplePolygonF f point -> Int Source # | |||||||||
| (VertexContainer nonEmpty vertex, HasFromFoldable1 nonEmpty, Point_ vertex 2 r, Fractional r) => HasPickPoint (SimplePolygonF nonEmpty vertex) r Source # | |||||||||
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 # | |||||||||
Defined in HGeometry.Polygon.Simple Methods extremes :: Vector 2 r -> SimplePolygonF f point -> (point, point) Source # ccwPredecessorOf :: VertexIx (SimplePolygonF f point) -> IndexedLens' (VertexIx (SimplePolygonF f point)) (SimplePolygonF f point) (Vertex (SimplePolygonF f point)) Source # ccwSuccessorOf :: VertexIx (SimplePolygonF f point) -> IndexedLens' (VertexIx (SimplePolygonF f point)) (SimplePolygonF f point) (Vertex (SimplePolygonF f point)) Source # | |||||||||
| (Point_ point 2 r, VertexContainer f point, HasFromFoldable1 f) => SimplePolygon_ (SimplePolygonF f point) point r Source # | |||||||||
Defined in HGeometry.Polygon.Simple Associated Types
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 # | |||||||||
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 # | |||||||||
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 # | |||||||||
Defined in HGeometry.Polygon.Simple.Type Methods vertices :: IndexedTraversal1 (VertexIx (SimplePolygonF f point)) (SimplePolygonF f point) (SimplePolygonF f point') (Vertex (SimplePolygonF f point)) (Vertex (SimplePolygonF f point')) Source # | |||||||||
| VertexContainer f point => HasPoints (SimplePolygonF f point) (SimplePolygonF f point') point point' Source # | |||||||||
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. | ||||||||
Defined in HGeometry.Polygon.Simple.PossiblyDegenerate type Intersection (HalfSpaceF line) (SimplePolygonF f point) = [HalfPlane_x_SimplePolygon_Component f (NumType point) point] | |||||||||
| type Intersection (HalfSpaceF line :+ extra) (SimplePolygonF f point :+ extra') Source # | If we drag along extra information in the halfplane polygon intersection we lose it | ||||||||
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 # | |||||||||
Defined in HGeometry.Polygon.Simple | |||||||||
| type Rep (SimplePolygonF f point) Source # | |||||||||
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 # | |||||||||
Defined in HGeometry.Polygon.Simple.Type | |||||||||
| type HoleF (SimplePolygonF f point) Source # | |||||||||
Defined in HGeometry.Polygon.Simple | |||||||||
| type HoleIx (SimplePolygonF f point) Source # | |||||||||
Defined in HGeometry.Polygon.Simple | |||||||||
| type Dimension (SimplePolygonF f point) Source # | |||||||||
Defined in HGeometry.Polygon.Simple.Type | |||||||||
| type NumType (SimplePolygonF f point) Source # | |||||||||
Defined in HGeometry.Polygon.Simple.Type | |||||||||
| type Edge (SimplePolygonF f vertex) Source # | |||||||||
Defined in HGeometry.Polygon.Simple.Type | |||||||||
| type EdgeIx (SimplePolygonF f vertex) Source # | |||||||||
Defined in HGeometry.Polygon.Simple.Type | |||||||||
| type Vertex (SimplePolygonF f point) Source # | |||||||||
Defined in HGeometry.Polygon.Simple.Type | |||||||||
| type VertexIx (SimplePolygonF f point) Source # | |||||||||
Defined in HGeometry.Polygon.Simple.Type | |||||||||
| type ConstructableSimplePolygon (SimplePolygonF f point) point r Source # | |||||||||
Defined in HGeometry.Polygon.Simple | |||||||||
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
| ConvexPolygon_ (ConvexPolygonF f point) point r => HasInPolygon (ConvexPolygonF f point) point r Source # | |
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 # | |
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` simplePolyStrictlyInside>>>Point2 0 0 `inPolygon` simplePolyOnBoundaryEdge 0>>>Point2 10 0 `inPolygon` simplePolyOnBoundaryEdge 1>>>Point2 5 13 `inPolygon` simplePolyStrictlyInside>>>Point2 5 10 `inPolygon` simplePolyStrictlyInside>>>Point2 10 5 `inPolygon` simplePolyOnBoundaryEdge 1>>>Point2 20 5 `inPolygon` simplePolyStrictlyOutside
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 # | |||||||||
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 # | |||||||||
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 # | |||||||||
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 # | |||||||||
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 # | |||||||||
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 # | |||||||||
Methods readsPrec :: Int -> ReadS (SimplePolygonF f point) Source # readList :: ReadS [SimplePolygonF f point] Source # readPrec :: ReadPrec (SimplePolygonF f point) Source # readListPrec :: ReadPrec [SimplePolygonF f point] Source # | |||||||||
| (Show point, SimplePolygon_ (SimplePolygonF f point) point r) => Show (SimplePolygonF f point) 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 # | |||||||||
Methods transformBy :: Transformation (Dimension (SimplePolygonF f point)) (NumType (SimplePolygonF f point)) -> SimplePolygonF f point -> SimplePolygonF f point Source # | |||||||||
| HasHoles (SimplePolygonF f point) Source # | |||||||||
Associated Types
Methods holes :: IndexedTraversal' (HoleIx (SimplePolygonF f point)) (SimplePolygonF f point) (Hole (SimplePolygonF f point)) Source # holeAt :: HoleIx (SimplePolygonF f point) -> IndexedTraversal' (HoleIx (SimplePolygonF f point)) (SimplePolygonF f point) (Hole (SimplePolygonF f point)) Source # | |||||||||
| VertexContainer f point => HasOuterBoundary (SimplePolygonF f point) Source # | |||||||||
Methods outerBoundary :: IndexedTraversal1' (VertexIx (SimplePolygonF f point)) (SimplePolygonF f point) (Vertex (SimplePolygonF f point)) Source # ccwOuterBoundaryFrom :: VertexIx (SimplePolygonF f point) -> IndexedTraversal1' (VertexIx (SimplePolygonF f point)) (SimplePolygonF f point) (Vertex (SimplePolygonF f point)) Source # cwOuterBoundaryFrom :: VertexIx (SimplePolygonF f point) -> IndexedTraversal1' (VertexIx (SimplePolygonF f point)) (SimplePolygonF f point) (Vertex (SimplePolygonF f point)) Source # outerBoundaryVertexAt :: VertexIx (SimplePolygonF f point) -> IndexedGetter (VertexIx (SimplePolygonF f point)) (SimplePolygonF f point) (Vertex (SimplePolygonF f point)) Source # outerBoundaryEdges :: IndexedFold1 (VertexIx (SimplePolygonF f point), VertexIx (SimplePolygonF f point)) (SimplePolygonF f point) (Vertex (SimplePolygonF f point), Vertex (SimplePolygonF f point)) Source # outerBoundaryEdgeAt :: VertexIx (SimplePolygonF f point) -> IndexedGetter (VertexIx (SimplePolygonF f point), VertexIx (SimplePolygonF f point)) (SimplePolygonF f point) (Vertex (SimplePolygonF f point), Vertex (SimplePolygonF f point)) Source # | |||||||||
| (VertexContainer nonEmpty vertex, HasFromFoldable1 nonEmpty, Point_ vertex 2 r, Fractional r) => HasPickPoint (SimplePolygonF nonEmpty vertex) r Source # | |||||||||
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 # | |||||||||
Methods extremes :: Vector 2 r -> SimplePolygonF f point -> (point, point) Source # ccwPredecessorOf :: VertexIx (SimplePolygonF f point) -> IndexedLens' (VertexIx (SimplePolygonF f point)) (SimplePolygonF f point) (Vertex (SimplePolygonF f point)) Source # ccwSuccessorOf :: VertexIx (SimplePolygonF f point) -> IndexedLens' (VertexIx (SimplePolygonF f point)) (SimplePolygonF f point) (Vertex (SimplePolygonF f point)) Source # | |||||||||
| (Point_ point 2 r, VertexContainer f point, HasFromFoldable1 f) => SimplePolygon_ (SimplePolygonF f point) point r Source # | |||||||||
Associated Types
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 # | |||||||||
Methods inPolygon :: (Num r, Ord r, Point_ queryPoint 2 r) => queryPoint -> SimplePolygonF f point -> PointLocationResultWith (VertexIx (SimplePolygonF f point)) Source # | |||||||||