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

Copyright(C) Frank Staals
Licensesee the LICENSE file
MaintainerFrank Staals
Safe HaskellNone
LanguageHaskell2010

Data.Geometry.Box.Internal

Contents

Description

Orthogonal \(d\)-dimensiontal boxes (e.g. rectangles)

Synopsis

Documentation

newtype CWMin a Source #

Coordinate wize minimum

Constructors

CWMin 

Fields

Instances
Functor CWMin Source # 
Instance details

Defined in Data.Geometry.Box.Internal

Methods

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

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

Foldable CWMin Source # 
Instance details

Defined in Data.Geometry.Box.Internal

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 # 
Instance details

Defined in Data.Geometry.Box.Internal

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 # 
Instance details

Defined in Data.Geometry.Box.Internal

Methods

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

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

Ord a => Ord (CWMin a) Source # 
Instance details

Defined in Data.Geometry.Box.Internal

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 # 
Instance details

Defined in Data.Geometry.Box.Internal

Methods

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

show :: CWMin a -> String #

showList :: [CWMin a] -> ShowS #

Generic (CWMin a) Source # 
Instance details

Defined in Data.Geometry.Box.Internal

Associated Types

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

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 # 
Instance details

Defined in Data.Geometry.Box.Internal

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 # 
Instance details

Defined in Data.Geometry.Box.Internal

Methods

rnf :: CWMin a -> () #

type Rep (CWMin a) Source # 
Instance details

Defined in Data.Geometry.Box.Internal

type Rep (CWMin a) = D1 (MetaData "CWMin" "Data.Geometry.Box.Internal" "hgeometry-0.11.0.0-5Q7X7STHtn33ZJbJEL0QVy" True) (C1 (MetaCons "CWMin" PrefixI True) (S1 (MetaSel (Just "_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 # 
Instance details

Defined in Data.Geometry.Box.Internal

Methods

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

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

Foldable CWMax Source # 
Instance details

Defined in Data.Geometry.Box.Internal

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 # 
Instance details

Defined in Data.Geometry.Box.Internal

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 # 
Instance details

Defined in Data.Geometry.Box.Internal

Methods

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

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

Ord a => Ord (CWMax a) Source # 
Instance details

Defined in Data.Geometry.Box.Internal

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 # 
Instance details

Defined in Data.Geometry.Box.Internal

Methods

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

show :: CWMax a -> String #

showList :: [CWMax a] -> ShowS #

Generic (CWMax a) Source # 
Instance details

Defined in Data.Geometry.Box.Internal

Associated Types

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

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 # 
Instance details

Defined in Data.Geometry.Box.Internal

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 # 
Instance details

Defined in Data.Geometry.Box.Internal

Methods

rnf :: CWMax a -> () #

type Rep (CWMax a) Source # 
Instance details

Defined in Data.Geometry.Box.Internal

type Rep (CWMax a) = D1 (MetaData "CWMax" "Data.Geometry.Box.Internal" "hgeometry-0.11.0.0-5Q7X7STHtn33ZJbJEL0QVy" True) (C1 (MetaCons "CWMax" PrefixI True) (S1 (MetaSel (Just "_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
Arity d => Bifunctor (Box d) Source # 
Instance details

Defined in Data.Geometry.Box.Internal

Methods

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

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

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

Arity d => Bitraversable (Box d) Source # 
Instance details

Defined in Data.Geometry.Box.Internal

Methods

bitraverse :: Applicative f => (a -> f c) -> (b -> f d0) -> Box d a b -> f (Box d c d0) #

Arity d => Bifoldable (Box d) Source # 
Instance details

Defined in Data.Geometry.Box.Internal

Methods

bifold :: Monoid m => Box d m m -> m #

bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> Box d a b -> m #

bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> Box d a b -> c #

bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> Box d a b -> c #

PointFunctor (Box d p) Source # 
Instance details

Defined in Data.Geometry.Box.Internal

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 #

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

Defined in Data.Geometry.Line

Methods

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

intersects :: Line 2 r -> Boundary (Rectangle p r) -> Bool #

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

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

Defined in Data.Geometry.Line

Methods

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

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

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

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

Defined in Data.Geometry.Box.Internal

Methods

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

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

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

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

Defined in Data.Geometry.Box.Internal

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 # 
Instance details

Defined in Data.Geometry.Box.Internal

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 # 
Instance details

Defined in Data.Geometry.Box.Internal

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 # 
Instance details

Defined in Data.Geometry.Box.Internal

Associated Types

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

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 # 
Instance details

Defined in Data.Geometry.Box.Internal

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 #

(Arbitrary r, Arity d, Ord r) => Arbitrary (Box d () r) Source # 
Instance details

Defined in Data.Geometry.Box.Internal

Methods

arbitrary :: Gen (Box d () r) #

shrink :: Box d () r -> [Box d () r] #

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

Defined in Data.Geometry.Box

Methods

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

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

Defined in Data.Geometry.Box.Internal

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 # 
Instance details

Defined in Data.Geometry.Box.Internal

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 # 
Instance details

Defined in Data.Geometry.Box.Internal

Methods

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

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

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

type IntersectionOf (Line 2 r) (Boundary (Rectangle p r)) Source # 
Instance details

Defined in Data.Geometry.Line

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

Defined in Data.Geometry.Line

type IntersectionOf (Line 2 r) (Rectangle p r) = NoIntersection ': (Point 2 r ': (LineSegment 2 () r ': ([] :: [Type])))
type IntersectionOf (Point d r) (Box d p r) Source # 
Instance details

Defined in Data.Geometry.Box.Internal

type IntersectionOf (Point d r) (Box d p r) = NoIntersection ': (Point d r ': ([] :: [Type]))
type Rep (Box d p r) Source # 
Instance details

Defined in Data.Geometry.Box.Internal

type Rep (Box d p r) = D1 (MetaData "Box" "Data.Geometry.Box.Internal" "hgeometry-0.11.0.0-5Q7X7STHtn33ZJbJEL0QVy" False) (C1 (MetaCons "Box" PrefixI True) (S1 (MetaSel (Just "_minP") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (CWMin (Point d r) :+ p)) :*: S1 (MetaSel (Just "_maxP") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (CWMax (Point d r) :+ p))))
type NumType (Box d p r) Source # 
Instance details

Defined in Data.Geometry.Box.Internal

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

Defined in Data.Geometry.Box.Internal

type Dimension (Box d p r) = d
type IntersectionOf (Box d p r) (Box d q r) Source # 
Instance details

Defined in Data.Geometry.Box.Internal

type IntersectionOf (Box d p r) (Box d q r) = NoIntersection ': (Box d () r ': ([] :: [Type]))

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.

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

grows the box by x on all sides

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

Build a d dimensional Box given d ranges.

fromCenter :: (Arity d, Fractional r) => Point d r -> Vector d r -> Box d () r Source #

Given a center point and a vector specifying the box width's, construct a box.

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, Arity (i - 1), Num r, ((i - 1) + 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, 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 #

Constructing bounding boxes

class IsBoxable g where Source #

Methods

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

Instances
IsBoxable c => IsBoxable (c :+ e) Source # 
Instance details

Defined in Data.Geometry.Box.Internal

Methods

boundingBox :: (c :+ e) -> Box (Dimension (c :+ e)) () (NumType (c :+ e)) Source #

IsBoxable (Point d r) Source # 
Instance details

Defined in Data.Geometry.Box.Internal

Methods

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

IsBoxable (ConvexPolygon p r) Source # 
Instance details

Defined in Data.Geometry.Polygon.Convex

IsBoxable (Box d p r) Source # 
Instance details

Defined in Data.Geometry.Box.Internal

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 # 
Instance details

Defined in Data.Geometry.LineSegment

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 # 
Instance details

Defined in Data.Geometry.PolyLine

Methods

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

IsBoxable (Polygon t p r) Source # 
Instance details

Defined in Data.Geometry.Polygon.Core

Methods

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

IsBoxable (PlaneGraph s v e f r) Source # 
Instance details

Defined in Data.PlaneGraph.Core

Methods

boundingBox :: PlaneGraph s v e f r -> Box (Dimension (PlaneGraph s v e f r)) () (NumType (PlaneGraph s v e f r)) Source #

IsBoxable (PlanarSubdivision s v e f r) Source # 
Instance details

Defined in Data.Geometry.PlanarSubdivision.Basic

Methods

boundingBox :: PlanarSubdivision s v e f r -> Box (Dimension (PlanarSubdivision s v e f r)) () (NumType (PlanarSubdivision s v e f r)) Source #

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

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