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

Data.Geometry.LineSegment

Description

Line segment data type and some basic functions on line segments

Synopsis

Documentation

data LineSegment d p r where Source #

Line segments. LineSegments have a start and end point, both of which may contain additional data of type p. We can think of a Line-Segment being defined as

>>> data LineSegment d p r = LineSegment (EndPoint (Point d r :+ p)) (EndPoint (Point d r :+ p))

it is assumed that the two endpoints of the line segment are disjoint. This is not checked.

Bundled Patterns

pattern LineSegment :: EndPoint (Point d r :+ p) -> EndPoint (Point d r :+ p) -> LineSegment d p r 
pattern LineSegment' :: (Point d r :+ p) -> (Point d r :+ p) -> LineSegment d p r

Gets the start and end point, but forgetting if they are open or closed.

pattern ClosedLineSegment :: (Point d r :+ p) -> (Point d r :+ p) -> LineSegment d p r 
pattern OpenLineSegment :: (Point d r :+ p) -> (Point d r :+ p) -> LineSegment d p r 

Instances

Instances details
Arity d => Bifunctor (LineSegment d) Source # 
Instance details

Defined in Data.Geometry.LineSegment.Internal

Methods

bimap :: (a -> b) -> (c -> d0) -> LineSegment d a c -> LineSegment d b d0 #

first :: (a -> b) -> LineSegment d a c -> LineSegment d b c #

second :: (b -> c) -> LineSegment d a b -> LineSegment d a c #

Arity d => Functor (LineSegment d p) Source # 
Instance details

Defined in Data.Geometry.LineSegment.Internal

Methods

fmap :: (a -> b) -> LineSegment d p a -> LineSegment d p b #

(<$) :: a -> LineSegment d p b -> LineSegment d p a #

PointFunctor (LineSegment d p) Source # 
Instance details

Defined in Data.Geometry.LineSegment.Internal

Methods

pmap :: (Point (Dimension (LineSegment d p r)) r -> Point (Dimension (LineSegment d p s)) s) -> LineSegment d p r -> LineSegment d p s Source #

(Ord r, Fractional r, Arity d) => IsIntersectableWith (Point d r) (LineSegment d p r) Source # 
Instance details

Defined in Data.Geometry.LineSegment.Internal

Methods

intersect :: Point d r -> LineSegment d p r -> Intersection (Point d r) (LineSegment d p r) #

intersects :: Point d r -> LineSegment d p r -> Bool #

nonEmptyIntersection :: proxy (Point d r) -> proxy (LineSegment d p r) -> Intersection (Point d r) (LineSegment d p r) -> Bool #

(Ord r, Num r) => IsIntersectableWith (Point 2 r) (LineSegment 2 p r) Source # 
Instance details

Defined in Data.Geometry.LineSegment.Internal

Methods

intersect :: Point 2 r -> LineSegment 2 p r -> Intersection (Point 2 r) (LineSegment 2 p r) #

intersects :: Point 2 r -> LineSegment 2 p r -> Bool #

nonEmptyIntersection :: proxy (Point 2 r) -> proxy (LineSegment 2 p r) -> Intersection (Point 2 r) (LineSegment 2 p r) -> Bool #

(Eq r, Eq p, Arity d) => Eq (LineSegment d p r) Source # 
Instance details

Defined in Data.Geometry.LineSegment.Internal

Methods

(==) :: LineSegment d p r -> LineSegment d p r -> Bool #

(/=) :: LineSegment d p r -> LineSegment d p r -> Bool #

(Read r, Read p, Arity d) => Read (LineSegment d p r) Source # 
Instance details

Defined in Data.Geometry.LineSegment.Internal

(Show r, Show p, Arity d) => Show (LineSegment d p r) Source # 
Instance details

Defined in Data.Geometry.LineSegment.Internal

Methods

showsPrec :: Int -> LineSegment d p r -> ShowS #

show :: LineSegment d p r -> String #

showList :: [LineSegment d p r] -> ShowS #

(Arbitrary r, Arbitrary p, Eq r, Arity d) => Arbitrary (LineSegment d p r) Source # 
Instance details

Defined in Data.Geometry.LineSegment.Internal

Methods

arbitrary :: Gen (LineSegment d p r) #

shrink :: LineSegment d p r -> [LineSegment d p r] #

(Arity d, NFData r, NFData p) => NFData (LineSegment d p r) Source # 
Instance details

Defined in Data.Geometry.LineSegment.Internal

Methods

rnf :: LineSegment d p r -> () #

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 #

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 #

(Fractional r, Arity d, Arity (d + 1)) => IsTransformable (LineSegment d p r) Source # 
Instance details

Defined in Data.Geometry.LineSegment.Internal

(Num r, Arity d) => HasSupportingLine (LineSegment d p r) Source # 
Instance details

Defined in Data.Geometry.LineSegment.Internal

Arity d => IsBoxable (LineSegment d p r) Source # 
Instance details

Defined in Data.Geometry.LineSegment.Internal

Methods

boundingBox :: LineSegment d p r -> Box (Dimension (LineSegment d p r)) () (NumType (LineSegment d p r)) Source #

(Ord r, Fractional r) => IsIntersectableWith (LineSegment 2 () r) (HalfLine 2 r) Source # 
Instance details

Defined in Data.Geometry.HalfLine

Methods

intersect :: LineSegment 2 () r -> HalfLine 2 r -> Intersection (LineSegment 2 () r) (HalfLine 2 r) #

intersects :: LineSegment 2 () r -> HalfLine 2 r -> Bool #

nonEmptyIntersection :: proxy (LineSegment 2 () r) -> proxy (HalfLine 2 r) -> Intersection (LineSegment 2 () r) (HalfLine 2 r) -> Bool #

(Ord r, Fractional r) => IsIntersectableWith (LineSegment 2 p r) (Line 2 r) Source # 
Instance details

Defined in Data.Geometry.LineSegment.Internal

Methods

intersect :: LineSegment 2 p r -> Line 2 r -> Intersection (LineSegment 2 p r) (Line 2 r) #

intersects :: LineSegment 2 p r -> Line 2 r -> Bool #

nonEmptyIntersection :: proxy (LineSegment 2 p r) -> proxy (Line 2 r) -> Intersection (LineSegment 2 p r) (Line 2 r) -> Bool #

(Ord r, Floating r) => IsIntersectableWith (LineSegment 2 p r) (Circle q r) Source # 
Instance details

Defined in Data.Geometry.Ball

Methods

intersect :: LineSegment 2 p r -> Circle q r -> Intersection (LineSegment 2 p r) (Circle q r) #

intersects :: LineSegment 2 p r -> Circle q r -> Bool #

nonEmptyIntersection :: proxy (LineSegment 2 p r) -> proxy (Circle q r) -> Intersection (LineSegment 2 p r) (Circle q r) -> Bool #

(Ord r, Fractional r) => IsIntersectableWith (LineSegment 2 p r) (LineSegment 2 p r) Source # 
Instance details

Defined in Data.Geometry.LineSegment.Internal

Methods

intersect :: LineSegment 2 p r -> LineSegment 2 p r -> Intersection (LineSegment 2 p r) (LineSegment 2 p r) #

intersects :: LineSegment 2 p r -> LineSegment 2 p r -> Bool #

nonEmptyIntersection :: proxy (LineSegment 2 p r) -> proxy (LineSegment 2 p r) -> Intersection (LineSegment 2 p r) (LineSegment 2 p r) -> Bool #

(Fractional r, Ord r, HasBoundingLines o) => IsIntersectableWith (LineSegment 2 a r) (Slab o a r) Source # 
Instance details

Defined in Data.Geometry.Slab

Methods

intersect :: LineSegment 2 a r -> Slab o a r -> Intersection (LineSegment 2 a r) (Slab o a r) #

intersects :: LineSegment 2 a r -> Slab o a r -> Bool #

nonEmptyIntersection :: proxy (LineSegment 2 a r) -> proxy (Slab o a r) -> Intersection (LineSegment 2 a r) (Slab o a r) -> Bool #

type IntersectionOf (Point d r) (LineSegment d p r) Source # 
Instance details

Defined in Data.Geometry.LineSegment.Internal

type IntersectionOf (Point d r) (LineSegment d p r) = '[NoIntersection, Point d r]
type NumType (LineSegment d p r) Source # 
Instance details

Defined in Data.Geometry.LineSegment.Internal

type NumType (LineSegment d p r) = r
type Dimension (LineSegment d p r) Source # 
Instance details

Defined in Data.Geometry.LineSegment.Internal

type Dimension (LineSegment d p r) = d
type EndCore (LineSegment d p r) Source # 
Instance details

Defined in Data.Geometry.LineSegment.Internal

type EndCore (LineSegment d p r) = Point d r
type EndExtra (LineSegment d p r) Source # 
Instance details

Defined in Data.Geometry.LineSegment.Internal

type EndExtra (LineSegment d p r) = p
type StartCore (LineSegment d p r) Source # 
Instance details

Defined in Data.Geometry.LineSegment.Internal

type StartCore (LineSegment d p r) = Point d r
type StartExtra (LineSegment d p r) Source # 
Instance details

Defined in Data.Geometry.LineSegment.Internal

type StartExtra (LineSegment d p r) = p
type IntersectionOf (LineSegment 2 p r) (Line 2 r) Source # 
Instance details

Defined in Data.Geometry.LineSegment.Internal

type IntersectionOf (LineSegment 2 p r) (Line 2 r) = '[NoIntersection, Point 2 r, LineSegment 2 p r]
type IntersectionOf (LineSegment 2 p r) (HalfLine 2 r) Source # 
Instance details

Defined in Data.Geometry.HalfLine

type IntersectionOf (LineSegment 2 p r) (HalfLine 2 r) = '[NoIntersection, Point 2 r, LineSegment 2 () r]
type IntersectionOf (LineSegment 2 p r) (Circle q r) Source #

A line segment may not intersect a circle, touch it, or intersect it properly in one or two points.

Instance details

Defined in Data.Geometry.Ball

type IntersectionOf (LineSegment 2 p r) (Circle q r) = '[NoIntersection, Touching (Point 2 r), Point 2 r, (Point 2 r, Point 2 r)]
type IntersectionOf (LineSegment 2 p r) (LineSegment 2 p r) Source # 
Instance details

Defined in Data.Geometry.LineSegment.Internal

type IntersectionOf (LineSegment 2 p r) (Slab o a r) Source # 
Instance details

Defined in Data.Geometry.Slab

type IntersectionOf (LineSegment 2 p r) (Slab o a r) = '[NoIntersection, LineSegment 2 () r]

endPoints :: Traversal (LineSegment d p r) (LineSegment d' q s) (Point d r :+ p) (Point d' s :+ q) Source #

Traversal to access the endpoints. Note that this traversal allows you to change more or less everything, even the dimension and the numeric type used, but it preservers if the segment is open or closed.

_SubLine :: (Num r, Arity d) => Iso' (LineSegment d p r) (SubLine d p r r) Source #

shiftRight :: Num r => r -> Range r -> Range r #

Shifts the range to the right

>>> prettyShow $ shiftRight 10 (ClosedRange 10 20)
"[20,30]"
>>> prettyShow $ shiftRight 10 (OpenRange 15 25)
"(25,35)"

shiftLeft :: Num r => r -> Range r -> Range r #

Shift a range x units to the left

>>> prettyShow $ shiftLeft 10 (ClosedRange 10 20)
"[0,10]"
>>> prettyShow $ shiftLeft 10 (OpenRange 15 25)
"(5,15)"

isValid :: Ord a => Range a -> Bool #

Check if the range is valid and nonEmpty, i.e. if the lower endpoint is indeed smaller than the right endpoint. Note that we treat empty open-ranges as invalid as well.

covers :: Ord a => Range a -> Range a -> Bool #

Wether or not the first range completely covers the second one

clipUpper :: Ord a => EndPoint a -> Range a -> Maybe (Range a) #

Clip the interval from above. I.e. intersect with (-infty, u}, where } is either open, ), or closed, ],

clipLower :: Ord a => EndPoint a -> Range a -> Maybe (Range a) #

Clip the interval from below. I.e. intersect with the interval {l,infty), where { is either open, (, orr closed, [.

clampTo :: Ord r => Range r -> r -> r #

Clamps a value to a range. I.e. if the value lies outside the range we report the closest value "in the range". Note that if an endpoint of the range is open we report that value anyway, so we return a value that is truely inside the range only if that side of the range is closed.

>>> clampTo (ClosedRange 0 10) 20
10
>>> clampTo (ClosedRange 0 10) (-20)
0
>>> clampTo (ClosedRange 0 10) 5
5
>>> clampTo (OpenRange 0 10) 20
10
>>> clampTo (OpenRange 0 10) (-20)
0
>>> clampTo (OpenRange 0 10) 5
5

inRange :: Ord a => a -> Range a -> Bool #

Test if a value lies in a range.

>>> 1 `inRange` (OpenRange 0 2)
True
>>> 1 `inRange` (OpenRange 0 1)
False
>>> 1 `inRange` (ClosedRange 0 1)
True
>>> 1 `inRange` (ClosedRange 1 1)
True
>>> 10 `inRange` (OpenRange 1 10)
False
>>> 10 `inRange` (ClosedRange 0 1)
False

This one is kind of weird

>>> 0 `inRange` Range (Closed 0) (Open 0)
False

prettyShow :: Show a => Range a -> String #

Helper function to show a range in mathematical notation.

>>> prettyShow $ OpenRange 0 2
"(0,2)"
>>> prettyShow $ ClosedRange 0 2
"[0,2]"
>>> prettyShow $ Range (Open 0) (Closed 5)
"(0,5]"

upper :: Lens' (Range a) (EndPoint a) #

Lens access for the upper part of a range.

lower :: Lens' (Range a) (EndPoint a) #

Lens access for the lower part of a range.

isClosed :: EndPoint a -> Bool #

True iff EndPoint is closed.

isOpen :: EndPoint a -> Bool #

True iff EndPoint is open.

unEndPoint :: Lens (EndPoint a) (EndPoint b) a b #

Access lens for EndPoint value regardless of whether it is open or closed.

>>> Open 5 ^. unEndPoint
5
>>> Closed 10 ^. unEndPoint
10
>>> Open 4 & unEndPoint .~ 0
Open 0

data EndPoint a #

Endpoints of a range may either be open or closed.

Constructors

Open !a 
Closed !a 

Instances

Instances details
Functor EndPoint 
Instance details

Defined in Data.Range

Methods

fmap :: (a -> b) -> EndPoint a -> EndPoint b #

(<$) :: a -> EndPoint b -> EndPoint a #

Foldable EndPoint 
Instance details

Defined in Data.Range

Methods

fold :: Monoid m => EndPoint m -> m #

foldMap :: Monoid m => (a -> m) -> EndPoint a -> m #

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

foldr :: (a -> b -> b) -> b -> EndPoint a -> b #

foldr' :: (a -> b -> b) -> b -> EndPoint a -> b #

foldl :: (b -> a -> b) -> b -> EndPoint a -> b #

foldl' :: (b -> a -> b) -> b -> EndPoint a -> b #

foldr1 :: (a -> a -> a) -> EndPoint a -> a #

foldl1 :: (a -> a -> a) -> EndPoint a -> a #

toList :: EndPoint a -> [a] #

null :: EndPoint a -> Bool #

length :: EndPoint a -> Int #

elem :: Eq a => a -> EndPoint a -> Bool #

maximum :: Ord a => EndPoint a -> a #

minimum :: Ord a => EndPoint a -> a #

sum :: Num a => EndPoint a -> a #

product :: Num a => EndPoint a -> a #

Traversable EndPoint 
Instance details

Defined in Data.Range

Methods

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

sequenceA :: Applicative f => EndPoint (f a) -> f (EndPoint a) #

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

sequence :: Monad m => EndPoint (m a) -> m (EndPoint a) #

Read1 EndPoint 
Instance details

Defined in Data.Range

Methods

liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (EndPoint a) #

liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [EndPoint a] #

liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (EndPoint a) #

liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [EndPoint a] #

Show1 EndPoint 
Instance details

Defined in Data.Range

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> EndPoint a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [EndPoint a] -> ShowS #

Eq a => Eq (EndPoint a) 
Instance details

Defined in Data.Range

Methods

(==) :: EndPoint a -> EndPoint a -> Bool #

(/=) :: EndPoint a -> EndPoint a -> Bool #

Ord a => Ord (EndPoint a) 
Instance details

Defined in Data.Range

Methods

compare :: EndPoint a -> EndPoint a -> Ordering #

(<) :: EndPoint a -> EndPoint a -> Bool #

(<=) :: EndPoint a -> EndPoint a -> Bool #

(>) :: EndPoint a -> EndPoint a -> Bool #

(>=) :: EndPoint a -> EndPoint a -> Bool #

max :: EndPoint a -> EndPoint a -> EndPoint a #

min :: EndPoint a -> EndPoint a -> EndPoint a #

Read a => Read (EndPoint a) 
Instance details

Defined in Data.Range

Show a => Show (EndPoint a) 
Instance details

Defined in Data.Range

Methods

showsPrec :: Int -> EndPoint a -> ShowS #

show :: EndPoint a -> String #

showList :: [EndPoint a] -> ShowS #

Generic (EndPoint a) 
Instance details

Defined in Data.Range

Associated Types

type Rep (EndPoint a) :: Type -> Type #

Methods

from :: EndPoint a -> Rep (EndPoint a) x #

to :: Rep (EndPoint a) x -> EndPoint a #

Arbitrary r => Arbitrary (EndPoint r) 
Instance details

Defined in Data.Range

Methods

arbitrary :: Gen (EndPoint r) #

shrink :: EndPoint r -> [EndPoint r] #

NFData a => NFData (EndPoint a) 
Instance details

Defined in Data.Range

Methods

rnf :: EndPoint a -> () #

type Rep (EndPoint a) 
Instance details

Defined in Data.Range

type Rep (EndPoint a) = D1 ('MetaData "EndPoint" "Data.Range" "hgeometry-combinatorial-0.12.0.0-VIzkyOvE5y1mf3MPLhQ6V" 'False) (C1 ('MetaCons "Open" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a)) :+: C1 ('MetaCons "Closed" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a)))

data Range a #

Data type for representing ranges.

Constructors

Range 

Fields

Bundled Patterns

pattern OpenRange :: a -> a -> Range a 
pattern ClosedRange :: a -> a -> Range a 
pattern Range' :: a -> a -> Range a

A range from l to u, ignoring/forgetting the type of the endpoints

Instances

Instances details
Functor Range 
Instance details

Defined in Data.Range

Methods

fmap :: (a -> b) -> Range a -> Range b #

(<$) :: a -> Range b -> Range a #

Foldable Range 
Instance details

Defined in Data.Range

Methods

fold :: Monoid m => Range m -> m #

foldMap :: Monoid m => (a -> m) -> Range a -> m #

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

foldr :: (a -> b -> b) -> b -> Range a -> b #

foldr' :: (a -> b -> b) -> b -> Range a -> b #

foldl :: (b -> a -> b) -> b -> Range a -> b #

foldl' :: (b -> a -> b) -> b -> Range a -> b #

foldr1 :: (a -> a -> a) -> Range a -> a #

foldl1 :: (a -> a -> a) -> Range a -> a #

toList :: Range a -> [a] #

null :: Range a -> Bool #

length :: Range a -> Int #

elem :: Eq a => a -> Range a -> Bool #

maximum :: Ord a => Range a -> a #

minimum :: Ord a => Range a -> a #

sum :: Num a => Range a -> a #

product :: Num a => Range a -> a #

Traversable Range 
Instance details

Defined in Data.Range

Methods

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

sequenceA :: Applicative f => Range (f a) -> f (Range a) #

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

sequence :: Monad m => Range (m a) -> m (Range a) #

Read1 Range 
Instance details

Defined in Data.Range

Methods

liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (Range a) #

liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [Range a] #

liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (Range a) #

liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [Range a] #

Show1 Range 
Instance details

Defined in Data.Range

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Range a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Range a] -> ShowS #

Eq a => Eq (Range a) 
Instance details

Defined in Data.Range

Methods

(==) :: Range a -> Range a -> Bool #

(/=) :: Range a -> Range a -> Bool #

Read a => Read (Range a) 
Instance details

Defined in Data.Range

Show a => Show (Range a) 
Instance details

Defined in Data.Range

Methods

showsPrec :: Int -> Range a -> ShowS #

show :: Range a -> String #

showList :: [Range a] -> ShowS #

Generic (Range a) 
Instance details

Defined in Data.Range

Associated Types

type Rep (Range a) :: Type -> Type #

Methods

from :: Range a -> Rep (Range a) x #

to :: Rep (Range a) x -> Range a #

(Arbitrary r, Ord r) => Arbitrary (Range r) 
Instance details

Defined in Data.Range

Methods

arbitrary :: Gen (Range r) #

shrink :: Range r -> [Range r] #

NFData a => NFData (Range a) 
Instance details

Defined in Data.Range

Methods

rnf :: Range a -> () #

IntervalLike (Range r) Source # 
Instance details

Defined in Data.Geometry.IntervalTree

Methods

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

Ord a => IsIntersectableWith (Range a) (Range a) 
Instance details

Defined in Data.Range

Methods

intersect :: Range a -> Range a -> Intersection (Range a) (Range a) #

intersects :: Range a -> Range a -> Bool #

nonEmptyIntersection :: proxy (Range a) -> proxy (Range a) -> Intersection (Range a) (Range a) -> Bool #

type Rep (Range a) 
Instance details

Defined in Data.Range

type Rep (Range a) = D1 ('MetaData "Range" "Data.Range" "hgeometry-combinatorial-0.12.0.0-VIzkyOvE5y1mf3MPLhQ6V" 'False) (C1 ('MetaCons "Range" 'PrefixI 'True) (S1 ('MetaSel ('Just "_lower") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (EndPoint a)) :*: S1 ('MetaSel ('Just "_upper") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (EndPoint a))))
type NumType (Range a) Source # 
Instance details

Defined in Data.Geometry.Properties

type NumType (Range a) = a
type IntersectionOf (Range a) (Range a) 
Instance details

Defined in Data.Range

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 #

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 #

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 ClosedInterval :: (r :+ a) -> (r :+ a) -> Interval a r 
pattern Interval :: EndPoint (r :+ a) -> EndPoint (r :+ a) -> Interval a r 
pattern OpenInterval :: (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.0-3A6BqD11e4bE4Mwo2IplDZ" '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

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.

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

Constrct an interval from a Range

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.

toLineSegment :: (Monoid p, Num r, Arity d) => Line d r -> LineSegment d p r Source #

Directly convert a line into a line segment.

orderedEndPoints :: Ord r => LineSegment 2 p r -> (Point 2 r :+ p, Point 2 r :+ p) Source #

The left and right end point (or left below right if they have equal x-coords)

segmentLength :: (Arity d, Floating r) => LineSegment d p r -> r Source #

Length of the line segment

sqSegmentLength :: (Arity d, Num r) => LineSegment d p r -> r Source #

sqDistanceToSeg :: (Arity d, Fractional r, Ord r) => Point d r -> LineSegment d p r -> r Source #

Squared distance from the point to the Segment s. The same remark as for the sqDistanceToSegArg applies here.

sqDistanceToSegArg :: (Arity d, Fractional r, Ord r) => Point d r -> LineSegment d p r -> (r, Point d r) Source #

Squared distance from the point to the Segment s, and the point on s realizing it. Note that if the segment is *open*, the closest point returned may be one of the (open) end points, even though technically the end point does not lie on the segment. (The true closest point then lies arbitrarily close to the end point).

flipSegment :: LineSegment d p r -> LineSegment d p r Source #

flips the start and end point of the segment

interpolate :: (Fractional r, Arity d) => r -> LineSegment d p r -> Point d r Source #

Linearly interpolate the two endpoints with a value in the range [0,1]

>>> interpolate 0.5 $ ClosedLineSegment (ext $ origin) (ext $ Point2 10.0 10.0)
Point2 5.0 5.0
>>> interpolate 0.1 $ ClosedLineSegment (ext $ origin) (ext $ Point2 10.0 10.0)
Point2 1.0 1.0
>>> interpolate 0 $ ClosedLineSegment (ext $ origin) (ext $ Point2 10.0 10.0)
Point2 0.0 0.0
>>> interpolate 1 $ ClosedLineSegment (ext $ origin) (ext $ Point2 10.0 10.0)
Point2 10.0 10.0