| Copyright | (C) Frank Staals |
|---|---|
| License | see the LICENSE file |
| Maintainer | Frank Staals |
| Safe Haskell | None |
| Language | GHC2024 |
HGeometry.Box
Contents
Description
d-dimensional Boxes
Synopsis
- module HGeometry.Box.Class
- fromExtent :: forall vector (d :: Nat) interval r. (Vector_ vector d interval, ClosedInterval_ interval r, Has_ Additive_ d r, Has_ Vector_ d interval, HasComponents (Vector d interval) (Vector d r)) => vector -> Box (Point d r)
- data Box point where
- type Rectangle = Box
- corners :: (Num r, Rectangle_ rectangle point, Point_ point 2 r) => rectangle -> Corners point
- cornersInDirection :: CardinalDirection -> Corners p -> Vector 2 p
- northEast :: forall a f. Functor f => (a -> f a) -> Corners a -> f (Corners a)
- northWest :: forall a f. Functor f => (a -> f a) -> Corners a -> f (Corners a)
- southEast :: forall a f. Functor f => (a -> f a) -> Corners a -> f (Corners a)
- southWest :: forall a f. Functor f => (a -> f a) -> Corners a -> f (Corners a)
- data Corners a = Corners !a !a !a !a
- bottomSide :: (Num r, Rectangle_ rectangle point, Point_ point 2 r) => rectangle -> ClosedLineSegment point
- east :: forall a f. Functor f => (a -> f a) -> Sides a -> f (Sides a)
- intersectingHalfPlanes :: (Rectangle_ rectangle point, Point_ point 2 r, Num r) => rectangle -> Sides (HalfSpaceF (LinePV 2 r))
- leftSide :: (Num r, Rectangle_ rectangle point, Point_ point 2 r) => rectangle -> ClosedLineSegment point
- north :: forall a f. Functor f => (a -> f a) -> Sides a -> f (Sides a)
- rightSide :: (Num r, Rectangle_ rectangle point, Point_ point 2 r) => rectangle -> ClosedLineSegment point
- sideDirections :: Sides CardinalDirection
- sideValues :: (Rectangle_ rectangle point, Point_ point 2 r) => rectangle -> Sides r
- sides :: (Num r, Rectangle_ rectangle point, Point_ point 2 r) => rectangle -> Sides (ClosedLineSegment point)
- sides' :: (Num r, Rectangle_ rectangle point, Point_ point 2 r) => rectangle -> Sides (ClosedLineSegment point)
- south :: forall a f. Functor f => (a -> f a) -> Sides a -> f (Sides a)
- topSide :: (Num r, Rectangle_ rectangle point, Point_ point 2 r) => rectangle -> ClosedLineSegment point
- west :: forall a f. Functor f => (a -> f a) -> Sides a -> f (Sides a)
- data Sides a = Sides !a !a !a !a
- class IsBoxable g where
- data LineBoxIntersection (d :: Nat) r
- = Line_x_Box_Point (Point d r)
- | Line_x_Box_LineSegment (ClosedLineSegment (Point d r))
- data HalfLineBoxIntersection point
- = HalfLine_x_Box_Point point
- | HalfLine_x_Box_LineSegment (ClosedLineSegment point)
Documentation
module HGeometry.Box.Class
fromExtent :: forall vector (d :: Nat) interval r. (Vector_ vector d interval, ClosedInterval_ interval r, Has_ Additive_ d r, Has_ Vector_ d interval, HasComponents (Vector d interval) (Vector d r)) => vector -> Box (Point d r) Source #
Given a vector of intervals, construct a box.
>>>fromExtent (Vector2 (ClosedInterval 1 2) (ClosedInterval 10 20))Box (Point2 1 10) (Point2 2 20)
D-dimensional boxes.
A box is represented by two points; a point with lexicographically minimal coordinates, and a point with lexicographically maximal coordinates.
Bundled Patterns
| pattern Box :: point -> point -> Box point | Construct a box |
| pattern Rect :: Num r => r -> r -> r -> r -> Rectangle (Point 2 r) | Given x y w h construct the rectangle with bottom left corner (x,y), width w, and hegith h. |
| pattern Rectangle :: Dimension point ~ 2 => point -> point -> Box point | Construct a Rectangle |
Instances
corners :: (Num r, Rectangle_ rectangle point, Point_ point 2 r) => rectangle -> Corners point Source #
Get the corners of a rectangle, the order is:
Any additional information from in the top points is taken from the Top point, Any additional information from in the bottom points is taken from the Bottom point,
cornersInDirection :: CardinalDirection -> Corners p -> Vector 2 p Source #
Gets the corners in a particular direction
northEast :: forall a f. Functor f => (a -> f a) -> Corners a -> f (Corners a) Source #
Access the northeast corner
northWest :: forall a f. Functor f => (a -> f a) -> Corners a -> f (Corners a) Source #
Access the northwest corner
southEast :: forall a f. Functor f => (a -> f a) -> Corners a -> f (Corners a) Source #
Access the southeast corner
southWest :: forall a f. Functor f => (a -> f a) -> Corners a -> f (Corners a) Source #
Access the southwest corner
A data type rperesenting the corners of a box. the order of the Corners is 'northWest, northEast, southEast, southWest', i.e. in clockwise order starting from the topleft.
Constructors
| Corners !a !a !a !a |
Instances
| Foldable1 Corners Source # | |||||
Defined in HGeometry.Box.Corners Methods fold1 :: Semigroup m => Corners m -> m Source # foldMap1 :: Semigroup m => (a -> m) -> Corners a -> m Source # foldMap1' :: Semigroup m => (a -> m) -> Corners a -> m Source # toNonEmpty :: Corners a -> NonEmpty a Source # maximum :: Ord a => Corners a -> a Source # minimum :: Ord a => Corners a -> a Source # head :: Corners a -> a Source # last :: Corners a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Corners a -> b Source # foldlMap1' :: (a -> b) -> (b -> a -> b) -> Corners a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Corners a -> b Source # foldrMap1' :: (a -> b) -> (a -> b -> b) -> Corners a -> b Source # | |||||
| Applicative Corners Source # | |||||
Defined in HGeometry.Box.Corners | |||||
| Functor Corners Source # | |||||
| Foldable Corners Source # | |||||
Defined in HGeometry.Box.Corners Methods fold :: Monoid m => Corners m -> m Source # foldMap :: Monoid m => (a -> m) -> Corners a -> m Source # foldMap' :: Monoid m => (a -> m) -> Corners a -> m Source # foldr :: (a -> b -> b) -> b -> Corners a -> b Source # foldr' :: (a -> b -> b) -> b -> Corners a -> b Source # foldl :: (b -> a -> b) -> b -> Corners a -> b Source # foldl' :: (b -> a -> b) -> b -> Corners a -> b Source # foldr1 :: (a -> a -> a) -> Corners a -> a Source # foldl1 :: (a -> a -> a) -> Corners a -> a Source # toList :: Corners a -> [a] Source # null :: Corners a -> Bool Source # length :: Corners a -> Int Source # elem :: Eq a => a -> Corners a -> Bool Source # maximum :: Ord a => Corners a -> a Source # minimum :: Ord a => Corners a -> a Source # | |||||
| Traversable Corners Source # | |||||
Defined in HGeometry.Box.Corners | |||||
| Traversable1 Corners Source # | |||||
| FoldableWithIndex InterCardinalDirection Corners Source # | |||||
Defined in HGeometry.Box.Corners Methods ifoldMap :: Monoid m => (InterCardinalDirection -> a -> m) -> Corners a -> m Source # ifoldMap' :: Monoid m => (InterCardinalDirection -> a -> m) -> Corners a -> m Source # ifoldr :: (InterCardinalDirection -> a -> b -> b) -> b -> Corners a -> b Source # ifoldl :: (InterCardinalDirection -> b -> a -> b) -> b -> Corners a -> b Source # ifoldr' :: (InterCardinalDirection -> a -> b -> b) -> b -> Corners a -> b Source # ifoldl' :: (InterCardinalDirection -> b -> a -> b) -> b -> Corners a -> b Source # | |||||
| FunctorWithIndex InterCardinalDirection Corners Source # | |||||
Defined in HGeometry.Box.Corners | |||||
| TraversableWithIndex InterCardinalDirection Corners Source # | |||||
Defined in HGeometry.Box.Corners Methods itraverse :: Applicative f => (InterCardinalDirection -> a -> f b) -> Corners a -> f (Corners b) Source # | |||||
| Monoid a => Monoid (Corners a) Source # | |||||
| Semigroup a => Semigroup (Corners a) Source # | |||||
| Generic (Corners a) Source # | |||||
Defined in HGeometry.Box.Corners Associated Types
| |||||
| Show a => Show (Corners a) Source # | |||||
| Eq a => Eq (Corners a) Source # | |||||
| Ord a => Ord (Corners a) Source # | |||||
Defined in HGeometry.Box.Corners | |||||
| Ixed (Corners a) Source # | |||||
Defined in HGeometry.Box.Corners | |||||
| type Rep (Corners a) Source # | |||||
Defined in HGeometry.Box.Corners type Rep (Corners a) = D1 ('MetaData "Corners" "HGeometry.Box.Corners" "hgeometry-kernel-1.0.0.0-inplace" 'False) (C1 ('MetaCons "Corners" 'PrefixI 'True) ((S1 ('MetaSel ('Just "_northWest") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a) :*: S1 ('MetaSel ('Just "_northEast") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a)) :*: (S1 ('MetaSel ('Just "_southEast") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a) :*: S1 ('MetaSel ('Just "_southWest") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a)))) | |||||
| type Index (Corners a) Source # | |||||
Defined in HGeometry.Box.Corners | |||||
| type IxValue (Corners a) Source # | |||||
Defined in HGeometry.Box.Corners | |||||
bottomSide :: (Num r, Rectangle_ rectangle point, Point_ point 2 r) => rectangle -> ClosedLineSegment point Source #
Oriented from *left to right*
intersectingHalfPlanes :: (Rectangle_ rectangle point, Point_ point 2 r, Num r) => rectangle -> Sides (HalfSpaceF (LinePV 2 r)) Source #
Gets the four halfplanes so that the box is the intersection of the halfplanes.
leftSide :: (Num r, Rectangle_ rectangle point, Point_ point 2 r) => rectangle -> ClosedLineSegment point Source #
Left side of the box, from bottom to top
north :: forall a f. Functor f => (a -> f a) -> Sides a -> f (Sides a) Source #
Access the north side
rightSide :: (Num r, Rectangle_ rectangle point, Point_ point 2 r) => rectangle -> ClosedLineSegment point Source #
The right side, oriented from *bottom* to top
sideDirections :: Sides CardinalDirection Source #
Constructs a Sides value that indicates the appropriate direction.
sideValues :: (Rectangle_ rectangle point, Point_ point 2 r) => rectangle -> Sides r Source #
The side values of the rectangle, i.e. the coordinates of the top, right, bottom, and left sides.
sides :: (Num r, Rectangle_ rectangle point, Point_ point 2 r) => rectangle -> Sides (ClosedLineSegment point) Source #
The sides of the rectangle, in order (Top, Right, Bottom, Left). The sides
themselves are also oriented in clockwise order. If, you want them in the
same order as the functions topSide, bottomSide, leftSide, and
rightSide, use sides' instead.
sides' :: (Num r, Rectangle_ rectangle point, Point_ point 2 r) => rectangle -> Sides (ClosedLineSegment point) Source #
The sides of the rectangle. The order of the segments is (Top, Right,
Bottom, Left). Note that the segments themselves, are oriented as described
by the functions topSide, bottomSide, leftSide, rightSide (basically: from
left to right, and from bottom to top). If you want the segments oriented
along the boundary of the rectangle, use the sides function instead.
south :: forall a f. Functor f => (a -> f a) -> Sides a -> f (Sides a) Source #
Access the south side
topSide :: (Num r, Rectangle_ rectangle point, Point_ point 2 r) => rectangle -> ClosedLineSegment point Source #
The top side of the box, from left to right.
The four sides of a rectangle
i.e. a `Sides n e s w` rerpesents an object whose north side is n, east side e, south side s, and west side w.
Constructors
| Sides !a !a !a !a |
Instances
| Foldable1 Sides Source # | |||||
Defined in HGeometry.Box.Sides Methods fold1 :: Semigroup m => Sides m -> m Source # foldMap1 :: Semigroup m => (a -> m) -> Sides a -> m Source # foldMap1' :: Semigroup m => (a -> m) -> Sides a -> m Source # toNonEmpty :: Sides a -> NonEmpty a Source # maximum :: Ord a => Sides a -> a Source # minimum :: Ord a => Sides a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Sides a -> b Source # foldlMap1' :: (a -> b) -> (b -> a -> b) -> Sides a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Sides a -> b Source # foldrMap1' :: (a -> b) -> (a -> b -> b) -> Sides a -> b Source # | |||||
| Applicative Sides Source # | |||||
| Functor Sides Source # | |||||
| Foldable Sides Source # | |||||
Defined in HGeometry.Box.Sides Methods fold :: Monoid m => Sides m -> m Source # foldMap :: Monoid m => (a -> m) -> Sides a -> m Source # foldMap' :: Monoid m => (a -> m) -> Sides a -> m Source # foldr :: (a -> b -> b) -> b -> Sides a -> b Source # foldr' :: (a -> b -> b) -> b -> Sides a -> b Source # foldl :: (b -> a -> b) -> b -> Sides a -> b Source # foldl' :: (b -> a -> b) -> b -> Sides a -> b Source # foldr1 :: (a -> a -> a) -> Sides a -> a Source # foldl1 :: (a -> a -> a) -> Sides a -> a Source # toList :: Sides a -> [a] Source # null :: Sides a -> Bool Source # length :: Sides a -> Int Source # elem :: Eq a => a -> Sides a -> Bool Source # maximum :: Ord a => Sides a -> a Source # minimum :: Ord a => Sides a -> a Source # | |||||
| Traversable Sides Source # | |||||
| Traversable1 Sides Source # | |||||
| FoldableWithIndex CardinalDirection Sides Source # | |||||
Defined in HGeometry.Box.Sides Methods ifoldMap :: Monoid m => (CardinalDirection -> a -> m) -> Sides a -> m Source # ifoldMap' :: Monoid m => (CardinalDirection -> a -> m) -> Sides a -> m Source # ifoldr :: (CardinalDirection -> a -> b -> b) -> b -> Sides a -> b Source # ifoldl :: (CardinalDirection -> b -> a -> b) -> b -> Sides a -> b Source # ifoldr' :: (CardinalDirection -> a -> b -> b) -> b -> Sides a -> b Source # ifoldl' :: (CardinalDirection -> b -> a -> b) -> b -> Sides a -> b Source # | |||||
| FunctorWithIndex CardinalDirection Sides Source # | |||||
Defined in HGeometry.Box.Sides | |||||
| TraversableWithIndex CardinalDirection Sides Source # | |||||
Defined in HGeometry.Box.Sides Methods itraverse :: Applicative f => (CardinalDirection -> a -> f b) -> Sides a -> f (Sides b) Source # | |||||
| Monoid a => Monoid (Sides a) Source # | |||||
| Semigroup a => Semigroup (Sides a) Source # | |||||
| Generic (Sides a) Source # | |||||
Defined in HGeometry.Box.Sides Associated Types
| |||||
| Read a => Read (Sides a) Source # | |||||
| Show a => Show (Sides a) Source # | |||||
| Eq a => Eq (Sides a) Source # | |||||
| Ord a => Ord (Sides a) Source # | |||||
Defined in HGeometry.Box.Sides | |||||
| Ixed (Sides a) Source # | |||||
Defined in HGeometry.Box.Sides | |||||
| type Rep (Sides a) Source # | |||||
Defined in HGeometry.Box.Sides type Rep (Sides a) = D1 ('MetaData "Sides" "HGeometry.Box.Sides" "hgeometry-kernel-1.0.0.0-inplace" 'False) (C1 ('MetaCons "Sides" 'PrefixI 'True) ((S1 ('MetaSel ('Just "_north") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a) :*: S1 ('MetaSel ('Just "_east") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a)) :*: (S1 ('MetaSel ('Just "_south") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a) :*: S1 ('MetaSel ('Just "_west") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a)))) | |||||
| type Index (Sides a) Source # | |||||
Defined in HGeometry.Box.Sides | |||||
| type IxValue (Sides a) Source # | |||||
Defined in HGeometry.Box.Sides | |||||
class IsBoxable g where Source #
Types for which we can compute an axis parallel boundingbox
Minimal complete definition
Nothing
Methods
boundingBox :: forall (d :: Nat) r. (d ~ Dimension g, r ~ NumType g, Ord r) => g -> Box (Point d r) Source #
Compute the axis-parallel boundingbox of the given geometry.
Instances
| (IsBoxable g, Has_ Additive_ d r, d ~ Dimension g, r ~ NumType g) => IsBoxable (NonEmpty g) Source # | |
| (Box_ (Box point) point, Point_ point d r) => IsBoxable (Box point) Source # | |
| (Point_ point d r, Ord (Vector d r)) => IsBoxable (Triangle point) Source # | |
| IsBoxable g => IsBoxable (g :+ extra) Source # | |
| (Traversable1 endPoint, Point_ point d r, d ~ Dimension point, r ~ NumType point, Ord r, Ord (Vector d r)) => IsBoxable (LineSegment endPoint point) Source # | |
Defined in HGeometry.LineSegment.Internal Methods boundingBox :: forall (d0 :: Nat) r0. (d0 ~ Dimension (LineSegment endPoint point), r0 ~ NumType (LineSegment endPoint point), Ord r0) => LineSegment endPoint point -> Box (Point d0 r0) Source # | |
| IsBoxable (Point d r) Source # | |
data LineBoxIntersection (d :: Nat) r Source #
Data type representing the intersection of a Box and a line
Constructors
| Line_x_Box_Point (Point d r) | |
| Line_x_Box_LineSegment (ClosedLineSegment (Point d r)) |
Instances
| (Show (Point d r), Show (ClosedLineSegment (Point d r))) => Show (LineBoxIntersection d r) Source # | |
Defined in HGeometry.Box | |
| (Eq (Point d r), Eq (ClosedLineSegment (Point d r))) => Eq (LineBoxIntersection d r) Source # | |
Defined in HGeometry.Box Methods (==) :: LineBoxIntersection d r -> LineBoxIntersection d r -> Bool Source # (/=) :: LineBoxIntersection d r -> LineBoxIntersection d r -> Bool Source # | |
data HalfLineBoxIntersection point Source #
Constructors
| HalfLine_x_Box_Point point | |
| HalfLine_x_Box_LineSegment (ClosedLineSegment point) |
Instances
| Functor HalfLineBoxIntersection Source # | |||||
Defined in HGeometry.Box Methods fmap :: (a -> b) -> HalfLineBoxIntersection a -> HalfLineBoxIntersection b Source # (<$) :: a -> HalfLineBoxIntersection b -> HalfLineBoxIntersection a Source # | |||||
| Generic (HalfLineBoxIntersection point) Source # | |||||
Defined in HGeometry.Box Associated Types
Methods from :: HalfLineBoxIntersection point -> Rep (HalfLineBoxIntersection point) x Source # to :: Rep (HalfLineBoxIntersection point) x -> HalfLineBoxIntersection point Source # | |||||
| Read point => Read (HalfLineBoxIntersection point) Source # | |||||
Defined in HGeometry.Box Methods readsPrec :: Int -> ReadS (HalfLineBoxIntersection point) Source # readList :: ReadS [HalfLineBoxIntersection point] Source # readPrec :: ReadPrec (HalfLineBoxIntersection point) Source # readListPrec :: ReadPrec [HalfLineBoxIntersection point] Source # | |||||
| Show point => Show (HalfLineBoxIntersection point) Source # | |||||
Defined in HGeometry.Box | |||||
| Eq point => Eq (HalfLineBoxIntersection point) Source # | |||||
Defined in HGeometry.Box Methods (==) :: HalfLineBoxIntersection point -> HalfLineBoxIntersection point -> Bool Source # (/=) :: HalfLineBoxIntersection point -> HalfLineBoxIntersection point -> Bool Source # | |||||
| type Rep (HalfLineBoxIntersection point) Source # | |||||
Defined in HGeometry.Box type Rep (HalfLineBoxIntersection point) = D1 ('MetaData "HalfLineBoxIntersection" "HGeometry.Box" "hgeometry-kernel-1.0.0.0-inplace" 'False) (C1 ('MetaCons "HalfLine_x_Box_Point" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 point)) :+: C1 ('MetaCons "HalfLine_x_Box_LineSegment" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ClosedLineSegment point)))) | |||||
Orphan instances
| (Point_ point d r, IsTransformable point) => IsTransformable (Box point) Source # | |
Methods transformBy :: Transformation (Dimension (Box point)) (NumType (Box point)) -> Box point -> Box point Source # | |
| (Point_ point 2 r, Ord r, Num r) => HasIntersectionWith (HalfLine point) (Rectangle point) Source # | |
| (Num r, Ord r, Point_ point 2 r) => HasIntersectionWith (VerticalOrLineEQ r) (Rectangle point) Source # | |
Methods intersects :: VerticalOrLineEQ r -> Rectangle point -> Bool Source # | |
| (Num r, Ord r, Point_ point 2 r) => HasIntersectionWith (LineEQ r) (Rectangle point) Source # | |
| (Point_ point 2 r, Ord r, Fractional r) => IsIntersectableWith (HalfLine point) (Rectangle point) Source # | |
| (Fractional r, Ord r, Point_ point 2 r) => IsIntersectableWith (VerticalOrLineEQ r) (Rectangle point) Source # | |
Methods intersect :: VerticalOrLineEQ r -> Rectangle point -> Intersection (VerticalOrLineEQ r) (Rectangle point) Source # | |
| (Fractional r, Ord r, Point_ point 2 r) => IsIntersectableWith (LineEQ r) (Rectangle point) Source # | |
| (Num r, Ord r, Point_ point 2 r) => HasIntersectionWith (LinePV 2 r) (Rectangle point) Source # | |
| (Ord r, Num r, Point_ point 2 r, Point_ point' 2 r, HasIntersectionWith (LineSegment endPoint point) (ClosedLineSegment point')) => HasIntersectionWith (LineSegment endPoint point) (Boundary (Rectangle point')) Source # | |
Methods intersects :: LineSegment endPoint point -> Boundary (Rectangle point') -> Bool Source # | |
| (Ord r, Num r, Point_ point 2 r, Point_ point' 2 r, IxValue (endPoint point) ~ point, EndPoint_ (endPoint point), HasIntersectionWith (LineSegment endPoint point) (ClosedLineSegment point')) => HasIntersectionWith (LineSegment endPoint point) (Rectangle point') Source # | |
Methods intersects :: LineSegment endPoint point -> Rectangle point' -> Bool Source # | |
| (Point_ point d r, Num r, Ord r, Foldable1 (Vector d), Zip (Vector d)) => HasIntersectionWith (Point d r) (Box point) Source # | |
| (Fractional r, Ord r, Point_ point 2 r) => IsIntersectableWith (LinePV 2 r) (Rectangle point) Source # | |
| (Point_ point d r, Num r, Ord r, Foldable1 (Vector d), Zip (Vector d)) => IsIntersectableWith (Point d r) (Box point) Source # | |