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_tetrahedron0_volumes_exact :: Cube -> Bool
42 prop_tetrahedron0_volumes_exact c =
43 volume (tetrahedron0 c) ~= (1/24)*(delta^(3::Int))
47 -- | In fact, since all of the tetrahedra are identical, we should
48 -- already know their volumes. There's 24 tetrahedra to a cube, so
49 -- we'd expect the volume of each one to be (1/24)*h^3.
50 prop_tetrahedron1_volumes_exact :: Cube -> Bool
51 prop_tetrahedron1_volumes_exact c =
52 volume (tetrahedron1 c) ~= (1/24)*(delta^(3::Int))
56 -- | In fact, since all of the tetrahedra are identical, we should
57 -- already know their volumes. There's 24 tetrahedra to a cube, so
58 -- we'd expect the volume of each one to be (1/24)*h^3.
59 prop_tetrahedron2_volumes_exact :: Cube -> Bool
60 prop_tetrahedron2_volumes_exact c =
61 volume (tetrahedron2 c) ~= (1/24)*(delta^(3::Int))
65 -- | In fact, since all of the tetrahedra are identical, we should
66 -- already know their volumes. There's 24 tetrahedra to a cube, so
67 -- we'd expect the volume of each one to be (1/24)*h^3.
68 prop_tetrahedron3_volumes_exact :: Cube -> Bool
69 prop_tetrahedron3_volumes_exact c =
70 volume (tetrahedron3 c) ~= (1/24)*(delta^(3::Int))
74 -- | In fact, since all of the tetrahedra are identical, we should
75 -- already know their volumes. There's 24 tetrahedra to a cube, so
76 -- we'd expect the volume of each one to be (1/24)*h^3.
77 prop_tetrahedron4_volumes_exact :: Cube -> Bool
78 prop_tetrahedron4_volumes_exact c =
79 volume (tetrahedron4 c) ~= (1/24)*(delta^(3::Int))
83 -- | In fact, since all of the tetrahedra are identical, we should
84 -- already know their volumes. There's 24 tetrahedra to a cube, so
85 -- we'd expect the volume of each one to be (1/24)*h^3.
86 prop_tetrahedron5_volumes_exact :: Cube -> Bool
87 prop_tetrahedron5_volumes_exact c =
88 volume (tetrahedron5 c) ~= (1/24)*(delta^(3::Int))
92 -- | In fact, since all of the tetrahedra are identical, we should
93 -- already know their volumes. There's 24 tetrahedra to a cube, so
94 -- we'd expect the volume of each one to be (1/24)*h^3.
95 prop_tetrahedron6_volumes_exact :: Cube -> Bool
96 prop_tetrahedron6_volumes_exact c =
97 volume (tetrahedron6 c) ~= (1/24)*(delta^(3::Int))
101 -- | In fact, since all of the tetrahedra are identical, we should
102 -- already know their volumes. There's 24 tetrahedra to a cube, so
103 -- we'd expect the volume of each one to be (1/24)*h^3.
104 prop_tetrahedron7_volumes_exact :: Cube -> Bool
105 prop_tetrahedron7_volumes_exact c =
106 volume (tetrahedron7 c) ~= (1/24)*(delta^(3::Int))
110 -- | All tetrahedron should have their v0 located at the center of the cube.
111 prop_v0_all_equal :: Cube -> Bool
112 prop_v0_all_equal c = (v0 t0) == (v0 t1)
114 t0 = head (tetrahedrons c) -- Doesn't matter which two we choose.
115 t1 = head $ tail (tetrahedrons c)
118 -- | This pretty much repeats the prop_all_volumes_positive property,
119 -- but will let me know which tetrahedrons's vertices are disoriented.
120 prop_tetrahedron0_volumes_positive :: Cube -> Bool
121 prop_tetrahedron0_volumes_positive c =
122 volume (tetrahedron0 c) > 0
124 -- | This pretty much repeats the prop_all_volumes_positive property,
125 -- but will let me know which tetrahedrons's vertices are disoriented.
126 prop_tetrahedron1_volumes_positive :: Cube -> Bool
127 prop_tetrahedron1_volumes_positive c =
128 volume (tetrahedron1 c) > 0
130 -- | This pretty much repeats the prop_all_volumes_positive property,
131 -- but will let me know which tetrahedrons's vertices are disoriented.
132 prop_tetrahedron2_volumes_positive :: Cube -> Bool
133 prop_tetrahedron2_volumes_positive c =
134 volume (tetrahedron2 c) > 0
136 -- | This pretty much repeats the prop_all_volumes_positive property,
137 -- but will let me know which tetrahedrons's vertices are disoriented.
138 prop_tetrahedron3_volumes_positive :: Cube -> Bool
139 prop_tetrahedron3_volumes_positive c =
140 volume (tetrahedron3 c) > 0
142 -- | This pretty much repeats the prop_all_volumes_positive property,
143 -- but will let me know which tetrahedrons's vertices are disoriented.
144 prop_tetrahedron4_volumes_positive :: Cube -> Bool
145 prop_tetrahedron4_volumes_positive c =
146 volume (tetrahedron4 c) > 0
148 -- | This pretty much repeats the prop_all_volumes_positive property,
149 -- but will let me know which tetrahedrons's vertices are disoriented.
150 prop_tetrahedron5_volumes_positive :: Cube -> Bool
151 prop_tetrahedron5_volumes_positive c =
152 volume (tetrahedron5 c) > 0
154 -- | This pretty much repeats the prop_all_volumes_positive property,
155 -- but will let me know which tetrahedrons's vertices are disoriented.
156 prop_tetrahedron6_volumes_positive :: Cube -> Bool
157 prop_tetrahedron6_volumes_positive c =
158 volume (tetrahedron6 c) > 0
160 -- | This pretty much repeats the prop_all_volumes_positive property,
161 -- but will let me know which tetrahedrons's vertices are disoriented.
162 prop_tetrahedron7_volumes_positive :: Cube -> Bool
163 prop_tetrahedron7_volumes_positive c =
164 volume (tetrahedron7 c) > 0