| Safe Haskell | None | 
|---|---|
| Language | Haskell2010 | 
NumHask.Rect
- newtype Rect a = Rect' (Compose Pair Range a)
 - pattern Rect :: a -> a -> a -> a -> Rect a
 - pattern Ranges :: Range a -> Range a -> Rect a
 - corners :: (FromInteger a, Signed a, BoundedField a, Ord a) => Rect a -> [Pair a]
 - projectRect :: (FromInteger a, Signed a, Ord a, BoundedField a) => Rect a -> Rect a -> Rect a -> Rect a
 
Documentation
a Pair of Ranges that form a rectangle in what is often thought of as the XY plane.
>>>let a = Rect (-1) 1 (-2) 4>>>aRect -1 1 -2 4>>>let (Ranges x y) = a>>>xRange -1 1>>>yRange -2 4>>>fmap (+1) (Rect 1 2 3 4)Rect 2 3 4 5>>>one :: Rect DoubleRect -0.5 0.5 -0.5 0.5>>>zero :: Rect DoubleRect Infinity -Infinity Infinity -Infinity
as a Field instance
>>>Rect 0 1 2 3 + zeroRect 0.0 1.0 2.0 3.0>>>Rect 0 1 (-2) (-1) + Rect 2 3 (-5) 3Rect 0.0 3.0 -5.0 3.0>>>Rect 1 1 1 1 - oneRect 0.5 1.0 0.5 1.0>>>Rect 0 1 0 1 * oneRect 0.0 1.0 0.0 1.0>>>Rect 0 1 0 1 / oneRect 0.0 1.0 0.0 1.0>>>singleton (Pair 1.0 2.0) :: Rect DoubleRect 1.0 1.0 2.0 2.0>>>abs (Rect 1 0 1 0)Rect 0.0 1.0 0.0 1.0>>>sign (Rect 1 0 1 0) == negate oneTrue
as a Space instance
>>>project (Rect 0 1 (-1) 0) (Rect 1 4 10 0) (Pair 0.5 1)Pair 2.5 -10.0>>>gridSpace (Rect 0 10 0 1) (Pair 2 2)[Rect 0.0 5.0 0.0 0.5,Rect 0.0 5.0 0.5 1.0,Rect 5.0 10.0 0.0 0.5,Rect 5.0 10.0 0.5 1.0]>>>grid MidPos (Rect 0 10 0 1) (Pair 2 2)[Pair 2.5 0.25,Pair 2.5 0.75,Pair 7.5 0.25,Pair 7.5 0.75]
Instances
corners :: (FromInteger a, Signed a, BoundedField a, Ord a) => Rect a -> [Pair a] Source #
create a list of pairs representing the lower left and upper right cormners of a rectangle.
projectRect :: (FromInteger a, Signed a, Ord a, BoundedField a) => Rect a -> Rect a -> Rect a -> Rect a Source #
project a Rect from an old range to a new one