2014-09-30 22:05:29 +00:00
|
|
|
module Util where
|
|
|
|
|
|
|
|
|
|
|
|
-- |Checks whether the Coordinates are in a given range.
|
|
|
|
inRange :: (Double, Double) -- ^ Coordinates to check
|
|
|
|
-> Double -- ^ min
|
|
|
|
-> Double -- ^ max
|
|
|
|
-> Bool -- ^ result
|
|
|
|
inRange (x, y) min' max'
|
|
|
|
| x <= max' && x >= min' && y <= max' && y >= min' = True
|
|
|
|
| otherwise = False
|
|
|
|
|
|
|
|
|
|
|
|
-- |Filter the valid coordinates.
|
2014-09-30 23:19:20 +00:00
|
|
|
filterValidCoords :: Double -- ^ min
|
2014-09-30 22:05:29 +00:00
|
|
|
-> Double -- ^ max
|
|
|
|
-> [(Double, Double)] -- ^ unfiltered
|
|
|
|
-> [(Double, Double)] -- ^ filtered
|
|
|
|
filterValidCoords min' max' = filter (\(x, y) -> inRange (x, y) min' max')
|