module Graphics.Gloss.Data.Point
        ( Point, Path
        , pointInBox)
where
import Graphics.Gloss.Data.Picture


-- | Test whether a point lies within a rectangular box that is oriented
--   on the x-y plane. The points P1-P2 are opposing points of the box,
--   but need not be in a particular order.
--
-- @
--    P2 +-------+
--       |       |
--       | + P0  |
--       |       |
--       +-------+ P1
-- @
--
pointInBox
        :: Point
        -> Point
        -> Point -> Bool

pointInBox :: Point -> Point -> Point -> Bool
pointInBox (Float
x0, Float
y0) (Float
x1, Float
y1) (Float
x2, Float
y2)
        =  Float
x0 Float -> Float -> Bool
forall a. Ord a => a -> a -> Bool
>= Float -> Float -> Float
forall a. Ord a => a -> a -> a
min Float
x1 Float
x2
        Bool -> Bool -> Bool
&& Float
x0 Float -> Float -> Bool
forall a. Ord a => a -> a -> Bool
<= Float -> Float -> Float
forall a. Ord a => a -> a -> a
max Float
x1 Float
x2
        Bool -> Bool -> Bool
&& Float
y0 Float -> Float -> Bool
forall a. Ord a => a -> a -> Bool
>= Float -> Float -> Float
forall a. Ord a => a -> a -> a
min Float
y1 Float
y2
        Bool -> Bool -> Bool
&& Float
y0 Float -> Float -> Bool
forall a. Ord a => a -> a -> Bool
<= Float -> Float -> Float
forall a. Ord a => a -> a -> a
max Float
y1 Float
y2