From b1280ac95807f6f871224e2ac9b3a3d5620ccc85 Mon Sep 17 00:00:00 2001 From: hasufell Date: Thu, 13 Nov 2014 23:04:26 +0100 Subject: [PATCH] VEC: use the Square type for inRange --- Algebra/Vector.hs | 10 +++++----- Algebra/VectorTypes.hs | 1 + Graphics/Diagram/Types.hs | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Algebra/Vector.hs b/Algebra/Vector.hs index abcab5d..7bdc9c4 100644 --- a/Algebra/Vector.hs +++ b/Algebra/Vector.hs @@ -11,11 +11,11 @@ import MyPrelude -- |Checks whether the Point is in a given dimension. -inRange :: Coord -- ^ X dimension - -> Coord -- ^ Y dimension - -> PT -- ^ Coordinates - -> Bool -- ^ result -inRange (xlD, xuD) (ylD, yuD) p = x <= xuD && x >= xlD && y <= yuD && y >= ylD +inRange :: Square -- ^ the square, defined by x/y dimensions + -> PT -- ^ Coordinate + -> Bool -- ^ result +inRange ((xlD, xuD), (ylD, yuD)) p = + x <= xuD && x >= xlD && y <= yuD && y >= ylD where (x, y) = unp2 p diff --git a/Algebra/VectorTypes.hs b/Algebra/VectorTypes.hs index d6934bc..0f64f4b 100644 --- a/Algebra/VectorTypes.hs +++ b/Algebra/VectorTypes.hs @@ -9,6 +9,7 @@ type Vec = R2 type PT = P2 type Coord = (Double, Double) type Segment = (PT, PT) +type Square = (Coord, Coord) data Alignment = CW diff --git a/Graphics/Diagram/Types.hs b/Graphics/Diagram/Types.hs index df02049..15aec10 100644 --- a/Graphics/Diagram/Types.hs +++ b/Graphics/Diagram/Types.hs @@ -138,4 +138,4 @@ maybeDiag b d filterValidPT :: DiagProp -> [PT] -> [PT] -filterValidPT p = filter (inRange (dX p) (dY p)) +filterValidPT p = filter (inRange (dX p, dY p))