data Region = HalfPlane Coordinate Coordinate
type Coordinate = (Float, Float)
containsR :: Region -> Coordinate -> Bool
HalfPlane p1 p2 `containsR` p = p `isLeftOf` (p1, p2)
----- reuse the isLeftOf function -----
isLeftOf :: Coordinate -> Ray -> Bool
(px, py) `isLeftOf` ((ax, ay), (bx, by))
= let (s, t) = (px - ax, py - ay)
(u, v) = (px - bx, py - by)
in s * v >= t * u
type Ray = (Coordinate, Coordinate)
This entry was posted
on Wednesday, May 30th, 2007 at 4:36 pm and is filed under Haskell - SOE.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.