hgeometry-kernel
Copyright(C) Frank Staals
Licensesee the LICENSE file
MaintainerFrank Staals
Safe HaskellNone
LanguageGHC2024

HGeometry.Box.Class

Description

d dimensional boxes

Synopsis

Documentation

class (HasMinPoint box point, HasMaxPoint box point, Point_ point (Dimension box) (NumType box)) => Box_ box point | box -> point where Source #

d-dimensional Boxes

Methods

extent :: forall r (d :: Nat). (r ~ NumType box, d ~ Dimension box, Num r) => box -> Vector d (ClosedInterval 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.

Instances

Instances details
(Point_ point d r, Zip (Vector d)) => Box_ (Box point) point Source # 
Instance details

Defined in HGeometry.Box.Internal

Methods

extent :: forall r0 (d0 :: Nat). (r0 ~ NumType (Box point), d0 ~ Dimension (Box point), Num r0) => Box point -> Vector d0 (ClosedInterval r0) Source #

Box_ box point => Box_ (box :+ extra) point Source # 
Instance details

Defined in HGeometry.Box.Class

Methods

extent :: forall r (d :: Nat). (r ~ NumType (box :+ extra), d ~ Dimension (box :+ extra), Num r) => (box :+ extra) -> Vector d (ClosedInterval r) Source #

class HasMinPoint box point | box -> point where Source #

Types that have a minPoint field lens

Methods

minPoint :: Lens' box point Source #

Lens to access the lexicographically smallest point

Instances

Instances details
HasMinPoint (Box point) point Source # 
Instance details

Defined in HGeometry.Box.Internal

Methods

minPoint :: Lens' (Box point) point Source #

HasMinPoint box point => HasMinPoint (box :+ extra) point Source # 
Instance details

Defined in HGeometry.Box.Class

Methods

minPoint :: Lens' (box :+ extra) point Source #

class HasMaxPoint box point | box -> point where Source #

Types that have a maxPoint field lens

Methods

maxPoint :: Lens' box point Source #

Lens to access the lexicographically largest point

Instances

Instances details
HasMaxPoint (Box point) point Source # 
Instance details

Defined in HGeometry.Box.Internal

Methods

maxPoint :: Lens' (Box point) point Source #

HasMaxPoint box point => HasMaxPoint (box :+ extra) point Source # 
Instance details

Defined in HGeometry.Box.Class

Methods

maxPoint :: Lens' (box :+ extra) point Source #

centerPoint :: forall box point (d :: Nat) r. (Box_ box point, Point_ point d r, Fractional r) => box -> point Source #

Get the center point of a box

>>> centerPoint myRect
Point2 5.5 10.5

type Rectangle_ rectangle point = (Box_ rectangle point, Dimension rectangle ~ 2) Source #

Rectangles are two dimensional boxes.

width :: forall box point (d :: Nat) r. (Box_ box point, Point_ point d r, 0 <= (d - 1), Functor (Vector d), Num r) => box -> r Source #

Get the width of a rectangle.

height :: forall box point (d :: Nat) r. (Box_ box point, Point_ point d r, 1 <= (d - 1), Functor (Vector d), Num r) => box -> r Source #

get the height of a rectangle

size :: forall box (d :: Nat) point r. (Box_ box point, Point_ point d r, Num r, Functor (Vector d)) => box -> 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 myRect
Vector2 9.0 19.0