8 import FunctionValues (FunctionValues(FunctionValues))
9 import Tests.FunctionValues
10 import Tetrahedron (v0, volume)
12 instance Arbitrary Cube where
14 (Positive h') <- arbitrary :: Gen (Positive Double)
15 i' <- choose (coordmin, coordmax)
16 j' <- choose (coordmin, coordmax)
17 k' <- choose (coordmin, coordmax)
18 fv' <- arbitrary :: Gen FunctionValues
19 return (Cube h' i' j' k' fv')
21 coordmin = -268435456 -- -(2^29 / 2)
22 coordmax = 268435456 -- +(2^29 / 2)
27 -- | Since the grid size is necessarily positive, all tetrahedrons
28 -- (which comprise cubes of positive volume) must have positive volume
30 prop_all_volumes_positive :: Cube -> Bool
31 prop_all_volumes_positive c =
32 null nonpositive_volumes
35 volumes = map volume ts
36 nonpositive_volumes = filter (<= 0) volumes
38 -- | In fact, since all of the tetrahedra are identical, we should
39 -- already know their volumes. There's 24 tetrahedra to a cube, so
40 -- we'd expect the volume of each one to be (1/24)*h^3.
41 prop_all_volumes_exact :: Cube -> Bool
42 prop_all_volumes_exact c =
43 volume t ~= (1/24)*(delta^(3::Int))
45 t = head $ tetrahedrons c
48 -- | All tetrahedron should have their v0 located at the center of the cube.
49 prop_v0_all_equal :: Cube -> Bool
50 prop_v0_all_equal c = (v0 t0) == (v0 t1)
52 t0 = head (tetrahedrons c) -- Doesn't matter which two we choose.
53 t1 = head $ tail (tetrahedrons c)
56 -- | This pretty much repeats the prop_all_volumes_positive property,
57 -- but will let me know which tetrahedrons's vertices are disoriented.
58 prop_tetrahedron0_volumes_positive :: Cube -> Bool
59 prop_tetrahedron0_volumes_positive c =
60 volume (tetrahedron0 c) > 0
62 -- | This pretty much repeats the prop_all_volumes_positive property,
63 -- but will let me know which tetrahedrons's vertices are disoriented.
64 prop_tetrahedron1_volumes_positive :: Cube -> Bool
65 prop_tetrahedron1_volumes_positive c =
66 volume (tetrahedron1 c) > 0
68 -- | This pretty much repeats the prop_all_volumes_positive property,
69 -- but will let me know which tetrahedrons's vertices are disoriented.
70 prop_tetrahedron2_volumes_positive :: Cube -> Bool
71 prop_tetrahedron2_volumes_positive c =
72 volume (tetrahedron2 c) > 0
74 -- | This pretty much repeats the prop_all_volumes_positive property,
75 -- but will let me know which tetrahedrons's vertices are disoriented.
76 prop_tetrahedron3_volumes_positive :: Cube -> Bool
77 prop_tetrahedron3_volumes_positive c =
78 volume (tetrahedron3 c) > 0
80 -- | This pretty much repeats the prop_all_volumes_positive property,
81 -- but will let me know which tetrahedrons's vertices are disoriented.
82 prop_tetrahedron4_volumes_positive :: Cube -> Bool
83 prop_tetrahedron4_volumes_positive c =
84 volume (tetrahedron4 c) > 0
86 -- | This pretty much repeats the prop_all_volumes_positive property,
87 -- but will let me know which tetrahedrons's vertices are disoriented.
88 prop_tetrahedron5_volumes_positive :: Cube -> Bool
89 prop_tetrahedron5_volumes_positive c =
90 volume (tetrahedron5 c) > 0
92 -- | This pretty much repeats the prop_all_volumes_positive property,
93 -- but will let me know which tetrahedrons's vertices are disoriented.
94 prop_tetrahedron6_volumes_positive :: Cube -> Bool
95 prop_tetrahedron6_volumes_positive c =
96 volume (tetrahedron6 c) > 0
98 -- | This pretty much repeats the prop_all_volumes_positive property,
99 -- but will let me know which tetrahedrons's vertices are disoriented.
100 prop_tetrahedron7_volumes_positive :: Cube -> Bool
101 prop_tetrahedron7_volumes_positive c =
102 volume (tetrahedron7 c) > 0