{-# LANGUAGE UndecidableInstances  #-}
{-# LANGUAGE DeriveAnyClass  #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
--------------------------------------------------------------------------------
-- |
-- Module      :  Data.Geometry.Box
-- Copyright   :  (C) Frank Staals
-- License     :  see the LICENSE file
-- Maintainer  :  Frank Staals
--
-- Orthogonal \(d\)-dimensiontal boxes (e.g. rectangles)
--
--------------------------------------------------------------------------------
module Data.Geometry.Box
  ( module Data.Geometry.Box.Internal
  , module Data.Geometry.Box.Corners
  , module Data.Geometry.Box.Sides
  , inBox'
  ) where

import Control.DeepSeq
import Data.Geometry.Box.Corners
import Data.Geometry.Box.Internal
import Data.Geometry.Box.Sides
import Data.Geometry.Vector
import Data.Geometry.Point
import Data.Geometry.Boundary

--------------------------------------------------------------------------------

deriving instance (NFData p, NFData r, Arity d) => NFData (Box d p r)


-- | Compute whether the point lies inside, on the boundary of, or
-- outside the box.
inBox' :: (Arity d, Ord r) => Point d r -> Box d p r -> PointLocationResult
Point d r
q inBox' :: Point d r -> Box d p r -> PointLocationResult
`inBox'` Box d p r
b | Point d r
q Point d r -> Box d p r -> Bool
forall (d :: Nat) r p.
(Arity d, Ord r) =>
Point d r -> Box d p r -> Bool
`insideBox` Box d p r
b = PointLocationResult
Inside
             | Point d r
q Point d r -> Box d p r -> Bool
forall (d :: Nat) r p.
(Arity d, Ord r) =>
Point d r -> Box d p r -> Bool
`inBox`     Box d p r
b = PointLocationResult
OnBoundary
             | Bool
otherwise       = PointLocationResult
Outside