{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE RebindableSyntax #-}
module Chart.Data
(
Rect (..),
pattern Rect,
mid,
foldRect,
addPoint,
projectOnP,
projectOnR,
space1,
padRect,
padSingletons,
isSingleton,
Point (..),
addp,
Range (..),
Multiplicative (one),
Additive (zero),
abs,
Direction (..),
Basis (..),
)
where
import NumHask.Prelude
import NumHask.Space
padRect :: (Subtractive a) => a -> Rect a -> Rect a
padRect :: forall a. Subtractive a => a -> Rect a -> Rect a
padRect a
p (Rect a
x a
z a
y a
w) = forall a. a -> a -> a -> a -> Rect a
Rect (a
x forall a. Subtractive a => a -> a -> a
- a
p) (a
z forall a. Additive a => a -> a -> a
+ a
p) (a
y forall a. Subtractive a => a -> a -> a
- a
p) (a
w forall a. Additive a => a -> a -> a
+ a
p)
padSingletons :: Rect Double -> Rect Double
padSingletons :: Rect Double -> Rect Double
padSingletons (Rect Double
x Double
z Double
y Double
w)
| Double
x forall a. Eq a => a -> a -> Bool
== Double
z Bool -> Bool -> Bool
&& Double
y forall a. Eq a => a -> a -> Bool
== Double
w = forall a. a -> a -> a -> a -> Rect a
Rect (Double
x forall a. Subtractive a => a -> a -> a
- Double
0.5) (Double
x forall a. Additive a => a -> a -> a
+ Double
0.5) (Double
y forall a. Subtractive a => a -> a -> a
- Double
0.5) (Double
y forall a. Additive a => a -> a -> a
+ Double
0.5)
| Double
x forall a. Eq a => a -> a -> Bool
== Double
z = forall a. a -> a -> a -> a -> Rect a
Rect (Double
x forall a. Subtractive a => a -> a -> a
- Double
0.5) (Double
x forall a. Additive a => a -> a -> a
+ Double
0.5) Double
y Double
w
| Double
y forall a. Eq a => a -> a -> Bool
== Double
w = forall a. a -> a -> a -> a -> Rect a
Rect Double
x Double
z (Double
y forall a. Subtractive a => a -> a -> a
- Double
0.5) (Double
y forall a. Additive a => a -> a -> a
+ Double
0.5)
| Bool
otherwise = forall a. a -> a -> a -> a -> Rect a
Rect Double
x Double
z Double
y Double
w
isSingleton :: Rect Double -> Bool
isSingleton :: Rect Double -> Bool
isSingleton (Rect Double
x Double
z Double
y Double
w) = Double
x forall a. Eq a => a -> a -> Bool
== Double
z Bool -> Bool -> Bool
|| Double
y forall a. Eq a => a -> a -> Bool
== Double
w
addp :: Point Double -> Point Double -> Point Double
addp :: Point Double -> Point Double -> Point Double
addp = forall a. Additive a => a -> a -> a
(+)