]> gitweb.michael.orlitzky.com - spline3.git/blob - src/Tests/Cube.hs
Add tests/code for tetrahedron 12 through 15.
[spline3.git] / src / Tests / Cube.hs
1 module Tests.Cube
2 where
3
4 import Test.QuickCheck
5
6 import Comparisons
7 import Cube
8 import FunctionValues (FunctionValues(FunctionValues))
9 import Tests.FunctionValues
10 import Tetrahedron (v0, volume)
11
12 instance Arbitrary Cube where
13 arbitrary = do
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')
20 where
21 coordmin = -268435456 -- -(2^29 / 2)
22 coordmax = 268435456 -- +(2^29 / 2)
23
24
25 -- Quickcheck tests.
26
27 -- | Since the grid size is necessarily positive, all tetrahedrons
28 -- (which comprise cubes of positive volume) must have positive volume
29 -- as well.
30 prop_all_volumes_positive :: Cube -> Bool
31 prop_all_volumes_positive c =
32 null nonpositive_volumes
33 where
34 ts = tetrahedrons c
35 volumes = map volume ts
36 nonpositive_volumes = filter (<= 0) volumes
37
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))
44 where
45 delta = h c
46
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))
53 where
54 delta = h c
55
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))
62 where
63 delta = h c
64
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))
71 where
72 delta = h c
73
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))
80 where
81 delta = h c
82
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))
89 where
90 delta = h c
91
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))
98 where
99 delta = h c
100
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))
107 where
108 delta = h c
109
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)
113 where
114 t0 = head (tetrahedrons c) -- Doesn't matter which two we choose.
115 t1 = head $ tail (tetrahedrons c)
116
117
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
123
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
129
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
135
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
141
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
147
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
153
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
159
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
165
166 -- | This pretty much repeats the prop_all_volumes_positive property,
167 -- but will let me know which tetrahedrons's vertices are disoriented.
168 prop_tetrahedron8_volumes_positive :: Cube -> Bool
169 prop_tetrahedron8_volumes_positive c =
170 volume (tetrahedron8 c) > 0
171
172 -- | This pretty much repeats the prop_all_volumes_positive property,
173 -- but will let me know which tetrahedrons's vertices are disoriented.
174 prop_tetrahedron9_volumes_positive :: Cube -> Bool
175 prop_tetrahedron9_volumes_positive c =
176 volume (tetrahedron9 c) > 0
177
178 -- | This pretty much repeats the prop_all_volumes_positive property,
179 -- but will let me know which tetrahedrons's vertices are disoriented.
180 prop_tetrahedron10_volumes_positive :: Cube -> Bool
181 prop_tetrahedron10_volumes_positive c =
182 volume (tetrahedron10 c) > 0
183
184 -- | This pretty much repeats the prop_all_volumes_positive property,
185 -- but will let me know which tetrahedrons's vertices are disoriented.
186 prop_tetrahedron11_volumes_positive :: Cube -> Bool
187 prop_tetrahedron11_volumes_positive c =
188 volume (tetrahedron11 c) > 0
189
190 -- | This pretty much repeats the prop_all_volumes_positive property,
191 -- but will let me know which tetrahedrons's vertices are disoriented.
192 prop_tetrahedron12_volumes_positive :: Cube -> Bool
193 prop_tetrahedron12_volumes_positive c =
194 volume (tetrahedron12 c) > 0
195
196 -- | This pretty much repeats the prop_all_volumes_positive property,
197 -- but will let me know which tetrahedrons's vertices are disoriented.
198 prop_tetrahedron13_volumes_positive :: Cube -> Bool
199 prop_tetrahedron13_volumes_positive c =
200 volume (tetrahedron13 c) > 0
201
202 -- | This pretty much repeats the prop_all_volumes_positive property,
203 -- but will let me know which tetrahedrons's vertices are disoriented.
204 prop_tetrahedron14_volumes_positive :: Cube -> Bool
205 prop_tetrahedron14_volumes_positive c =
206 volume (tetrahedron14 c) > 0
207
208 -- | This pretty much repeats the prop_all_volumes_positive property,
209 -- but will let me know which tetrahedrons's vertices are disoriented.
210 prop_tetrahedron15_volumes_positive :: Cube -> Bool
211 prop_tetrahedron15_volumes_positive c =
212 volume (tetrahedron15 c) > 0