hgeometry-0.11.0.0: Geometric Algorithms, Data structures, and Data types.

Data.Geometry.Interval

Synopsis

# 1 dimensional Intervals

data Interval a r 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))

Instances
 Source # Instance detailsDefined in Data.Geometry.Interval Methodsbimap :: (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 # Source # Instance detailsDefined in Data.Geometry.Interval Methodsfmap :: (a0 -> b) -> Interval a a0 -> Interval a b #(<\$) :: a0 -> Interval a b -> Interval a a0 # Source # Instance detailsDefined in Data.Geometry.Interval Methodsfold :: Monoid m => Interval a m -> 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 # Source # Instance detailsDefined in Data.Geometry.Interval Methodstraverse :: 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 detailsDefined 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 detailsDefined in Data.Geometry.Interval MethodsshowsPrec :: Int -> Interval a r -> ShowS #show :: Interval a r -> String #showList :: [Interval a r] -> ShowS # Generic (Interval a r) Source # Instance detailsDefined in Data.Geometry.Interval Associated Typestype Rep (Interval a r) :: Type -> Type # Methodsfrom :: 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 detailsDefined in Data.Geometry.Interval Methodsarbitrary :: Gen (Interval a r) #shrink :: Interval a r -> [Interval a r] # (NFData a, NFData r) => NFData (Interval a r) Source # Instance detailsDefined in Data.Geometry.Interval Methodsrnf :: Interval a r -> () # HasEnd (Interval a r) Source # Instance detailsDefined in Data.Geometry.Interval Associated Typestype EndCore (Interval a r) :: Type Source #type EndExtra (Interval a r) :: Type Source # Methodsend :: Lens' (Interval a r) (EndCore (Interval a r) :+ EndExtra (Interval a r)) Source # HasStart (Interval a r) Source # Instance detailsDefined in Data.Geometry.Interval Associated Typestype StartCore (Interval a r) :: Type Source #type StartExtra (Interval a r) :: Type Source # Methodsstart :: Lens' (Interval a r) (StartCore (Interval a r) :+ StartExtra (Interval a r)) Source # IntervalLike (Interval p r) Source # Instance detailsDefined in Data.Geometry.IntervalTree MethodsasRange :: Interval p r -> Range (NumType (Interval p r)) Source # Ord r => IsIntersectableWith (Interval a r) (Interval a r) Source # Instance detailsDefined in Data.Geometry.Interval Methodsintersect :: 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 detailsDefined in Data.Geometry.Interval type Rep (Interval a r) = D1 (MetaData "Interval" "Data.Geometry.Interval" "hgeometry-0.11.0.0-5Q7X7STHtn33ZJbJEL0QVy" True) (C1 (MetaCons "GInterval" PrefixI True) (S1 (MetaSel (Just "toRange") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Range (r :+ a))))) type NumType (Interval a r) Source # Instance detailsDefined in Data.Geometry.Interval type NumType (Interval a r) = r type Dimension (Interval a r) Source # Instance detailsDefined in Data.Geometry.Interval type Dimension (Interval a r) = 1 type EndCore (Interval a r) Source # Instance detailsDefined in Data.Geometry.Interval type EndCore (Interval a r) = r type EndExtra (Interval a r) Source # Instance detailsDefined in Data.Geometry.Interval type EndExtra (Interval a r) = a type StartCore (Interval a r) Source # Instance detailsDefined in Data.Geometry.Interval type StartCore (Interval a r) = r type StartExtra (Interval a r) Source # Instance detailsDefined in Data.Geometry.Interval type StartExtra (Interval a r) = a type IntersectionOf (Interval a r) (Interval a r) Source # Instance detailsDefined in Data.Geometry.Interval type IntersectionOf (Interval a r) (Interval a r) = NoIntersection ': (Interval a r ': ([] :: [Type]))

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

Constrct an interval from a Range

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

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

pattern OpenInterval :: (r :+ a) -> (r :+ a) -> Interval a r Source #

pattern ClosedInterval :: (r :+ a) -> (r :+ a) -> Interval a r Source #

pattern Interval :: EndPoint (r :+ a) -> EndPoint (r :+ a) -> Interval a r Source #

# querying the start and end of intervals

class HasStart t where Source #

Associated Types

type StartCore t Source #

type StartExtra t Source #

Methods

Instances
 HasStart (Interval a r) Source # Instance detailsDefined in Data.Geometry.Interval Associated Typestype StartCore (Interval a r) :: Type Source #type StartExtra (Interval a r) :: Type Source # Methodsstart :: Lens' (Interval a r) (StartCore (Interval a r) :+ StartExtra (Interval a r)) Source # HasStart (HalfLine d r) Source # Instance detailsDefined in Data.Geometry.HalfLine Associated Typestype StartCore (HalfLine d r) :: Type Source #type StartExtra (HalfLine d r) :: Type Source # Methodsstart :: Lens' (HalfLine d r) (StartCore (HalfLine d r) :+ StartExtra (HalfLine d r)) Source # HasStart (LineSegment d p r) Source # Instance detailsDefined in Data.Geometry.LineSegment Associated Typestype StartCore (LineSegment d p r) :: Type Source #type StartExtra (LineSegment d p r) :: Type Source # Methodsstart :: Lens' (LineSegment d p r) (StartCore (LineSegment d p r) :+ StartExtra (LineSegment 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
 HasEnd (Interval a r) Source # Instance detailsDefined in Data.Geometry.Interval Associated Typestype EndCore (Interval a r) :: Type Source #type EndExtra (Interval a r) :: Type Source # Methodsend :: Lens' (Interval a r) (EndCore (Interval a r) :+ EndExtra (Interval a r)) Source # HasEnd (LineSegment d p r) Source # Instance detailsDefined in Data.Geometry.LineSegment Associated Typestype EndCore (LineSegment d p r) :: Type Source #type EndExtra (LineSegment d p r) :: Type Source # Methodsend :: Lens' (LineSegment d p r) (EndCore (LineSegment d p r) :+ EndExtra (LineSegment 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