| Copyright | (C) Frank Staals |
|---|---|
| License | see the LICENSE file |
| Maintainer | Frank Staals |
| Safe Haskell | None |
| Language | GHC2024 |
HGeometry.Interval.Class
Description
Intervals
Synopsis
- class (IntervalLike_ interval r, NumType interval ~ r) => Interval_ interval r | interval -> r
- pattern Interval_ :: Interval_ interval r => StartPointOf interval -> EndPointOf interval -> interval
- class (HasStart interval point, HasStartPoint interval (StartPointOf interval), HasEnd interval point, HasEndPoint interval (EndPointOf interval), EndPoint_ (EndPointOf interval), IxValue (EndPointOf interval) ~ point, EndPoint_ (StartPointOf interval), IxValue (StartPointOf interval) ~ point) => IntervalLike_ interval point | interval -> point
- class Interval_ interval point => ConstructableInterval_ interval point where
- mkInterval :: StartPointOf interval -> EndPointOf interval -> interval
- buildInterval :: StartPointOf interval -> EndPointOf interval -> interval
- class (Interval_ interval r, StartPointOf interval ~ EndPoint 'Closed r, EndPointOf interval ~ EndPoint 'Closed r) => ClosedInterval_ interval r
- pattern ClosedInterval_ :: ClosedInterval_ interval r => r -> r -> interval
- class (ClosedInterval_ interval r, ConstructableInterval_ interval r) => ConstructableClosedInterval_ interval r where
- mkClosedInterval :: r -> r -> interval
- buildClosedInterval :: r -> r -> interval
- clampTo :: (ClosedInterval_ interval r, Ord r) => interval -> r -> r
- class (Interval_ interval r, StartPointOf interval ~ EndPoint 'Open r, EndPointOf interval ~ EndPoint 'Open r) => OpenInterval_ interval r | interval -> r
- pattern OpenInterval_ :: OpenInterval_ interval r => r -> r -> interval
- class (OpenInterval_ interval r, ConstructableInterval_ interval r) => ConstructableOpenInterval_ interval r | interval -> r where
- mkOpenInterval :: r -> r -> interval
- class HasStart seg p | seg -> p where
- class HasEnd seg p | seg -> p where
- startAndEnd :: (HasStart seg p, HasEnd seg p) => seg -> (p, p)
- type family StartPointOf interval
- type family EndPointOf interval
- class HasStartPoint seg p | seg -> p where
- startPoint :: Lens' seg p
- class HasEndPoint seg p | seg -> p where
- startAndEndPoint :: (HasStartPoint seg s, HasEndPoint seg e) => seg -> (s, e)
- inInterval :: forall interval r. (Ord r, Interval_ interval r) => r -> interval -> PointLocationResult
- stabsInterval :: forall interval r. (Ord r, Interval_ interval r) => r -> interval -> Bool
- compareInterval :: (Ord r, Interval_ interval r) => r -> interval -> Ordering
- compareIntervalExact :: (Ord r, Interval_ interval r) => r -> interval -> CompareInterval
- data CompareInterval
- shiftLeft :: (Num r, Interval_ interval r) => r -> interval -> interval
- shiftRight :: (Num r, Interval_ interval r) => r -> interval -> interval
- duration :: (Interval_ interval r, Num r) => interval -> r
- module HGeometry.Interval.EndPoint
Documentation
class (IntervalLike_ interval r, NumType interval ~ r) => Interval_ interval r | interval -> r Source #
A class for types representing Intervals
Instances
| Interval_ (HalfOpenInterval r) r Source # | |
Defined in HGeometry.Interval.HalfOpen | |
| Interval_ interval r => Interval_ (interval :+ extra) r Source # | |
Defined in HGeometry.Interval.Class | |
| (EndPoint_ (endPoint r), IxValue (endPoint r) ~ r) => Interval_ (Interval endPoint r) r Source # | |
Defined in HGeometry.Interval.Internal | |
pattern Interval_ :: Interval_ interval r => StartPointOf interval -> EndPointOf interval -> interval Source #
Pattern to match on intervals
class (HasStart interval point, HasStartPoint interval (StartPointOf interval), HasEnd interval point, HasEndPoint interval (EndPointOf interval), EndPoint_ (EndPointOf interval), IxValue (EndPointOf interval) ~ point, EndPoint_ (StartPointOf interval), IxValue (StartPointOf interval) ~ point) => IntervalLike_ interval point | interval -> point Source #
A class for types representing interval like objects
Instances
| IntervalLike_ (HalfOpenInterval r) r Source # | |
Defined in HGeometry.Interval.HalfOpen | |
| (IxValue (endPoint point) ~ point, EndPoint_ (endPoint point)) => IntervalLike_ (LineSegment endPoint point) point Source # | |
Defined in HGeometry.LineSegment.Internal | |
| IntervalLike_ interval point => IntervalLike_ (interval :+ extra) point Source # | |
Defined in HGeometry.Interval.Class | |
| (EndPoint_ (endPoint r), IxValue (endPoint r) ~ r) => IntervalLike_ (Interval endPoint r) r Source # | |
Defined in HGeometry.Interval.Internal | |
class Interval_ interval point => ConstructableInterval_ interval point where Source #
A class for constructable intervals
Minimal complete definition
Methods
mkInterval :: StartPointOf interval -> EndPointOf interval -> interval Source #
Construct an interval given its start and end point.
pre: start < end
buildInterval :: StartPointOf interval -> EndPointOf interval -> interval Source #
Construct an interval given two points. This makes sure the start-point comes before the endpoint.
pre: it is possible to construct a valid, non-empty interval this way. so if either endpoint is open the endpoints should not coincide.
Instances
class (Interval_ interval r, StartPointOf interval ~ EndPoint 'Closed r, EndPointOf interval ~ EndPoint 'Closed r) => ClosedInterval_ interval r Source #
A class representing closed intervals, i.e. intervals that include their endpoints
Instances
| ClosedInterval_ (ClosedInterval r) r Source # | |
Defined in HGeometry.Interval.Internal | |
| ClosedInterval_ interval r => ClosedInterval_ (interval :+ extra) r Source # | |
Defined in HGeometry.Interval.Class | |
pattern ClosedInterval_ :: ClosedInterval_ interval r => r -> r -> interval Source #
Pattern matching on an arbitrary closed interval
class (ClosedInterval_ interval r, ConstructableInterval_ interval r) => ConstructableClosedInterval_ interval r where Source #
A class representing constructable closed intervals
Minimal complete definition
Nothing
Methods
mkClosedInterval :: r -> r -> interval Source #
Construct an interval given its start and end point.
buildClosedInterval :: r -> r -> interval Source #
Construct an interval given two points. This makes sure the start-point comes before the endpoint.
Instances
| ConstructableClosedInterval_ (ClosedInterval r) r Source # | |
Defined in HGeometry.Interval.Internal Methods mkClosedInterval :: r -> r -> ClosedInterval r Source # buildClosedInterval :: r -> r -> ClosedInterval r Source # | |
| (ConstructableClosedInterval_ interval r, Default extra) => ConstructableClosedInterval_ (interval :+ extra) r Source # | |
Defined in HGeometry.Interval.Class Methods mkClosedInterval :: r -> r -> interval :+ extra Source # buildClosedInterval :: r -> r -> interval :+ extra Source # | |
clampTo :: (ClosedInterval_ interval r, Ord r) => interval -> r -> r Source #
Clamps a value to an interval. I.e. if the value lies outside the range we report the closest value "in the range".
>>>clampTo (ClosedInterval 0 10) 2010>>>clampTo (ClosedInterval 0 10) (-20)0>>>clampTo (ClosedInterval 0 10) 55
class (Interval_ interval r, StartPointOf interval ~ EndPoint 'Open r, EndPointOf interval ~ EndPoint 'Open r) => OpenInterval_ interval r | interval -> r Source #
A class representing open intervals, i.e. intervals that exclude their endpoints
Instances
| OpenInterval_ (OpenInterval r) r Source # | |
Defined in HGeometry.Interval.Internal | |
| OpenInterval_ interval r => OpenInterval_ (interval :+ extra) r Source # | |
Defined in HGeometry.Interval.Class | |
pattern OpenInterval_ :: OpenInterval_ interval r => r -> r -> interval Source #
Pattern matching on an arbitrary open interval
class (OpenInterval_ interval r, ConstructableInterval_ interval r) => ConstructableOpenInterval_ interval r | interval -> r where Source #
Constructable Open intervals
Minimal complete definition
Nothing
Methods
mkOpenInterval :: r -> r -> interval Source #
Construct an interval given its start s and end point t.
pre: s < t
Instances
| ConstructableOpenInterval_ (OpenInterval r) r Source # | |
Defined in HGeometry.Interval.Internal Methods mkOpenInterval :: r -> r -> OpenInterval r Source # | |
| (ConstructableOpenInterval_ interval r, Default extra) => ConstructableOpenInterval_ (interval :+ extra) r Source # | |
Defined in HGeometry.Interval.Class Methods mkOpenInterval :: r -> r -> interval :+ extra Source # | |
class HasStart seg p | seg -> p where Source #
Things that have a start point
Instances
| HasStart (HalfLine point) point Source # | |
| HasStart (HalfOpenInterval r) r Source # | |
Defined in HGeometry.Interval.HalfOpen Methods start :: Lens' (HalfOpenInterval r) r Source # | |
| (IxValue (endPoint point) ~ point, EndPoint_ (endPoint point)) => HasStart (LineSegment endPoint point) point Source # | |
Defined in HGeometry.LineSegment.Internal Methods start :: Lens' (LineSegment endPoint point) point Source # | |
| HasStart seg p => HasStart (seg :+ extra) p Source # | |
| (EndPoint_ (endPoint r), IxValue (endPoint r) ~ r) => HasStart (Interval endPoint r) r Source # | |
class HasEnd seg p | seg -> p where Source #
Things that have an end point
Instances
| HasEnd (HalfOpenInterval r) r Source # | |
Defined in HGeometry.Interval.HalfOpen Methods end :: Lens' (HalfOpenInterval r) r Source # | |
| (IxValue (endPoint point) ~ point, EndPoint_ (endPoint point)) => HasEnd (LineSegment endPoint point) point Source # | |
Defined in HGeometry.LineSegment.Internal Methods end :: Lens' (LineSegment endPoint point) point Source # | |
| HasEnd seg p => HasEnd (seg :+ extra) p Source # | |
| (EndPoint_ (endPoint r), IxValue (endPoint r) ~ r) => HasEnd (Interval endPoint r) r Source # | |
startAndEnd :: (HasStart seg p, HasEnd seg p) => seg -> (p, p) Source #
Get both the start and end of something that has a start and end.
type family StartPointOf interval Source #
type family to declare the type of startpoint for an interval, the idea is to define this as one of the endpoinst form the Endpoints module
Instances
| type StartPointOf (HalfOpenInterval r) Source # | |
Defined in HGeometry.Interval.HalfOpen | |
| type StartPointOf (LineSegment endPoint point) Source # | |
Defined in HGeometry.LineSegment.Internal | |
| type StartPointOf (interval :+ extra) Source # | |
Defined in HGeometry.Interval.Class | |
| type StartPointOf (Interval endPoint r) Source # | |
Defined in HGeometry.Interval.Internal | |
type family EndPointOf interval Source #
type family to declare the type of endpoint for an interval, the idea is to define this as one of the endpoinst form the Endpoints module
Instances
| type EndPointOf (HalfOpenInterval r) Source # | |
Defined in HGeometry.Interval.HalfOpen | |
| type EndPointOf (LineSegment endPoint point) Source # | |
Defined in HGeometry.LineSegment.Internal | |
| type EndPointOf (interval :+ extra) Source # | |
Defined in HGeometry.Interval.Class | |
| type EndPointOf (Interval endPoint r) Source # | |
Defined in HGeometry.Interval.Internal | |
class HasStartPoint seg p | seg -> p where Source #
Things that have a start point
Instances
| HasStartPoint (HalfOpenInterval r) (EndPoint 'Open r) Source # | |
Defined in HGeometry.Interval.HalfOpen Methods startPoint :: Lens' (HalfOpenInterval r) (EndPoint 'Open r) Source # | |
| HasStartPoint seg p => HasStartPoint (seg :+ extra) p Source # | |
Defined in HGeometry.Interval.Class Methods startPoint :: Lens' (seg :+ extra) p Source # | |
| IxValue (endPoint point) ~ point => HasStartPoint (LineSegment endPoint point) (endPoint point) Source # | |
Defined in HGeometry.LineSegment.Internal Methods startPoint :: Lens' (LineSegment endPoint point) (endPoint point) Source # | |
| HasStartPoint (Interval endPoint r) (endPoint r) Source # | |
Defined in HGeometry.Interval.Internal Methods startPoint :: Lens' (Interval endPoint r) (endPoint r) Source # | |
class HasEndPoint seg p | seg -> p where Source #
Things that have an end point
Instances
| HasEndPoint (HalfOpenInterval r) (EndPoint 'Closed r) Source # | |
Defined in HGeometry.Interval.HalfOpen | |
| HasEndPoint seg p => HasEndPoint (seg :+ extra) p Source # | |
| IxValue (endPoint point) ~ point => HasEndPoint (LineSegment endPoint point) (endPoint point) Source # | |
Defined in HGeometry.LineSegment.Internal Methods endPoint :: Lens' (LineSegment endPoint point) (endPoint point) Source # | |
| HasEndPoint (Interval endPoint r) (endPoint r) Source # | |
startAndEndPoint :: (HasStartPoint seg s, HasEndPoint seg e) => seg -> (s, e) Source #
Get both the start and end of something that has a start and end.
inInterval :: forall interval r. (Ord r, Interval_ interval r) => r -> interval -> PointLocationResult Source #
Compute where the given query value is with respect to the interval.
Note that even if the boundary of the interval is open we may return OnBoundary.
stabsInterval :: forall interval r. (Ord r, Interval_ interval r) => r -> interval -> Bool Source #
Test if the point lies inside in,or on the boundary of, the interval.
Note that even if the boundary of the interval is open we may return OnBoundary.
compareInterval :: (Ord r, Interval_ interval r) => r -> interval -> Ordering Source #
test if te point appears before (=LT), in (=EQ), or after (=GT) te interval.
>>>1 `compareInterval` (OpenInterval 0 2)EQ>>>1 `compareInterval` (OpenInterval 0 1)GT>>>1 `compareInterval` (ClosedInterval 0 1)EQ>>>10 `compareInterval` (OpenInterval 1 10)GT>>>10 `compareInterval` (ClosedInterval 0 1)GT
compareIntervalExact :: (Ord r, Interval_ interval r) => r -> interval -> CompareInterval Source #
test if te point appears before, in, or after te interval, or on one of its endpoints.
>>>1 `compareIntervalExact` (OpenInterval 0 2)Interior>>>1 `compareIntervalExact` (OpenInterval 0 1)OnEnd>>>1 `compareIntervalExact` (ClosedInterval 0 1)OnEnd>>>10 `compareIntervalExact` (OpenInterval 1 10)OnEnd>>>10 `compareIntervalExact` (ClosedInterval 0 1)After
data CompareInterval Source #
Data type to represent the result of where a point is with respect to an interval.
Instances
| Read CompareInterval Source # | |
Defined in HGeometry.Interval.Class Methods readsPrec :: Int -> ReadS CompareInterval # readList :: ReadS [CompareInterval] # | |
| Show CompareInterval Source # | |
Defined in HGeometry.Interval.Class Methods showsPrec :: Int -> CompareInterval -> ShowS # show :: CompareInterval -> String # showList :: [CompareInterval] -> ShowS # | |
| Eq CompareInterval Source # | |
Defined in HGeometry.Interval.Class Methods (==) :: CompareInterval -> CompareInterval -> Bool # (/=) :: CompareInterval -> CompareInterval -> Bool # | |
| Ord CompareInterval Source # | |
Defined in HGeometry.Interval.Class Methods compare :: CompareInterval -> CompareInterval -> Ordering # (<) :: CompareInterval -> CompareInterval -> Bool # (<=) :: CompareInterval -> CompareInterval -> Bool # (>) :: CompareInterval -> CompareInterval -> Bool # (>=) :: CompareInterval -> CompareInterval -> Bool # max :: CompareInterval -> CompareInterval -> CompareInterval # min :: CompareInterval -> CompareInterval -> CompareInterval # | |
shiftLeft :: (Num r, Interval_ interval r) => r -> interval -> interval Source #
Shifts the interval to the left by delta
shiftRight :: (Num r, Interval_ interval r) => r -> interval -> interval Source #
Shifts the interval to the right by delta
duration :: (Interval_ interval r, Num r) => interval -> r Source #
Get the duration, or length of an interval.
module HGeometry.Interval.EndPoint