| Copyright | (C) Frank Staals |
|---|---|
| License | see the LICENSE file |
| Maintainer | Frank Staals |
| Safe Haskell | None |
| Language | GHC2024 |
HGeometry.LineSegment.Intersection.Types
Description
Types for line segment intersections
Synopsis
- type Intersections r lineSegment = Map (Point 2 r) (Associated lineSegment)
- intersectionPoints :: Intersections r lineSegment -> Set (Point 2 r)
- data Associated lineSegment = Associated (Set (AroundStart lineSegment)) (Set (AroundEnd lineSegment)) (Set (AroundIntersection lineSegment))
- startPointOf :: forall lineSegment f. Functor f => (Set (AroundStart lineSegment) -> f (Set (AroundStart lineSegment))) -> Associated lineSegment -> f (Associated lineSegment)
- endPointOf :: forall lineSegment f. Functor f => (Set (AroundEnd lineSegment) -> f (Set (AroundEnd lineSegment))) -> Associated lineSegment -> f (Associated lineSegment)
- interiorTo :: forall lineSegment f. Functor f => (Set (AroundIntersection lineSegment) -> f (Set (AroundIntersection lineSegment))) -> Associated lineSegment -> f (Associated lineSegment)
- empty :: Associated lineSegment
- mkAssociated :: (LineSegment_ lineSegment point, Point_ point 2 r, Point_ point' 2 r, Eq r) => point' -> lineSegment -> Associated lineSegment
- mkAroundStart :: lineSegment -> Associated lineSegment
- mkAroundEnd :: lineSegment -> Associated lineSegment
- associatedSegments :: forall lineSegment f. (Contravariant f, Applicative f) => (lineSegment -> f lineSegment) -> Associated lineSegment -> f (Associated lineSegment)
- newtype AroundEnd a = AroundEnd a
- newtype AroundStart a = AroundStart a
- newtype AroundIntersection a = AroundIntersection a
- isInteriorIntersection :: Associated lineSegment -> Bool
- data IntersectionPoint point lineSegment
- intersectionPointOf :: (LineSegment_ lineSegment point, LineSegment_ seg point, Point_ point 2 r, Ord r, Fractional r, IntersectConstraints seg lineSegment) => lineSegment -> lineSegment -> Maybe (IntersectionPoint (Point 2 r) lineSegment)
- intersectionPoint :: forall point lineSegment point' f. Functor f => (point -> f point') -> IntersectionPoint point lineSegment -> f (IntersectionPoint point' lineSegment)
- associatedSegs :: forall point lineSegment lineSegment' f. Functor f => (Associated lineSegment -> f (Associated lineSegment')) -> IntersectionPoint point lineSegment -> f (IntersectionPoint point lineSegment')
- mkIntersectionPoint :: (LineSegment_ lineSegment endPoint, Point_ endPoint 2 r, Point_ point 2 r, Ord r, Num r, OrdArounds lineSegment) => point -> [lineSegment] -> [lineSegment] -> IntersectionPoint point lineSegment
- type IntersectConstraints seg lineSegment = (OrdArounds lineSegment, IsIntersectableWith lineSegment lineSegment, Intersection lineSegment lineSegment ~ Maybe (LineSegmentLineSegmentIntersection seg), NumType seg ~ NumType lineSegment, Dimension seg ~ Dimension lineSegment)
- type OrdArounds lineSegment = (Ord (AroundStart lineSegment), Ord (AroundEnd lineSegment))
- ordPoints :: (Point_ point 2 r, Ord r) => point -> point -> Ordering
- fromInteriors :: (LineSegment_ lineSegment endPoint, Point_ endPoint 2 r, Ord r, Num r) => Point 2 r -> [lineSegment] -> Set (AroundIntersection lineSegment)
- mergeInteriorsWith :: (LineSegment_ lineSegment endPoint, Point_ endPoint 2 r, Ord r, Num r) => Point 2 r -> Set (AroundIntersection lineSegment) -> Set (AroundIntersection lineSegment) -> Set (AroundIntersection lineSegment)
Documentation
type Intersections r lineSegment = Map (Point 2 r) (Associated lineSegment) Source #
For each intersection point the segments intersecting there.
intersectionPoints :: Intersections r lineSegment -> Set (Point 2 r) Source #
Get the set of all intersection points
data Associated lineSegment Source #
The line segments that contain a given point p may either have p as the endpoint or have p in their interior.
if somehow the segment is degenerate, and p is both the start and end it is reported only as the start point.
Constructors
| Associated (Set (AroundStart lineSegment)) (Set (AroundEnd lineSegment)) (Set (AroundIntersection lineSegment)) |
Instances
startPointOf :: forall lineSegment f. Functor f => (Set (AroundStart lineSegment) -> f (Set (AroundStart lineSegment))) -> Associated lineSegment -> f (Associated lineSegment) Source #
Lens to access the segments for which this is a startPoint
endPointOf :: forall lineSegment f. Functor f => (Set (AroundEnd lineSegment) -> f (Set (AroundEnd lineSegment))) -> Associated lineSegment -> f (Associated lineSegment) Source #
Lens to access the segments for which this is an endPoint
interiorTo :: forall lineSegment f. Functor f => (Set (AroundIntersection lineSegment) -> f (Set (AroundIntersection lineSegment))) -> Associated lineSegment -> f (Associated lineSegment) Source #
Lens to access the segments for which this point lies in the interior of the segment
empty :: Associated lineSegment Source #
Constructs an empty associated
mkAssociated :: (LineSegment_ lineSegment point, Point_ point 2 r, Point_ point' 2 r, Eq r) => point' -> lineSegment -> Associated lineSegment Source #
test if the given segment has p as its endpoint, an construct the appropriate associated representing that.
pre: p intersects the segment
mkAroundStart :: lineSegment -> Associated lineSegment Source #
Constructs an around start
mkAroundEnd :: lineSegment -> Associated lineSegment Source #
Constructs an ArroundEnd
associatedSegments :: forall lineSegment f. (Contravariant f, Applicative f) => (lineSegment -> f lineSegment) -> Associated lineSegment -> f (Associated lineSegment) Source #
Fold over the segments associated with the intersection.
Assumes that two segments have the same end point (ordering is CCW around common endpoint) (note that we specifically mean end point; not startpoint. See AroundStart)
Constructors
| AroundEnd a |
Instances
| Functor AroundEnd Source # | |||||
| NFData a => NFData (AroundEnd a) Source # | |||||
Defined in HGeometry.LineSegment.Intersection.Types | |||||
| Generic (AroundEnd a) Source # | |||||
Defined in HGeometry.LineSegment.Intersection.Types Associated Types
| |||||
| Show a => Show (AroundEnd a) Source # | |||||
| (Point_ point 2 r, Eq r, HasStart lineSegment point) => Eq (AroundEnd lineSegment) Source # | |||||
| (LineSegment_ lineSegment point, Point_ point 2 r, Ord r, Num r, Eq lineSegment) => Ord (AroundEnd lineSegment) Source # | |||||
Defined in HGeometry.LineSegment.Intersection.Types Methods compare :: AroundEnd lineSegment -> AroundEnd lineSegment -> Ordering Source # (<) :: AroundEnd lineSegment -> AroundEnd lineSegment -> Bool Source # (<=) :: AroundEnd lineSegment -> AroundEnd lineSegment -> Bool Source # (>) :: AroundEnd lineSegment -> AroundEnd lineSegment -> Bool Source # (>=) :: AroundEnd lineSegment -> AroundEnd lineSegment -> Bool Source # max :: AroundEnd lineSegment -> AroundEnd lineSegment -> AroundEnd lineSegment Source # min :: AroundEnd lineSegment -> AroundEnd lineSegment -> AroundEnd lineSegment Source # | |||||
| Wrapped (AroundEnd a) Source # | |||||
| AroundEnd a ~ t => Rewrapped (AroundEnd a) t Source # | |||||
Defined in HGeometry.LineSegment.Intersection.Types | |||||
| type Rep (AroundEnd a) Source # | |||||
Defined in HGeometry.LineSegment.Intersection.Types type Rep (AroundEnd a) = D1 ('MetaData "AroundEnd" "HGeometry.LineSegment.Intersection.Types" "hgeometry-lineSegmentIntersection-1.0.0.0-inplace" 'True) (C1 ('MetaCons "AroundEnd" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a))) | |||||
| type Unwrapped (AroundEnd a) Source # | |||||
Defined in HGeometry.LineSegment.Intersection.Types | |||||
newtype AroundStart a Source #
A newtype helping us order segments CCW around their common start point. I.e. this assumes that two segments have the same start point.
Constructors
| AroundStart a |
Instances
| Functor AroundStart Source # | |||||
Defined in HGeometry.LineSegment.Intersection.Types Methods fmap :: (a -> b) -> AroundStart a -> AroundStart b Source # (<$) :: a -> AroundStart b -> AroundStart a Source # | |||||
| NFData a => NFData (AroundStart a) Source # | |||||
Defined in HGeometry.LineSegment.Intersection.Types Methods rnf :: AroundStart a -> () Source # | |||||
| Generic (AroundStart a) Source # | |||||
Defined in HGeometry.LineSegment.Intersection.Types Associated Types
Methods from :: AroundStart a -> Rep (AroundStart a) x Source # to :: Rep (AroundStart a) x -> AroundStart a Source # | |||||
| Show a => Show (AroundStart a) Source # | |||||
Defined in HGeometry.LineSegment.Intersection.Types | |||||
| (Point_ point 2 r, Eq r, HasEnd lineSegment point) => Eq (AroundStart lineSegment) Source # | |||||
Defined in HGeometry.LineSegment.Intersection.Types Methods (==) :: AroundStart lineSegment -> AroundStart lineSegment -> Bool Source # (/=) :: AroundStart lineSegment -> AroundStart lineSegment -> Bool Source # | |||||
| (LineSegment_ lineSegment point, Point_ point 2 r, Ord r, Num r) => Ord (AroundStart lineSegment) Source # | |||||
Defined in HGeometry.LineSegment.Intersection.Types Methods compare :: AroundStart lineSegment -> AroundStart lineSegment -> Ordering Source # (<) :: AroundStart lineSegment -> AroundStart lineSegment -> Bool Source # (<=) :: AroundStart lineSegment -> AroundStart lineSegment -> Bool Source # (>) :: AroundStart lineSegment -> AroundStart lineSegment -> Bool Source # (>=) :: AroundStart lineSegment -> AroundStart lineSegment -> Bool Source # max :: AroundStart lineSegment -> AroundStart lineSegment -> AroundStart lineSegment Source # min :: AroundStart lineSegment -> AroundStart lineSegment -> AroundStart lineSegment Source # | |||||
| Wrapped (AroundStart a) Source # | |||||
Defined in HGeometry.LineSegment.Intersection.Types Associated Types
Methods _Wrapped' :: Iso' (AroundStart a) (Unwrapped (AroundStart a)) Source # | |||||
| AroundStart a ~ t => Rewrapped (AroundStart a) t Source # | |||||
Defined in HGeometry.LineSegment.Intersection.Types | |||||
| type Rep (AroundStart a) Source # | |||||
Defined in HGeometry.LineSegment.Intersection.Types type Rep (AroundStart a) = D1 ('MetaData "AroundStart" "HGeometry.LineSegment.Intersection.Types" "hgeometry-lineSegmentIntersection-1.0.0.0-inplace" 'True) (C1 ('MetaCons "AroundStart" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a))) | |||||
| type Unwrapped (AroundStart a) Source # | |||||
Defined in HGeometry.LineSegment.Intersection.Types | |||||
newtype AroundIntersection a Source #
This type represents a line segment seg, that contains some
globally known point "p" in its interior. The Ord instance of
AroundIntersection orders segments of this type "around" p. In
particular, it orders the segments in CCW order by their starting
point (starting from the positive x-axis).
Constructors
| AroundIntersection a |
Instances
| Functor AroundIntersection Source # | |||||
Defined in HGeometry.LineSegment.Intersection.Types Methods fmap :: (a -> b) -> AroundIntersection a -> AroundIntersection b Source # (<$) :: a -> AroundIntersection b -> AroundIntersection a Source # | |||||
| NFData a => NFData (AroundIntersection a) Source # | |||||
Defined in HGeometry.LineSegment.Intersection.Types Methods rnf :: AroundIntersection a -> () Source # | |||||
| Generic (AroundIntersection a) Source # | |||||
Defined in HGeometry.LineSegment.Intersection.Types Associated Types
Methods from :: AroundIntersection a -> Rep (AroundIntersection a) x Source # to :: Rep (AroundIntersection a) x -> AroundIntersection a Source # | |||||
| Show a => Show (AroundIntersection a) Source # | |||||
Defined in HGeometry.LineSegment.Intersection.Types | |||||
| Eq a => Eq (AroundIntersection a) Source # | |||||
Defined in HGeometry.LineSegment.Intersection.Types Methods (==) :: AroundIntersection a -> AroundIntersection a -> Bool Source # (/=) :: AroundIntersection a -> AroundIntersection a -> Bool Source # | |||||
| Wrapped (AroundIntersection a) Source # | |||||
Defined in HGeometry.LineSegment.Intersection.Types Associated Types
Methods _Wrapped' :: Iso' (AroundIntersection a) (Unwrapped (AroundIntersection a)) Source # | |||||
| AroundIntersection a ~ t => Rewrapped (AroundIntersection a) t Source # | |||||
Defined in HGeometry.LineSegment.Intersection.Types | |||||
| type Rep (AroundIntersection a) Source # | |||||
Defined in HGeometry.LineSegment.Intersection.Types type Rep (AroundIntersection a) = D1 ('MetaData "AroundIntersection" "HGeometry.LineSegment.Intersection.Types" "hgeometry-lineSegmentIntersection-1.0.0.0-inplace" 'True) (C1 ('MetaCons "AroundIntersection" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a))) | |||||
| type Unwrapped (AroundIntersection a) Source # | |||||
Defined in HGeometry.LineSegment.Intersection.Types | |||||
isInteriorIntersection :: Associated lineSegment -> Bool Source #
Reports whether this associated has any interior intersections
\(O(1)\)
data IntersectionPoint point lineSegment Source #
An intersection point together with all segments intersecting at this point.
Instances
| (NFData point, NFData lineSegment) => NFData (IntersectionPoint point lineSegment) Source # | |||||
Defined in HGeometry.LineSegment.Intersection.Types Methods rnf :: IntersectionPoint point lineSegment -> () Source # | |||||
| Generic (IntersectionPoint point lineSegment) Source # | |||||
Defined in HGeometry.LineSegment.Intersection.Types Associated Types
Methods from :: IntersectionPoint point lineSegment -> Rep (IntersectionPoint point lineSegment) x Source # to :: Rep (IntersectionPoint point lineSegment) x -> IntersectionPoint point lineSegment Source # | |||||
| (Show point, Show lineSegment) => Show (IntersectionPoint point lineSegment) Source # | |||||
Defined in HGeometry.LineSegment.Intersection.Types | |||||
| (Eq (AroundStart lineSegment), Eq (AroundIntersection lineSegment), Eq (AroundEnd lineSegment), Eq point) => Eq (IntersectionPoint point lineSegment) Source # | |||||
Defined in HGeometry.LineSegment.Intersection.Types Methods (==) :: IntersectionPoint point lineSegment -> IntersectionPoint point lineSegment -> Bool Source # (/=) :: IntersectionPoint point lineSegment -> IntersectionPoint point lineSegment -> Bool Source # | |||||
| type Rep (IntersectionPoint point lineSegment) Source # | |||||
Defined in HGeometry.LineSegment.Intersection.Types type Rep (IntersectionPoint point lineSegment) = D1 ('MetaData "IntersectionPoint" "HGeometry.LineSegment.Intersection.Types" "hgeometry-lineSegmentIntersection-1.0.0.0-inplace" 'False) (C1 ('MetaCons "IntersectionPoint" 'PrefixI 'True) (S1 ('MetaSel ('Just "_intersectionPoint") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 point) :*: S1 ('MetaSel ('Just "_associatedSegs") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Associated lineSegment)))) | |||||
intersectionPointOf :: (LineSegment_ lineSegment point, LineSegment_ seg point, Point_ point 2 r, Ord r, Fractional r, IntersectConstraints seg lineSegment) => lineSegment -> lineSegment -> Maybe (IntersectionPoint (Point 2 r) lineSegment) Source #
Given two segments, compute an IntersectionPoint representing their intersection (if such an intersection exists).
intersectionPoint :: forall point lineSegment point' f. Functor f => (point -> f point') -> IntersectionPoint point lineSegment -> f (IntersectionPoint point' lineSegment) Source #
Lens to access the intersectionp oint
associatedSegs :: forall point lineSegment lineSegment' f. Functor f => (Associated lineSegment -> f (Associated lineSegment')) -> IntersectionPoint point lineSegment -> f (IntersectionPoint point lineSegment') Source #
Lens to access the associated segments
Arguments
| :: (LineSegment_ lineSegment endPoint, Point_ endPoint 2 r, Point_ point 2 r, Ord r, Num r, OrdArounds lineSegment) | |
| => point | |
| -> [lineSegment] | uncategorized |
| -> [lineSegment] | segments we know contain p, |
| -> IntersectionPoint point lineSegment |
Given a point p, and a bunch of segments that suposedly intersect at p, correctly categorize them.
type IntersectConstraints seg lineSegment = (OrdArounds lineSegment, IsIntersectableWith lineSegment lineSegment, Intersection lineSegment lineSegment ~ Maybe (LineSegmentLineSegmentIntersection seg), NumType seg ~ NumType lineSegment, Dimension seg ~ Dimension lineSegment) Source #
Shorthand for the more-or-less standard constraints that we need on LineSegments
type OrdArounds lineSegment = (Ord (AroundStart lineSegment), Ord (AroundEnd lineSegment)) Source #
Shorthand for the required Ord instances
ordPoints :: (Point_ point 2 r, Ord r) => point -> point -> Ordering Source #
An ordering that is decreasing on y, increasing on x
fromInteriors :: (LineSegment_ lineSegment endPoint, Point_ endPoint 2 r, Ord r, Num r) => Point 2 r -> [lineSegment] -> Set (AroundIntersection lineSegment) Source #
Helper to produce the AroundIntersection part of the associate segments
mergeInteriorsWith :: (LineSegment_ lineSegment endPoint, Point_ endPoint 2 r, Ord r, Num r) => Point 2 r -> Set (AroundIntersection lineSegment) -> Set (AroundIntersection lineSegment) -> Set (AroundIntersection lineSegment) Source #
Merge the two AroundIntersection sets; given that they all have
point p in their interior.