Copyright | (C) Frank Staals |
---|---|
License | see the LICENSE file |
Maintainer | Frank Staals |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- data Interval a r where
- fromRange :: Range (r :+ a) -> Interval a r
- toRange :: Interval a r -> Range (r :+ a)
- _Range :: Iso' (Interval a r) (Range (r :+ a))
- class HasStart t where
- type StartCore t
- type StartExtra t
- start :: Lens' t (StartCore t :+ StartExtra t)
- class HasEnd t where
- inInterval :: Ord r => r -> Interval a r -> Bool
- shiftLeft' :: Num r => r -> Interval a r -> Interval a r
- asProperInterval :: Ord r => Interval p r -> Interval p r
- flipInterval :: Interval a r -> Interval a r
- module Data.Range
1 dimensional Intervals
data Interval a r where Source #
An Interval is essentially a Range
but with possible payload
We can think of an interval being defined as:
>>>
data Interval a r = Interval (EndPoint (r :+ a)) (EndPoint (r :+ a))
pattern Interval :: EndPoint (r :+ a) -> EndPoint (r :+ a) -> Interval a r | |
pattern OpenInterval :: (r :+ a) -> (r :+ a) -> Interval a r | |
pattern ClosedInterval :: (r :+ a) -> (r :+ a) -> Interval a r |
Instances
querying the start and end of intervals
class HasStart t where Source #
Instances
HasStart (Interval a r) Source # | |
HasStart (HalfLine d r) Source # | |
HasStart (LineSegment d p r) Source # | |
Defined in Data.Geometry.LineSegment.Internal type StartCore (LineSegment d p r) Source # type StartExtra (LineSegment d p r) Source # start :: Lens' (LineSegment d p r) (StartCore (LineSegment d p r) :+ StartExtra (LineSegment d p r)) Source # | |
HasStart (PolyLine d p r) Source # | |
Instances
HasEnd (Interval a r) Source # | |
HasEnd (LineSegment d p r) Source # | |
Defined in Data.Geometry.LineSegment.Internal type EndCore (LineSegment d p r) Source # type EndExtra (LineSegment d p r) Source # end :: Lens' (LineSegment d p r) (EndCore (LineSegment d p r) :+ EndExtra (LineSegment d p r)) Source # | |
HasEnd (PolyLine d p r) Source # | |
Working with intervals
inInterval :: Ord r => r -> Interval a r -> Bool Source #
Test if a value lies in an interval. Note that the difference between inInterval and inRange is that the extra value is *not* used in the comparison with inInterval, whereas it is in inRange.
shiftLeft' :: Num r => r -> Interval a r -> Interval a r Source #
Shifts the interval to the left by delta
asProperInterval :: Ord r => Interval p r -> Interval p r Source #
Makes sure the start and endpoint are oriented such that the starting value is smaller than the ending value.
flipInterval :: Interval a r -> Interval a r Source #
Flips the start and endpoint of the interval.
module Data.Range