VEC: use the Square type for inRange

This commit is contained in:
hasufell 2014-11-13 23:04:26 +01:00
parent c765c63125
commit b1280ac958
No known key found for this signature in database
GPG Key ID: 220CD1C5BDEED020
3 changed files with 7 additions and 6 deletions

View File

@ -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

View File

@ -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

View File

@ -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))