hgeometry-0.12.0.2: Geometric Algorithms, Data structures, and Data types.
Copyright(C) Frank Staals
Licensesee the LICENSE file
MaintainerFrank Staals
Safe HaskellNone
LanguageHaskell2010

Data.Geometry.Interval

Description

 
Synopsis

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))

Bundled Patterns

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

Instances details
Bifunctor Interval Source # 
Instance details

Defined in Data.Geometry.Interval

Methods

bimap :: (a -> b) -> (c -> d) -> Interval a c -> Interval b d #

first :: (a -> b) -> Interval a c -> Interval b c #

second :: (b -> c) -> Interval a b -> Interval a c #

Functor (Interval a) Source # 
Instance details

Defined in Data.Geometry.Interval

Methods

fmap :: (a0 -> b) -> Interval a a0 -> Interval a b #

(<$) :: a0 -> Interval a b -> Interval a a0 #

Foldable (Interval a) Source # 
Instance details

Defined in Data.Geometry.Interval

Methods

fold :: Monoid m => Interval a m -> m #

foldMap :: Monoid m => (a0 -> m) -> Interval a a0 -> m #

foldMap' :: Monoid m => (a0 -> m) -> Interval a a0 -> m #

foldr :: (a0 -> b -> b) -> b -> Interval a a0 -> b #

foldr' :: (a0 -> b -> b) -> b -> Interval a a0 -> b #

foldl :: (b -> a0 -> b) -> b -> Interval a a0 -> b #

foldl' :: (b -> a0 -> b) -> b -> Interval a a0 -> b #

foldr1 :: (a0 -> a0 -> a0) -> Interval a a0 -> a0 #

foldl1 :: (a0 -> a0 -> a0) -> Interval a a0 -> a0 #

toList :: Interval a a0 -> [a0] #

null :: Interval a a0 -> Bool #

length :: Interval a a0 -> Int #

elem :: Eq a0 => a0 -> Interval a a0 -> Bool #

maximum :: Ord a0 => Interval a a0 -> a0 #

minimum :: Ord a0 => Interval a a0 -> a0 #

sum :: Num a0 => Interval a a0 -> a0 #

product :: Num a0 => Interval a a0 -> a0 #

Traversable (Interval a) Source # 
Instance details

Defined in Data.Geometry.Interval

Methods

traverse :: Applicative f => (a0 -> f b) -> Interval a a0 -> f (Interval a b) #

sequenceA :: Applicative f => Interval a (f a0) -> f (Interval a a0) #

mapM :: Monad m => (a0 -> m b) -> Interval a a0 -> m (Interval a b) #

sequence :: Monad m => Interval a (m a0) -> m (Interval a a0) #

(Eq r, Eq a) => Eq (Interval a r) Source # 
Instance details

Defined in Data.Geometry.Interval

Methods

(==) :: Interval a r -> Interval a r -> Bool #

(/=) :: Interval a r -> Interval a r -> Bool #

(Show a, Show r) => Show (Interval a r) Source # 
Instance details

Defined in Data.Geometry.Interval

Methods

showsPrec :: Int -> Interval a r -> ShowS #

show :: Interval a r -> String #

showList :: [Interval a r] -> ShowS #

Generic (Interval a r) Source # 
Instance details

Defined in Data.Geometry.Interval

Associated Types

type Rep (Interval a r) :: Type -> Type #

Methods

from :: Interval a r -> Rep (Interval a r) x #

to :: Rep (Interval a r) x -> Interval a r #

(Arbitrary r, Arbitrary a, Ord r, Ord a) => Arbitrary (Interval a r) Source # 
Instance details

Defined in Data.Geometry.Interval

Methods

arbitrary :: Gen (Interval a r) #

shrink :: Interval a r -> [Interval a r] #

(NFData a, NFData r) => NFData (Interval a r) Source # 
Instance details

Defined in Data.Geometry.Interval

Methods

rnf :: Interval a r -> () #

HasEnd (Interval a r) Source # 
Instance details

Defined in Data.Geometry.Interval

Associated Types

type EndCore (Interval a r) Source #

type EndExtra (Interval a r) Source #

Methods

end :: Lens' (Interval a r) (EndCore (Interval a r) :+ EndExtra (Interval a r)) Source #

HasStart (Interval a r) Source # 
Instance details

Defined in Data.Geometry.Interval

Associated Types

type StartCore (Interval a r) Source #

type StartExtra (Interval a r) Source #

IntervalLike (Interval p r) Source # 
Instance details

Defined in Data.Geometry.IntervalTree

Methods

asRange :: Interval p r -> Range (NumType (Interval p r)) Source #

Ord r => IsIntersectableWith (Interval a r) (Interval a r) Source # 
Instance details

Defined in Data.Geometry.Interval

Methods

intersect :: Interval a r -> Interval a r -> Intersection (Interval a r) (Interval a r) #

intersects :: Interval a r -> Interval a r -> Bool #

nonEmptyIntersection :: proxy (Interval a r) -> proxy (Interval a r) -> Intersection (Interval a r) (Interval a r) -> Bool #

type Rep (Interval a r) Source # 
Instance details

Defined in Data.Geometry.Interval

type Rep (Interval a r) = D1 ('MetaData "Interval" "Data.Geometry.Interval" "hgeometry-0.12.0.2-IMXeR0PuShPEjPCARytEWE" 'True) (C1 ('MetaCons "GInterval" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Range (r :+ a)))))
type NumType (Interval a r) Source # 
Instance details

Defined in Data.Geometry.Interval

type NumType (Interval a r) = r
type Dimension (Interval a r) Source # 
Instance details

Defined in Data.Geometry.Interval

type Dimension (Interval a r) = 1
type EndCore (Interval a r) Source # 
Instance details

Defined in Data.Geometry.Interval

type EndCore (Interval a r) = r
type EndExtra (Interval a r) Source # 
Instance details

Defined in Data.Geometry.Interval

type EndExtra (Interval a r) = a
type StartCore (Interval a r) Source # 
Instance details

Defined in Data.Geometry.Interval

type StartCore (Interval a r) = r
type StartExtra (Interval a r) Source # 
Instance details

Defined in Data.Geometry.Interval

type StartExtra (Interval a r) = a
type IntersectionOf (Interval a r) (Interval a r) Source # 
Instance details

Defined in Data.Geometry.Interval

fromRange :: Range (r :+ a) -> Interval a r Source #

Constrct an interval from a Range

toRange :: Interval a r -> Range (r :+ a) Source #

Cast an interval to a range.

_Range :: Iso' (Interval a r) (Range (r :+ a)) Source #

Intervals and ranges are isomorphic.

querying the start and end of intervals

class HasStart t where Source #

Associated Types

type StartCore t Source #

type StartExtra t Source #

Instances

Instances details
HasStart (Interval a r) Source # 
Instance details

Defined in Data.Geometry.Interval

Associated Types

type StartCore (Interval a r) Source #

type StartExtra (Interval a r) Source #

HasStart (HalfLine d r) Source # 
Instance details

Defined in Data.Geometry.HalfLine

Associated Types

type StartCore (HalfLine d r) Source #

type StartExtra (HalfLine d r) Source #

HasStart (LineSegment d p r) Source # 
Instance details

Defined in Data.Geometry.LineSegment.Internal

Associated Types

type StartCore (LineSegment d p r) Source #

type StartExtra (LineSegment d p r) Source #

HasStart (PolyLine d p r) Source # 
Instance details

Defined in Data.Geometry.PolyLine

Associated Types

type StartCore (PolyLine d p r) Source #

type StartExtra (PolyLine d p r) Source #

Methods

start :: Lens' (PolyLine d p r) (StartCore (PolyLine d p r) :+ StartExtra (PolyLine d p r)) Source #

class HasEnd t where Source #

Associated Types

type EndCore t Source #

type EndExtra t Source #

Methods

end :: Lens' t (EndCore t :+ EndExtra t) Source #

Instances

Instances details
HasEnd (Interval a r) Source # 
Instance details

Defined in Data.Geometry.Interval

Associated Types

type EndCore (Interval a r) Source #

type EndExtra (Interval a r) Source #

Methods

end :: Lens' (Interval a r) (EndCore (Interval a r) :+ EndExtra (Interval a r)) Source #

HasEnd (LineSegment d p r) Source # 
Instance details

Defined in Data.Geometry.LineSegment.Internal

Associated Types

type EndCore (LineSegment d p r) Source #

type EndExtra (LineSegment d p r) Source #

Methods

end :: Lens' (LineSegment d p r) (EndCore (LineSegment d p r) :+ EndExtra (LineSegment d p r)) Source #

HasEnd (PolyLine d p r) Source # 
Instance details

Defined in Data.Geometry.PolyLine

Associated Types

type EndCore (PolyLine d p r) Source #

type EndExtra (PolyLine d p r) Source #

Methods

end :: Lens' (PolyLine d p r) (EndCore (PolyLine d p r) :+ EndExtra (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