Copyright | (C) Frank Staals |
---|---|
License | see the LICENSE file |
Maintainer | Frank Staals |
Safe Haskell | None |
Language | Haskell2010 |
Orthogonal \(d\)-dimensiontal boxes (e.g. rectangles)
Synopsis
- newtype CWMin a = CWMin {
- _cwMin :: a
- cwMin :: forall a a. Iso (CWMin a) (CWMin a) a a
- newtype CWMax a = CWMax {
- _cwMax :: a
- cwMax :: forall a a. Iso (CWMax a) (CWMax a) a a
- data Box d p r = Box {}
- minP :: forall d p r. Lens' (Box d p r) ((:+) (CWMin (Point d r)) p)
- maxP :: forall d p r. Lens' (Box d p r) ((:+) (CWMax (Point d r)) p)
- box :: (Point d r :+ p) -> (Point d r :+ p) -> Box d p r
- grow :: (Num r, Arity d) => r -> Box d p r -> Box d p r
- fromExtent :: Arity d => Vector d (Range r) -> Box d () r
- fromCenter :: (Arity d, Fractional r) => Point d r -> Vector d r -> Box d () r
- centerPoint :: (Arity d, Fractional r) => Box d p r -> Point d r
- minPoint :: Box d p r -> Point d r :+ p
- maxPoint :: Box d p r -> Point d r :+ p
- inBox :: (Arity d, Ord r) => Point d r -> Box d p r -> Bool
- extent :: Arity d => Box d p r -> Vector d (Range r)
- size :: (Arity d, Num r) => Box d p r -> Vector d r
- 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
- widthIn' :: (Arity d, KnownNat d, Num r) => Int -> Box d p r -> Maybe r
- type Rectangle = Box 2
- width :: Num r => Rectangle p r -> r
- height :: Num r => Rectangle p r -> r
- corners :: Num r => Rectangle p r -> (Point 2 r :+ p, Point 2 r :+ p, Point 2 r :+ p, Point 2 r :+ p)
- class IsBoxable g where
- boundingBoxList :: (IsBoxable g, Foldable1 c, Ord (NumType g), Arity (Dimension g)) => c g -> Box (Dimension g) () (NumType g)
- boundingBoxList' :: (IsBoxable g, Ord (NumType g), Arity (Dimension g)) => [g] -> Box (Dimension g) () (NumType g)
Documentation
Coordinate wize minimum
Instances
Functor CWMin Source # | |
Foldable CWMin Source # | |
Defined in Data.Geometry.Box.Internal 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 # elem :: Eq a => a -> CWMin a -> Bool # maximum :: Ord a => CWMin a -> a # minimum :: Ord a => CWMin a -> a # | |
Traversable CWMin Source # | |
Eq a => Eq (CWMin a) Source # | |
Ord a => Ord (CWMin a) Source # | |
Show a => Show (CWMin a) Source # | |
Generic (CWMin a) Source # | |
(Arity d, Ord r) => Semigroup (CWMin (Point d r)) Source # | |
NFData a => NFData (CWMin a) Source # | |
Defined in Data.Geometry.Box.Internal | |
type Rep (CWMin a) Source # | |
Defined in Data.Geometry.Box.Internal |
Coordinate wize maximum
Instances
Functor CWMax Source # | |
Foldable CWMax Source # | |
Defined in Data.Geometry.Box.Internal 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 # elem :: Eq a => a -> CWMax a -> Bool # maximum :: Ord a => CWMax a -> a # minimum :: Ord a => CWMax a -> a # | |
Traversable CWMax Source # | |
Eq a => Eq (CWMax a) Source # | |
Ord a => Ord (CWMax a) Source # | |
Show a => Show (CWMax a) Source # | |
Generic (CWMax a) Source # | |
(Arity d, Ord r) => Semigroup (CWMax (Point d r)) Source # | |
NFData a => NFData (CWMax a) Source # | |
Defined in Data.Geometry.Box.Internal | |
type Rep (CWMax a) Source # | |
Defined in Data.Geometry.Box.Internal |
d-dimensional boxes
Instances
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.
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
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, 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
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 #