VEC: use the Square type for inRange
This commit is contained in:
parent
c765c63125
commit
b1280ac958
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user