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

Safe HaskellNone
LanguageHaskell2010

Data.Geometry.Box.Internal

Contents

Synopsis

Documentation

newtype CWMin a Source #

Coordinate wize minimum

Constructors

CWMin 

Fields

Instances

Functor CWMin Source # 

Methods

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

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

Foldable CWMin Source # 

Methods

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

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

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

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

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

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

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

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

toList :: CWMin a -> [a] #

null :: CWMin a -> Bool #

length :: CWMin a -> Int #

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

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

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

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

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

Traversable CWMin Source # 

Methods

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

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

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

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

Eq a => Eq (CWMin a) Source # 

Methods

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

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

Ord a => Ord (CWMin a) Source # 

Methods

compare :: CWMin a -> CWMin a -> Ordering #

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

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

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

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

max :: CWMin a -> CWMin a -> CWMin a #

min :: CWMin a -> CWMin a -> CWMin a #

Show a => Show (CWMin a) Source # 

Methods

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

show :: CWMin a -> String #

showList :: [CWMin a] -> ShowS #

Generic (CWMin a) Source # 

Associated Types

type Rep (CWMin a) :: * -> * #

Methods

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

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

(Arity d, Ord r) => Semigroup (CWMin (Point d r)) Source # 

Methods

(<>) :: CWMin (Point d r) -> CWMin (Point d r) -> CWMin (Point d r) #

sconcat :: NonEmpty (CWMin (Point d r)) -> CWMin (Point d r) #

stimes :: Integral b => b -> CWMin (Point d r) -> CWMin (Point d r) #

NFData a => NFData (CWMin a) Source # 

Methods

rnf :: CWMin a -> () #

type Rep (CWMin a) Source # 
type Rep (CWMin a) = D1 (MetaData "CWMin" "Data.Geometry.Box.Internal" "hgeometry-0.6.0.0-ODn7ZyBfwj6IkLPAAzetJ" True) (C1 (MetaCons "CWMin" PrefixI True) (S1 (MetaSel (Just Symbol "_cwMin") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a)))

cwMin :: forall a a. Iso (CWMin a) (CWMin a) a a Source #

newtype CWMax a Source #

Coordinate wize maximum

Constructors

CWMax 

Fields

Instances

Functor CWMax Source # 

Methods

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

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

Foldable CWMax Source # 

Methods

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

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

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

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

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

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

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

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

toList :: CWMax a -> [a] #

null :: CWMax a -> Bool #

length :: CWMax a -> Int #

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

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

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

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

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

Traversable CWMax Source # 

Methods

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

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

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

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

Eq a => Eq (CWMax a) Source # 

Methods

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

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

Ord a => Ord (CWMax a) Source # 

Methods

compare :: CWMax a -> CWMax a -> Ordering #

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

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

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

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

max :: CWMax a -> CWMax a -> CWMax a #

min :: CWMax a -> CWMax a -> CWMax a #

Show a => Show (CWMax a) Source # 

Methods

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

show :: CWMax a -> String #

showList :: [CWMax a] -> ShowS #

Generic (CWMax a) Source # 

Associated Types

type Rep (CWMax a) :: * -> * #

Methods

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

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

(Arity d, Ord r) => Semigroup (CWMax (Point d r)) Source # 

Methods

(<>) :: CWMax (Point d r) -> CWMax (Point d r) -> CWMax (Point d r) #

sconcat :: NonEmpty (CWMax (Point d r)) -> CWMax (Point d r) #

stimes :: Integral b => b -> CWMax (Point d r) -> CWMax (Point d r) #

NFData a => NFData (CWMax a) Source # 

Methods

rnf :: CWMax a -> () #

type Rep (CWMax a) Source # 
type Rep (CWMax a) = D1 (MetaData "CWMax" "Data.Geometry.Box.Internal" "hgeometry-0.6.0.0-ODn7ZyBfwj6IkLPAAzetJ" True) (C1 (MetaCons "CWMax" PrefixI True) (S1 (MetaSel (Just Symbol "_cwMax") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a)))

cwMax :: forall a a. Iso (CWMax a) (CWMax a) a a Source #

d-dimensional boxes

data Box d p r Source #

Constructors

Box 

Fields

Instances

PointFunctor (Box d p) Source # 

Methods

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

Coordinate r => IpeReadText (Rectangle () r) Source # 
(Arity d, Ord r) => IsIntersectableWith (Point d r) (Box d p r) Source # 

Methods

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

intersects :: Point d r -> Box d p r -> Bool Source #

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

(Eq r, Eq p, Arity d) => Eq (Box d p r) Source # 

Methods

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

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

(Ord r, Ord p, Arity d) => Ord (Box d p r) Source # 

Methods

compare :: Box d p r -> Box d p r -> Ordering #

(<) :: Box d p r -> Box d p r -> Bool #

(<=) :: Box d p r -> Box d p r -> Bool #

(>) :: Box d p r -> Box d p r -> Bool #

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

max :: Box d p r -> Box d p r -> Box d p r #

min :: Box d p r -> Box d p r -> Box d p r #

(Show r, Show p, Arity d) => Show (Box d p r) Source # 

Methods

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

show :: Box d p r -> String #

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

Generic (Box d p r) Source # 

Associated Types

type Rep (Box d p r) :: * -> * #

Methods

from :: Box d p r -> Rep (Box d p r) x #

to :: Rep (Box d p r) x -> Box d p r #

(Arity d, Ord r, Semigroup p) => Semigroup (Box d p r) Source # 

Methods

(<>) :: Box d p r -> Box d p r -> Box d p r #

sconcat :: NonEmpty (Box d p r) -> Box d p r #

stimes :: Integral b => b -> Box d p r -> Box d p r #

(Num r, AlwaysTruePFT d) => IsTransformable (Box d p r) Source # 

Methods

transformBy :: Transformation (Dimension (Box d p r)) (NumType (Box d p r)) -> Box d p r -> Box d p r Source #

IsBoxable (Box d p r) Source # 

Methods

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

(Ord r, Arity d) => IsIntersectableWith (Box d p r) (Box d q r) Source # 

Methods

intersect :: Box d p r -> Box d q r -> Intersection (Box d p r) (Box d q r) Source #

intersects :: Box d p r -> Box d q r -> Bool Source #

nonEmptyIntersection :: proxy (Box d p r) -> proxy (Box d q r) -> Intersection (Box d p r) (Box d q r) -> Bool Source #

type IntersectionOf (Line 2 r) (Boundary (Rectangle p r)) Source # 
type IntersectionOf (Line 2 r) (Boundary (Rectangle p r)) = (:) * NoIntersection ((:) * (Point 2 r) ((:) * (Point 2 r, Point 2 r) ((:) * (LineSegment 2 () r) ([] *))))
type IntersectionOf (Line 2 r) (Rectangle p r) Source # 
type IntersectionOf (Line 2 r) (Rectangle p r) = (:) * NoIntersection ((:) * (Point 2 r) ((:) * (LineSegment 2 () r) ([] *)))
type IntersectionOf (Point d r) (Box d p r) Source # 
type IntersectionOf (Point d r) (Box d p r) = (:) * NoIntersection ((:) * (Point d r) ([] *))
type Rep (Box d p r) Source # 
type Rep (Box d p r) = D1 (MetaData "Box" "Data.Geometry.Box.Internal" "hgeometry-0.6.0.0-ODn7ZyBfwj6IkLPAAzetJ" False) (C1 (MetaCons "Box" PrefixI True) ((:*:) (S1 (MetaSel (Just Symbol "_minP") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 ((:+) (CWMin (Point d r)) p))) (S1 (MetaSel (Just Symbol "_maxP") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 ((:+) (CWMax (Point d r)) p)))))
type NumType (Box d p r) Source # 
type NumType (Box d p r) = r
type Dimension (Box d p r) Source # 
type Dimension (Box d p r) = d
type IntersectionOf (Box d p r) (Box d q r) Source # 
type IntersectionOf (Box d p r) (Box d q r) = (:) * NoIntersection ((:) * (Box d () r) ([] *))

minP :: forall d p r. Lens' (Box d p r) ((:+) (CWMin (Point d r)) p) Source #

maxP :: forall d p r. Lens' (Box d p r) ((:+) (CWMax (Point d r)) p) Source #

box :: (Point d r :+ p) -> (Point d r :+ p) -> Box d p r Source #

Given the point with the lowest coordinates and the point with highest coordinates, create a box.

fromExtent :: Arity d => Vector d (Range r) -> Box d () r Source #

Build a d dimensional Box given d ranges.

centerPoint :: (Arity d, Fractional r) => Box d p r -> Point d r Source #

Center of the box

Functions on d-dimensonal boxes

minPoint :: Box d p r -> Point d r :+ p Source #

maxPoint :: Box d p r -> Point d r :+ p Source #

inBox :: (Arity d, Ord r) => Point d r -> Box d p r -> Bool Source #

Check if a point lies a box

>>> origin `inBox` (boundingBoxList' [point3 1 2 3, point3 10 20 30] :: Box 3 () Int)
False
>>> origin `inBox` (boundingBoxList' [point3 (-1) (-2) (-3), point3 10 20 30] :: Box 3 () Int)
True

extent :: Arity d => Box d p r -> Vector d (Range r) Source #

Get a vector with the extent of the box in each dimension. Note that the resulting vector is 0 indexed whereas one would normally count dimensions starting at zero.

>>> extent (boundingBoxList' [point3 1 2 3, point3 10 20 30] :: Box 3 () Int)
Vector3 [Range (Closed 1) (Closed 10),Range (Closed 2) (Closed 20),Range (Closed 3) (Closed 30)]

size :: (Arity d, Num r) => Box d p r -> Vector d r Source #

Get the size of the box (in all dimensions). Note that the resulting vector is 0 indexed whereas one would normally count dimensions starting at zero.

>>> size (boundingBoxList' [origin, point3 1 2 3] :: Box 3 () Int)
Vector3 [1,2,3]

widthIn :: forall proxy p i d r. (Arity d, Num r, Index' (i - 1) d) => proxy i -> Box d p r -> r Source #

Given a dimension, get the width of the box in that dimension. Dimensions are 1 indexed.

>>> widthIn (C :: C 1) (boundingBoxList' [origin, point3 1 2 3] :: Box 3 () Int)
1
>>> widthIn (C :: C 3) (boundingBoxList' [origin, point3 1 2 3] :: Box 3 () Int)
3

widthIn' :: (Arity d, KnownNat d, Num r) => Int -> Box d p r -> Maybe r Source #

Same as widthIn but with a runtime int instead of a static dimension.

>>> widthIn' 1 (boundingBoxList' [origin, point3 1 2 3] :: Box 3 () Int)
Just 1
>>> widthIn' 3 (boundingBoxList' [origin, point3 1 2 3] :: Box 3 () Int)
Just 3
>>> widthIn' 10 (boundingBoxList' [origin, point3 1 2 3] :: Box 3 () Int)
Nothing

Rectangles, aka 2-dimensional boxes

width :: Num r => Rectangle p r -> r Source #

height :: Num r => Rectangle p r -> r Source #

corners :: Num r => Rectangle p r -> (Point 2 r :+ p, Point 2 r :+ p, Point 2 r :+ p, Point 2 r :+ p) Source #

Get the corners of a rectangle, the order is: (TopLeft, TopRight, BottomRight, BottomLeft). The extra values in the Top points are taken from the Top point, the extra values in the Bottom points are taken from the Bottom point

Constructing bounding boxes

class IsBoxable g where Source #

Minimal complete definition

boundingBox

Methods

boundingBox :: Ord (NumType g) => g -> Box (Dimension g) () (NumType g) Source #

Instances

IsBoxable (Point d r) Source # 

Methods

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

IsBoxable (ConvexPolygon p r) Source # 
IsBoxable (Box d p r) Source # 

Methods

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

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

Methods

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

Arity d => IsBoxable (PolyLine d p r) Source # 

Methods

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

IsBoxable (Polygon t p r) Source # 

Methods

boundingBox :: Polygon t p r -> Box (Dimension (Polygon t p r)) () (NumType (Polygon t p r)) Source #

boundingBoxList' :: (IsBoxable g, Ord (NumType g), Arity (Dimension g)) => [g] -> Box (Dimension g) () (NumType g) Source #

Unsafe version of boundingBoxList, that does not check if the list is non-empty