data-spacepart-0.1.1: test/Verify/Data/AABB.hs
module Verify.Data.AABB ( module Verify.Data.AABB
, module Data.AABB
)
where
import Data.AABB
import Control.Monad
import Test.QuickCheck
instance Arbitrary Boundary where
arbitrary = do
corner <- arbitrary
s <- liftM abs arbitrary
return $ Boundary corner s
data NonIntersectingBounds = NonIntersectingBounds Boundary Boundary
deriving (Eq, Show)
{- Two non-intersecting bounds can be generated by generating an arbitrary rectange defined by a min
- extent and max extent.
- The min extent is the corner of one boundary, p_0. The max extent is the corner of the other boundary, p_1.
- The boundary with a corner at p_1 can have any size.
- While the boundary with a corner at p_0 can not be given a size that could imply a boundary
- intersection.
-}
instance Arbitrary NonIntersectingBounds where
arbitrary = do
x_0 <- arbitrary
y_0 <- arbitrary
x_1 <- arbitrary
y_1 <- arbitrary
let p_0 = (min x_0 x_1, min y_0 y_1)
p_1 = (max x_0 x_1, max y_0 y_1)
s_0 <- choose (0.0, min (fst p_1 - fst p_0) (snd p_1 - snd p_0))
s_1 <- arbitrary
return $ NonIntersectingBounds (Boundary p_0 s_0) (Boundary p_1 s_1)
intersects_is_reflexive_prop :: Boundary -> Bool
intersects_is_reflexive_prop b = b `intersects` b
encloses_is_reflexive_prop :: Boundary -> Bool
encloses_is_reflexive_prop b = b `encloses` b