]> gitweb.michael.orlitzky.com - spline3.git/blob - src/Tests/Cube.hs
Add a bunch more exact volume tests.
[spline3.git] / src / Tests / Cube.hs
1 module Tests.Cube
2 where
3
4 import Prelude hiding (LT)
5 import Test.QuickCheck
6
7 import Cardinal
8 import Comparisons
9 import Cube
10 import FunctionValues
11 import Misc (all_equal)
12 import Tests.FunctionValues ()
13 import Tetrahedron (b0, b1, b2, b3, c, fv,
14 v0, v1, v2, v3, volume)
15
16 instance Arbitrary Cube where
17 arbitrary = do
18 (Positive h') <- arbitrary :: Gen (Positive Double)
19 i' <- choose (coordmin, coordmax)
20 j' <- choose (coordmin, coordmax)
21 k' <- choose (coordmin, coordmax)
22 fv' <- arbitrary :: Gen FunctionValues
23 return (Cube h' i' j' k' fv')
24 where
25 coordmin = -268435456 -- -(2^29 / 2)
26 coordmax = 268435456 -- +(2^29 / 2)
27
28
29 -- Quickcheck tests.
30
31 -- | Since the grid size is necessarily positive, all tetrahedrons
32 -- (which comprise cubes of positive volume) must have positive volume
33 -- as well.
34 prop_all_volumes_positive :: Cube -> Bool
35 prop_all_volumes_positive cube =
36 null nonpositive_volumes
37 where
38 ts = tetrahedrons cube
39 volumes = map volume ts
40 nonpositive_volumes = filter (<= 0) volumes
41
42 -- | In fact, since all of the tetrahedra are identical, we should
43 -- already know their volumes. There's 24 tetrahedra to a cube, so
44 -- we'd expect the volume of each one to be (1/24)*h^3.
45 prop_tetrahedron0_volumes_exact :: Cube -> Bool
46 prop_tetrahedron0_volumes_exact cube =
47 volume (tetrahedron0 cube) ~~= (1/24)*(delta^(3::Int))
48 where
49 delta = h cube
50
51
52 -- | In fact, since all of the tetrahedra are identical, we should
53 -- already know their volumes. There's 24 tetrahedra to a cube, so
54 -- we'd expect the volume of each one to be (1/24)*h^3.
55 prop_tetrahedron1_volumes_exact :: Cube -> Bool
56 prop_tetrahedron1_volumes_exact cube =
57 volume (tetrahedron1 cube) ~~= (1/24)*(delta^(3::Int))
58 where
59 delta = h cube
60
61 -- | In fact, since all of the tetrahedra are identical, we should
62 -- already know their volumes. There's 24 tetrahedra to a cube, so
63 -- we'd expect the volume of each one to be (1/24)*h^3.
64 prop_tetrahedron2_volumes_exact :: Cube -> Bool
65 prop_tetrahedron2_volumes_exact cube =
66 volume (tetrahedron2 cube) ~~= (1/24)*(delta^(3::Int))
67 where
68 delta = h cube
69
70 -- | In fact, since all of the tetrahedra are identical, we should
71 -- already know their volumes. There's 24 tetrahedra to a cube, so
72 -- we'd expect the volume of each one to be (1/24)*h^3.
73 prop_tetrahedron3_volumes_exact :: Cube -> Bool
74 prop_tetrahedron3_volumes_exact cube =
75 volume (tetrahedron3 cube) ~~= (1/24)*(delta^(3::Int))
76 where
77 delta = h cube
78
79 -- | In fact, since all of the tetrahedra are identical, we should
80 -- already know their volumes. There's 24 tetrahedra to a cube, so
81 -- we'd expect the volume of each one to be (1/24)*h^3.
82 prop_tetrahedron4_volumes_exact :: Cube -> Bool
83 prop_tetrahedron4_volumes_exact cube =
84 volume (tetrahedron4 cube) ~~= (1/24)*(delta^(3::Int))
85 where
86 delta = h cube
87
88 -- | In fact, since all of the tetrahedra are identical, we should
89 -- already know their volumes. There's 24 tetrahedra to a cube, so
90 -- we'd expect the volume of each one to be (1/24)*h^3.
91 prop_tetrahedron5_volumes_exact :: Cube -> Bool
92 prop_tetrahedron5_volumes_exact cube =
93 volume (tetrahedron5 cube) ~~= (1/24)*(delta^(3::Int))
94 where
95 delta = h cube
96
97 -- | In fact, since all of the tetrahedra are identical, we should
98 -- already know their volumes. There's 24 tetrahedra to a cube, so
99 -- we'd expect the volume of each one to be (1/24)*h^3.
100 prop_tetrahedron6_volumes_exact :: Cube -> Bool
101 prop_tetrahedron6_volumes_exact cube =
102 volume (tetrahedron6 cube) ~~= (1/24)*(delta^(3::Int))
103 where
104 delta = h cube
105
106 -- | In fact, since all of the tetrahedra are identical, we should
107 -- already know their volumes. There's 24 tetrahedra to a cube, so
108 -- we'd expect the volume of each one to be (1/24)*h^3.
109 prop_tetrahedron7_volumes_exact :: Cube -> Bool
110 prop_tetrahedron7_volumes_exact cube =
111 volume (tetrahedron7 cube) ~~= (1/24)*(delta^(3::Int))
112 where
113 delta = h cube
114
115 -- | In fact, since all of the tetrahedra are identical, we should
116 -- already know their volumes. There's 24 tetrahedra to a cube, so
117 -- we'd expect the volume of each one to be (1/24)*h^3.
118 prop_tetrahedron8_volumes_exact :: Cube -> Bool
119 prop_tetrahedron8_volumes_exact cube =
120 volume (tetrahedron8 cube) ~~= (1/24)*(delta^(3::Int))
121 where
122 delta = h cube
123
124 -- | In fact, since all of the tetrahedra are identical, we should
125 -- already know their volumes. There's 24 tetrahedra to a cube, so
126 -- we'd expect the volume of each one to be (1/24)*h^3.
127 prop_tetrahedron9_volumes_exact :: Cube -> Bool
128 prop_tetrahedron9_volumes_exact cube =
129 volume (tetrahedron9 cube) ~~= (1/24)*(delta^(3::Int))
130 where
131 delta = h cube
132
133 -- | In fact, since all of the tetrahedra are identical, we should
134 -- already know their volumes. There's 24 tetrahedra to a cube, so
135 -- we'd expect the volume of each one to be (1/24)*h^3.
136 prop_tetrahedron10_volumes_exact :: Cube -> Bool
137 prop_tetrahedron10_volumes_exact cube =
138 volume (tetrahedron10 cube) ~~= (1/24)*(delta^(3::Int))
139 where
140 delta = h cube
141
142 -- | In fact, since all of the tetrahedra are identical, we should
143 -- already know their volumes. There's 24 tetrahedra to a cube, so
144 -- we'd expect the volume of each one to be (1/24)*h^3.
145 prop_tetrahedron11_volumes_exact :: Cube -> Bool
146 prop_tetrahedron11_volumes_exact cube =
147 volume (tetrahedron11 cube) ~~= (1/24)*(delta^(3::Int))
148 where
149 delta = h cube
150
151 -- | In fact, since all of the tetrahedra are identical, we should
152 -- already know their volumes. There's 24 tetrahedra to a cube, so
153 -- we'd expect the volume of each one to be (1/24)*h^3.
154 prop_tetrahedron12_volumes_exact :: Cube -> Bool
155 prop_tetrahedron12_volumes_exact cube =
156 volume (tetrahedron12 cube) ~~= (1/24)*(delta^(3::Int))
157 where
158 delta = h cube
159
160 -- | In fact, since all of the tetrahedra are identical, we should
161 -- already know their volumes. There's 24 tetrahedra to a cube, so
162 -- we'd expect the volume of each one to be (1/24)*h^3.
163 prop_tetrahedron13_volumes_exact :: Cube -> Bool
164 prop_tetrahedron13_volumes_exact cube =
165 volume (tetrahedron13 cube) ~~= (1/24)*(delta^(3::Int))
166 where
167 delta = h cube
168
169 -- | In fact, since all of the tetrahedra are identical, we should
170 -- already know their volumes. There's 24 tetrahedra to a cube, so
171 -- we'd expect the volume of each one to be (1/24)*h^3.
172 prop_tetrahedron14_volumes_exact :: Cube -> Bool
173 prop_tetrahedron14_volumes_exact cube =
174 volume (tetrahedron14 cube) ~~= (1/24)*(delta^(3::Int))
175 where
176 delta = h cube
177
178 -- | In fact, since all of the tetrahedra are identical, we should
179 -- already know their volumes. There's 24 tetrahedra to a cube, so
180 -- we'd expect the volume of each one to be (1/24)*h^3.
181 prop_tetrahedron15_volumes_exact :: Cube -> Bool
182 prop_tetrahedron15_volumes_exact cube =
183 volume (tetrahedron15 cube) ~~= (1/24)*(delta^(3::Int))
184 where
185 delta = h cube
186
187 -- | In fact, since all of the tetrahedra are identical, we should
188 -- already know their volumes. There's 24 tetrahedra to a cube, so
189 -- we'd expect the volume of each one to be (1/24)*h^3.
190 prop_tetrahedron16_volumes_exact :: Cube -> Bool
191 prop_tetrahedron16_volumes_exact cube =
192 volume (tetrahedron16 cube) ~~= (1/24)*(delta^(3::Int))
193 where
194 delta = h cube
195
196 -- | In fact, since all of the tetrahedra are identical, we should
197 -- already know their volumes. There's 24 tetrahedra to a cube, so
198 -- we'd expect the volume of each one to be (1/24)*h^3.
199 prop_tetrahedron17_volumes_exact :: Cube -> Bool
200 prop_tetrahedron17_volumes_exact cube =
201 volume (tetrahedron17 cube) ~~= (1/24)*(delta^(3::Int))
202 where
203 delta = h cube
204
205 -- | In fact, since all of the tetrahedra are identical, we should
206 -- already know their volumes. There's 24 tetrahedra to a cube, so
207 -- we'd expect the volume of each one to be (1/24)*h^3.
208 prop_tetrahedron18_volumes_exact :: Cube -> Bool
209 prop_tetrahedron18_volumes_exact cube =
210 volume (tetrahedron18 cube) ~~= (1/24)*(delta^(3::Int))
211 where
212 delta = h cube
213
214 -- | In fact, since all of the tetrahedra are identical, we should
215 -- already know their volumes. There's 24 tetrahedra to a cube, so
216 -- we'd expect the volume of each one to be (1/24)*h^3.
217 prop_tetrahedron19_volumes_exact :: Cube -> Bool
218 prop_tetrahedron19_volumes_exact cube =
219 volume (tetrahedron19 cube) ~~= (1/24)*(delta^(3::Int))
220 where
221 delta = h cube
222
223 -- | In fact, since all of the tetrahedra are identical, we should
224 -- already know their volumes. There's 24 tetrahedra to a cube, so
225 -- we'd expect the volume of each one to be (1/24)*h^3.
226 prop_tetrahedron20_volumes_exact :: Cube -> Bool
227 prop_tetrahedron20_volumes_exact cube =
228 volume (tetrahedron20 cube) ~~= (1/24)*(delta^(3::Int))
229 where
230 delta = h cube
231
232 -- | In fact, since all of the tetrahedra are identical, we should
233 -- already know their volumes. There's 24 tetrahedra to a cube, so
234 -- we'd expect the volume of each one to be (1/24)*h^3.
235 prop_tetrahedron21_volumes_exact :: Cube -> Bool
236 prop_tetrahedron21_volumes_exact cube =
237 volume (tetrahedron21 cube) ~~= (1/24)*(delta^(3::Int))
238 where
239 delta = h cube
240
241 -- | In fact, since all of the tetrahedra are identical, we should
242 -- already know their volumes. There's 24 tetrahedra to a cube, so
243 -- we'd expect the volume of each one to be (1/24)*h^3.
244 prop_tetrahedron22_volumes_exact :: Cube -> Bool
245 prop_tetrahedron22_volumes_exact cube =
246 volume (tetrahedron22 cube) ~~= (1/24)*(delta^(3::Int))
247 where
248 delta = h cube
249
250 -- | In fact, since all of the tetrahedra are identical, we should
251 -- already know their volumes. There's 24 tetrahedra to a cube, so
252 -- we'd expect the volume of each one to be (1/24)*h^3.
253 prop_tetrahedron23_volumes_exact :: Cube -> Bool
254 prop_tetrahedron23_volumes_exact cube =
255 volume (tetrahedron23 cube) ~~= (1/24)*(delta^(3::Int))
256 where
257 delta = h cube
258
259 -- | All tetrahedron should have their v0 located at the center of the cube.
260 prop_v0_all_equal :: Cube -> Bool
261 prop_v0_all_equal cube = (v0 t0) == (v0 t1)
262 where
263 t0 = head (tetrahedrons cube) -- Doesn't matter which two we choose.
264 t1 = head $ tail (tetrahedrons cube)
265
266
267 -- | This pretty much repeats the prop_all_volumes_positive property,
268 -- but will let me know which tetrahedrons's vertices are disoriented.
269 prop_tetrahedron0_volumes_positive :: Cube -> Bool
270 prop_tetrahedron0_volumes_positive cube =
271 volume (tetrahedron0 cube) > 0
272
273 -- | This pretty much repeats the prop_all_volumes_positive property,
274 -- but will let me know which tetrahedrons's vertices are disoriented.
275 prop_tetrahedron1_volumes_positive :: Cube -> Bool
276 prop_tetrahedron1_volumes_positive cube =
277 volume (tetrahedron1 cube) > 0
278
279 -- | This pretty much repeats the prop_all_volumes_positive property,
280 -- but will let me know which tetrahedrons's vertices are disoriented.
281 prop_tetrahedron2_volumes_positive :: Cube -> Bool
282 prop_tetrahedron2_volumes_positive cube =
283 volume (tetrahedron2 cube) > 0
284
285 -- | This pretty much repeats the prop_all_volumes_positive property,
286 -- but will let me know which tetrahedrons's vertices are disoriented.
287 prop_tetrahedron3_volumes_positive :: Cube -> Bool
288 prop_tetrahedron3_volumes_positive cube =
289 volume (tetrahedron3 cube) > 0
290
291 -- | This pretty much repeats the prop_all_volumes_positive property,
292 -- but will let me know which tetrahedrons's vertices are disoriented.
293 prop_tetrahedron4_volumes_positive :: Cube -> Bool
294 prop_tetrahedron4_volumes_positive cube =
295 volume (tetrahedron4 cube) > 0
296
297 -- | This pretty much repeats the prop_all_volumes_positive property,
298 -- but will let me know which tetrahedrons's vertices are disoriented.
299 prop_tetrahedron5_volumes_positive :: Cube -> Bool
300 prop_tetrahedron5_volumes_positive cube =
301 volume (tetrahedron5 cube) > 0
302
303 -- | This pretty much repeats the prop_all_volumes_positive property,
304 -- but will let me know which tetrahedrons's vertices are disoriented.
305 prop_tetrahedron6_volumes_positive :: Cube -> Bool
306 prop_tetrahedron6_volumes_positive cube =
307 volume (tetrahedron6 cube) > 0
308
309 -- | This pretty much repeats the prop_all_volumes_positive property,
310 -- but will let me know which tetrahedrons's vertices are disoriented.
311 prop_tetrahedron7_volumes_positive :: Cube -> Bool
312 prop_tetrahedron7_volumes_positive cube =
313 volume (tetrahedron7 cube) > 0
314
315 -- | This pretty much repeats the prop_all_volumes_positive property,
316 -- but will let me know which tetrahedrons's vertices are disoriented.
317 prop_tetrahedron8_volumes_positive :: Cube -> Bool
318 prop_tetrahedron8_volumes_positive cube =
319 volume (tetrahedron8 cube) > 0
320
321 -- | This pretty much repeats the prop_all_volumes_positive property,
322 -- but will let me know which tetrahedrons's vertices are disoriented.
323 prop_tetrahedron9_volumes_positive :: Cube -> Bool
324 prop_tetrahedron9_volumes_positive cube =
325 volume (tetrahedron9 cube) > 0
326
327 -- | This pretty much repeats the prop_all_volumes_positive property,
328 -- but will let me know which tetrahedrons's vertices are disoriented.
329 prop_tetrahedron10_volumes_positive :: Cube -> Bool
330 prop_tetrahedron10_volumes_positive cube =
331 volume (tetrahedron10 cube) > 0
332
333 -- | This pretty much repeats the prop_all_volumes_positive property,
334 -- but will let me know which tetrahedrons's vertices are disoriented.
335 prop_tetrahedron11_volumes_positive :: Cube -> Bool
336 prop_tetrahedron11_volumes_positive cube =
337 volume (tetrahedron11 cube) > 0
338
339 -- | This pretty much repeats the prop_all_volumes_positive property,
340 -- but will let me know which tetrahedrons's vertices are disoriented.
341 prop_tetrahedron12_volumes_positive :: Cube -> Bool
342 prop_tetrahedron12_volumes_positive cube =
343 volume (tetrahedron12 cube) > 0
344
345 -- | This pretty much repeats the prop_all_volumes_positive property,
346 -- but will let me know which tetrahedrons's vertices are disoriented.
347 prop_tetrahedron13_volumes_positive :: Cube -> Bool
348 prop_tetrahedron13_volumes_positive cube =
349 volume (tetrahedron13 cube) > 0
350
351 -- | This pretty much repeats the prop_all_volumes_positive property,
352 -- but will let me know which tetrahedrons's vertices are disoriented.
353 prop_tetrahedron14_volumes_positive :: Cube -> Bool
354 prop_tetrahedron14_volumes_positive cube =
355 volume (tetrahedron14 cube) > 0
356
357 -- | This pretty much repeats the prop_all_volumes_positive property,
358 -- but will let me know which tetrahedrons's vertices are disoriented.
359 prop_tetrahedron15_volumes_positive :: Cube -> Bool
360 prop_tetrahedron15_volumes_positive cube =
361 volume (tetrahedron15 cube) > 0
362
363 -- | This pretty much repeats the prop_all_volumes_positive property,
364 -- but will let me know which tetrahedrons's vertices are disoriented.
365 prop_tetrahedron16_volumes_positive :: Cube -> Bool
366 prop_tetrahedron16_volumes_positive cube =
367 volume (tetrahedron16 cube) > 0
368
369 -- | This pretty much repeats the prop_all_volumes_positive property,
370 -- but will let me know which tetrahedrons's vertices are disoriented.
371 prop_tetrahedron17_volumes_positive :: Cube -> Bool
372 prop_tetrahedron17_volumes_positive cube =
373 volume (tetrahedron17 cube) > 0
374
375 -- | This pretty much repeats the prop_all_volumes_positive property,
376 -- but will let me know which tetrahedrons's vertices are disoriented.
377 prop_tetrahedron18_volumes_positive :: Cube -> Bool
378 prop_tetrahedron18_volumes_positive cube =
379 volume (tetrahedron18 cube) > 0
380
381 -- | This pretty much repeats the prop_all_volumes_positive property,
382 -- but will let me know which tetrahedrons's vertices are disoriented.
383 prop_tetrahedron19_volumes_positive :: Cube -> Bool
384 prop_tetrahedron19_volumes_positive cube =
385 volume (tetrahedron19 cube) > 0
386
387 -- | This pretty much repeats the prop_all_volumes_positive property,
388 -- but will let me know which tetrahedrons's vertices are disoriented.
389 prop_tetrahedron20_volumes_positive :: Cube -> Bool
390 prop_tetrahedron20_volumes_positive cube =
391 volume (tetrahedron20 cube) > 0
392
393 -- | This pretty much repeats the prop_all_volumes_positive property,
394 -- but will let me know which tetrahedrons's vertices are disoriented.
395 prop_tetrahedron21_volumes_positive :: Cube -> Bool
396 prop_tetrahedron21_volumes_positive cube =
397 volume (tetrahedron21 cube) > 0
398
399 -- | This pretty much repeats the prop_all_volumes_positive property,
400 -- but will let me know which tetrahedrons's vertices are disoriented.
401 prop_tetrahedron22_volumes_positive :: Cube -> Bool
402 prop_tetrahedron22_volumes_positive cube =
403 volume (tetrahedron22 cube) > 0
404
405 -- | This pretty much repeats the prop_all_volumes_positive property,
406 -- but will let me know which tetrahedrons's vertices are disoriented.
407 prop_tetrahedron23_volumes_positive :: Cube -> Bool
408 prop_tetrahedron23_volumes_positive cube =
409 volume (tetrahedron23 cube) > 0
410
411
412 -- | Given in Sorokina and Zeilfelder, p. 79. Note that the third and
413 -- fourth indices of c-t3 have been switched. This is because we
414 -- store the triangles oriented such that their volume is
415 -- positive. If T and T-tilde share \<v0,v1,v2\> and v3,v3-tilde point
416 -- in opposite directions, one of them has to have negative volume!
417 prop_c0120_identity1 :: Cube -> Bool
418 prop_c0120_identity1 cube =
419 c t0 0 1 2 0 ~= (c t0 0 0 2 1 + c t3 0 0 1 2) / 2
420 where
421 t0 = tetrahedron0 cube
422 t3 = tetrahedron3 cube
423
424
425 -- | Given in Sorokina and Zeilfelder, p. 79. Repeats
426 -- prop_c0120_identity2 with tetrahedrons 3 and 2.
427 prop_c0120_identity2 :: Cube -> Bool
428 prop_c0120_identity2 cube =
429 c t3 0 1 2 0 ~= (c t3 0 0 2 1 + c t2 0 0 1 2) / 2
430 where
431 t3 = tetrahedron3 cube
432 t2 = tetrahedron2 cube
433
434 -- | Given in Sorokina and Zeilfelder, p. 79. Repeats
435 -- prop_c0120_identity1 with tetrahedrons 2 and 1.
436 prop_c0120_identity3 :: Cube -> Bool
437 prop_c0120_identity3 cube =
438 c t2 0 1 2 0 ~= (c t2 0 0 2 1 + c t1 0 0 1 2) / 2
439 where
440 t2 = tetrahedron2 cube
441 t1 = tetrahedron1 cube
442
443
444 -- | Given in Sorokina and Zeilfelder, p. 79. Repeats
445 -- prop_c0120_identity1 with tetrahedrons 4 and 7.
446 prop_c0120_identity4 :: Cube -> Bool
447 prop_c0120_identity4 cube =
448 c t4 0 1 2 0 ~= (c t4 0 0 2 1 + c t7 0 0 1 2) / 2
449 where
450 t4 = tetrahedron4 cube
451 t7 = tetrahedron7 cube
452
453
454 -- | Given in Sorokina and Zeilfelder, p. 79. Repeats
455 -- prop_c0120_identity1 with tetrahedrons 7 and 6.
456 prop_c0120_identity5 :: Cube -> Bool
457 prop_c0120_identity5 cube =
458 c t7 0 1 2 0 ~= (c t7 0 0 2 1 + c t6 0 0 1 2) / 2
459 where
460 t7 = tetrahedron7 cube
461 t6 = tetrahedron6 cube
462
463
464 -- | Given in Sorokina and Zeilfelder, p. 79. Repeats
465 -- prop_c0120_identity1 with tetrahedrons 6 and 5.
466 prop_c0120_identity6 :: Cube -> Bool
467 prop_c0120_identity6 cube =
468 c t6 0 1 2 0 ~= (c t6 0 0 2 1 + c t5 0 0 1 2) / 2
469 where
470 t6 = tetrahedron6 cube
471 t5 = tetrahedron5 cube
472
473
474 -- | Given in Sorokina and Zeilfelder, p. 79. Note that the third and
475 -- fourth indices of c-t3 have been switched. This is because we
476 -- store the triangles oriented such that their volume is
477 -- positive. If T and T-tilde share \<v0,v1,v2\> and v3,v3-tilde point
478 -- in opposite directions, one of them has to have negative volume!
479 prop_c0210_identity1 :: Cube -> Bool
480 prop_c0210_identity1 cube =
481 c t0 0 2 1 0 ~= (c t0 0 1 1 1 + c t3 0 1 1 1) / 2
482 where
483 t0 = tetrahedron0 cube
484 t3 = tetrahedron3 cube
485
486
487 -- | Given in Sorokina and Zeilfelder, p. 79. Note that the third and
488 -- fourth indices of c-t3 have been switched. This is because we
489 -- store the triangles oriented such that their volume is
490 -- positive. If T and T-tilde share \<v0,v1,v2\> and v3,v3-tilde point
491 -- in opposite directions, one of them has to have negative volume!
492 prop_c0300_identity1 :: Cube -> Bool
493 prop_c0300_identity1 cube =
494 c t0 0 3 0 0 ~= (c t0 0 2 0 1 + c t3 0 2 1 0) / 2
495 where
496 t0 = tetrahedron0 cube
497 t3 = tetrahedron3 cube
498
499
500 -- | Given in Sorokina and Zeilfelder, p. 79. Note that the third and
501 -- fourth indices of c-t3 have been switched. This is because we
502 -- store the triangles oriented such that their volume is
503 -- positive. If T and T-tilde share \<v0,v1,v2\> and v3,v3-tilde point
504 -- in opposite directions, one of them has to have negative volume!
505 prop_c1110_identity :: Cube -> Bool
506 prop_c1110_identity cube =
507 c t0 1 1 1 0 ~= (c t0 1 0 1 1 + c t3 1 0 1 1) / 2
508 where
509 t0 = tetrahedron0 cube
510 t3 = tetrahedron3 cube
511
512
513 -- | Given in Sorokina and Zeilfelder, p. 79. Note that the third and
514 -- fourth indices of c-t3 have been switched. This is because we
515 -- store the triangles oriented such that their volume is
516 -- positive. If T and T-tilde share \<v0,v1,v2\> and v3,v3-tilde point
517 -- in opposite directions, one of them has to have negative volume!
518 prop_c1200_identity1 :: Cube -> Bool
519 prop_c1200_identity1 cube =
520 c t0 1 2 0 0 ~= (c t0 1 1 0 1 + c t3 1 1 1 0) / 2
521 where
522 t0 = tetrahedron0 cube
523 t3 = tetrahedron3 cube
524
525
526 -- | Given in Sorokina and Zeilfelder, p. 79. Note that the third and
527 -- fourth indices of c-t3 have been switched. This is because we
528 -- store the triangles oriented such that their volume is
529 -- positive. If T and T-tilde share \<v0,v1,v2\> and v3,v3-tilde point
530 -- in opposite directions, one of them has to have negative volume!
531 prop_c2100_identity1 :: Cube -> Bool
532 prop_c2100_identity1 cube =
533 c t0 2 1 0 0 ~= (c t0 2 0 0 1 + c t3 2 0 1 0) / 2
534 where
535 t0 = tetrahedron0 cube
536 t3 = tetrahedron3 cube
537
538
539
540 -- | Given in Sorokina and Zeilfelder, p. 79. Note that the third and
541 -- fourth indices of c-t1 have been switched. This is because we
542 -- store the triangles oriented such that their volume is
543 -- positive. If T and T-tilde share \<v0,v1,v3\> and v2,v2-tilde point
544 -- in opposite directions, one of them has to have negative volume!
545 prop_c0102_identity1 :: Cube -> Bool
546 prop_c0102_identity1 cube =
547 c t0 0 1 0 2 ~= (c t0 0 0 1 2 + c t1 0 0 2 1) / 2
548 where
549 t0 = tetrahedron0 cube
550 t1 = tetrahedron1 cube
551
552
553 -- | Given in Sorokina and Zeilfelder, p. 79. Note that the third and
554 -- fourth indices of c-t1 have been switched. This is because we
555 -- store the triangles oriented such that their volume is
556 -- positive. If T and T-tilde share \<v0,v1,v3\> and v2,v2-tilde point
557 -- in opposite directions, one of them has to have negative volume!
558 prop_c0201_identity1 :: Cube -> Bool
559 prop_c0201_identity1 cube =
560 c t0 0 2 0 1 ~= (c t0 0 1 1 1 + c t1 0 1 1 1) / 2
561 where
562 t0 = tetrahedron0 cube
563 t1 = tetrahedron1 cube
564
565
566 -- | Given in Sorokina and Zeilfelder, p. 79. Note that the third and
567 -- fourth indices of c-t1 have been switched. This is because we
568 -- store the triangles oriented such that their volume is
569 -- positive. If T and T-tilde share \<v0,v1,v3\> and v2,v2-tilde point
570 -- in opposite directions, one of them has to have negative volume!
571 prop_c0300_identity2 :: Cube -> Bool
572 prop_c0300_identity2 cube =
573 c t0 0 3 0 0 ~= (c t0 0 2 1 0 + c t1 0 2 0 1) / 2
574 where
575 t0 = tetrahedron0 cube
576 t1 = tetrahedron1 cube
577
578
579 -- | Given in Sorokina and Zeilfelder, p. 79. Note that the third and
580 -- fourth indices of c-t1 have been switched. This is because we
581 -- store the triangles oriented such that their volume is
582 -- positive. If T and T-tilde share \<v0,v1,v3\> and v2,v2-tilde point
583 -- in opposite directions, one of them has to have negative volume!
584 prop_c1101_identity :: Cube -> Bool
585 prop_c1101_identity cube =
586 c t0 1 1 0 1 ~= (c t0 1 0 1 1 + c t1 1 0 1 1) / 2
587 where
588 t0 = tetrahedron0 cube
589 t1 = tetrahedron1 cube
590
591
592 -- | Given in Sorokina and Zeilfelder, p. 79. Note that the third and
593 -- fourth indices of c-t1 have been switched. This is because we
594 -- store the triangles oriented such that their volume is
595 -- positive. If T and T-tilde share \<v0,v1,v3\> and v2,v2-tilde point
596 -- in opposite directions, one of them has to have negative volume!
597 prop_c1200_identity2 :: Cube -> Bool
598 prop_c1200_identity2 cube =
599 c t0 1 2 0 0 ~= (c t0 1 1 1 0 + c t1 1 1 0 1) / 2
600 where
601 t0 = tetrahedron0 cube
602 t1 = tetrahedron1 cube
603
604
605 -- | Given in Sorokina and Zeilfelder, p. 79. Note that the third and
606 -- fourth indices of c-t1 have been switched. This is because we
607 -- store the triangles oriented such that their volume is
608 -- positive. If T and T-tilde share \<v0,v1,v3\> and v2,v2-tilde point
609 -- in opposite directions, one of them has to have negative volume!
610 prop_c2100_identity2 :: Cube -> Bool
611 prop_c2100_identity2 cube =
612 c t0 2 1 0 0 ~= (c t0 2 0 1 0 + c t1 2 0 0 1) / 2
613 where
614 t0 = tetrahedron0 cube
615 t1 = tetrahedron1 cube
616
617
618 -- | Given in Sorokina and Zeilfelder, p. 79.
619 prop_c3000_identity :: Cube -> Bool
620 prop_c3000_identity cube =
621 c t0 3 0 0 0 ~= c t0 2 1 0 0 + c t6 2 1 0 0 - ((c t0 2 0 1 0 + c t0 2 0 0 1)/ 2)
622 where
623 t0 = tetrahedron0 cube
624 t6 = (tetrahedron6 cube) { v2 = (v3 t6), v3 = (v2 t6) }
625
626
627 -- | Given in Sorokina and Zeilfelder, p. 79.
628 prop_c2010_identity :: Cube -> Bool
629 prop_c2010_identity cube =
630 c t0 2 0 1 0 ~= c t0 1 1 1 0 + c t6 1 1 1 0 - ((c t0 1 0 2 0 + c t0 1 0 1 1)/ 2)
631 where
632 t0 = tetrahedron0 cube
633 t6 = tetrahedron6 cube
634
635
636 -- | Given in Sorokina and Zeilfelder, p. 79.
637 prop_c2001_identity :: Cube -> Bool
638 prop_c2001_identity cube =
639 c t0 2 0 0 1 ~= c t0 1 1 0 1 + c t6 1 1 0 1 - ((c t0 1 0 0 2 + c t0 1 0 1 1)/ 2)
640 where
641 t0 = tetrahedron0 cube
642 t6 = tetrahedron6 cube
643
644 -- | Given in Sorokina and Zeilfelder, p. 79.
645 prop_c1020_identity :: Cube -> Bool
646 prop_c1020_identity cube =
647 c t0 1 0 2 0 ~= c t0 0 1 2 0 + c t6 0 1 2 0 - ((c t0 0 0 3 0 + c t0 0 0 2 1)/ 2)
648 where
649 t0 = tetrahedron0 cube
650 t6 = tetrahedron6 cube
651
652
653 -- | Given in Sorokina and Zeilfelder, p. 79.
654 prop_c1002_identity :: Cube -> Bool
655 prop_c1002_identity cube =
656 c t0 1 0 0 2 ~= c t0 0 1 0 2 + c t6 0 1 0 2 - ((c t0 0 0 0 3 + c t0 0 0 1 2)/ 2)
657 where
658 t0 = tetrahedron0 cube
659 t6 = tetrahedron6 cube
660
661
662 -- | Given in Sorokina and Zeilfelder, p. 79.
663 prop_c1011_identity :: Cube -> Bool
664 prop_c1011_identity cube =
665 c t0 1 0 1 1 ~= c t0 0 1 1 1 + c t6 0 1 1 1 - ((c t0 0 0 1 2 + c t0 0 0 2 1)/ 2)
666 where
667 t0 = tetrahedron0 cube
668 t6 = tetrahedron6 cube
669
670
671
672 -- | Given in Sorokina and Zeilfelder, p. 78.
673 -- prop_cijk1_identity :: Cube -> Bool
674 -- prop_cijk1_identity cube =
675 -- and [ c t0 i j k 1 ~=
676 -- (c t1 (i+1) j k 0) * ((b0 t0) (v3 t1)) +
677 -- (c t1 i (j+1) k 0) * ((b1 t0) (v3 t1)) +
678 -- (c t1 i j (k+1) 0) * ((b2 t0) (v3 t1)) +
679 -- (c t1 i j k 1) * ((b3 t0) (v3 t1)) | i <- [0..2],
680 -- j <- [0..2],
681 -- k <- [0..2],
682 -- i + j + k == 2]
683 -- where
684 -- t0 = tetrahedron0 cube
685 -- t1 = tetrahedron1 cube
686
687
688
689 -- | The function values at the interior should be the same for all tetrahedra.
690 prop_interior_values_all_identical :: Cube -> Bool
691 prop_interior_values_all_identical cube =
692 all_equal [i0, i1, i2, i3, i4, i5, i6, i7, i8,
693 i9, i10, i11, i12, i13, i14, i15, i16,
694 i17, i18, i19, i20, i21, i22, i23]
695 where
696 i0 = eval (Tetrahedron.fv (tetrahedron0 cube)) $ I
697 i1 = eval (Tetrahedron.fv (tetrahedron1 cube)) $ I
698 i2 = eval (Tetrahedron.fv (tetrahedron2 cube)) $ I
699 i3 = eval (Tetrahedron.fv (tetrahedron3 cube)) $ I
700 i4 = eval (Tetrahedron.fv (tetrahedron4 cube)) $ I
701 i5 = eval (Tetrahedron.fv (tetrahedron5 cube)) $ I
702 i6 = eval (Tetrahedron.fv (tetrahedron6 cube)) $ I
703 i7 = eval (Tetrahedron.fv (tetrahedron7 cube)) $ I
704 i8 = eval (Tetrahedron.fv (tetrahedron8 cube)) $ I
705 i9 = eval (Tetrahedron.fv (tetrahedron9 cube)) $ I
706 i10 = eval (Tetrahedron.fv (tetrahedron10 cube)) $ I
707 i11 = eval (Tetrahedron.fv (tetrahedron11 cube)) $ I
708 i12 = eval (Tetrahedron.fv (tetrahedron12 cube)) $ I
709 i13 = eval (Tetrahedron.fv (tetrahedron13 cube)) $ I
710 i14 = eval (Tetrahedron.fv (tetrahedron14 cube)) $ I
711 i15 = eval (Tetrahedron.fv (tetrahedron15 cube)) $ I
712 i16 = eval (Tetrahedron.fv (tetrahedron16 cube)) $ I
713 i17 = eval (Tetrahedron.fv (tetrahedron17 cube)) $ I
714 i18 = eval (Tetrahedron.fv (tetrahedron18 cube)) $ I
715 i19 = eval (Tetrahedron.fv (tetrahedron19 cube)) $ I
716 i20 = eval (Tetrahedron.fv (tetrahedron20 cube)) $ I
717 i21 = eval (Tetrahedron.fv (tetrahedron21 cube)) $ I
718 i22 = eval (Tetrahedron.fv (tetrahedron22 cube)) $ I
719 i23 = eval (Tetrahedron.fv (tetrahedron23 cube)) $ I
720
721
722 -- | We know what (c t6 2 1 0 0) should be from Sorokina and Zeilfelder, p. 87.
723 -- This test checks the rotation works as expected.
724 prop_c_tilde_2100_rotation_correct :: Cube -> Bool
725 prop_c_tilde_2100_rotation_correct cube =
726 expr1 == expr2
727 where
728 t0 = tetrahedron0 cube
729 t6 = tetrahedron6 cube
730
731 -- What gets computed for c2100 of t6.
732 expr1 = eval (Tetrahedron.fv t6) $
733 (3/8)*I +
734 (1/12)*(T + R + L + D) +
735 (1/64)*(FT + FR + FL + FD) +
736 (7/48)*F +
737 (1/48)*B +
738 (1/96)*(RT + LD + LT + RD) +
739 (1/192)*(BT + BR + BL + BD)
740
741 -- What should be computed for c2100 of t6.
742 expr2 = eval (Tetrahedron.fv t0) $
743 (3/8)*I +
744 (1/12)*(F + R + L + B) +
745 (1/64)*(FT + RT + LT + BT) +
746 (7/48)*T +
747 (1/48)*D +
748 (1/96)*(FR + FL + BR + BL) +
749 (1/192)*(FD + RD + LD + BD)
750
751
752 -- | We know what (c t6 2 1 0 0) should be from Sorokina and Zeilfelder, p. 87.
753 -- This test checks the actual value based on the FunctionValues of the cube.
754 prop_c_tilde_2100_correct :: Cube -> Bool
755 prop_c_tilde_2100_correct cube =
756 c t6 2 1 0 0 == (3/8)*int + (1/12)*(f + r + l + b) + (1/64)*(ft + rt + lt + bt)
757 + (7/48)*t + (1/48)*d + (1/96)*(fr + fl + br + bl)
758 + (1/192)*(fd + rd + ld + bd)
759 where
760 t0 = tetrahedron0 cube
761 t6 = tetrahedron6 cube
762 fvs = Tetrahedron.fv t0
763 int = interior fvs
764 f = front fvs
765 r = right fvs
766 l = left fvs
767 b = back fvs
768 ft = front_top fvs
769 rt = right_top fvs
770 lt = left_top fvs
771 bt = back_top fvs
772 t = top fvs
773 d = down fvs
774 fr = front_right fvs
775 fl = front_left fvs
776 br = back_right fvs
777 bl = back_left fvs
778 fd = front_down fvs
779 rd = right_down fvs
780 ld = left_down fvs
781 bd = back_down fvs
782
783 -- Tests to check that the correct edges are incidental.
784 prop_t0_shares_edge_with_t1 :: Cube -> Bool
785 prop_t0_shares_edge_with_t1 cube =
786 (v1 t0) == (v1 t1) && (v3 t0) == (v2 t1)
787 where
788 t0 = tetrahedron0 cube
789 t1 = tetrahedron1 cube
790
791 prop_t0_shares_edge_with_t3 :: Cube -> Bool
792 prop_t0_shares_edge_with_t3 cube =
793 (v1 t0) == (v1 t3) && (v2 t0) == (v3 t3)
794 where
795 t0 = tetrahedron0 cube
796 t3 = tetrahedron3 cube
797
798 prop_t0_shares_edge_with_t6 :: Cube -> Bool
799 prop_t0_shares_edge_with_t6 cube =
800 (v2 t0) == (v3 t6) && (v3 t0) == (v2 t6)
801 where
802 t0 = tetrahedron0 cube
803 t6 = tetrahedron6 cube
804
805 prop_t1_shares_edge_with_t2 :: Cube -> Bool
806 prop_t1_shares_edge_with_t2 cube =
807 (v1 t1) == (v1 t2) && (v3 t1) == (v2 t2)
808 where
809 t1 = tetrahedron1 cube
810 t2 = tetrahedron2 cube
811
812 prop_t1_shares_edge_with_t19 :: Cube -> Bool
813 prop_t1_shares_edge_with_t19 cube =
814 (v2 t1) == (v3 t19) && (v3 t1) == (v2 t19)
815 where
816 t1 = tetrahedron1 cube
817 t19 = tetrahedron19 cube
818
819 prop_t2_shares_edge_with_t3 :: Cube -> Bool
820 prop_t2_shares_edge_with_t3 cube =
821 (v1 t1) == (v1 t2) && (v3 t1) == (v2 t2)
822 where
823 t1 = tetrahedron1 cube
824 t2 = tetrahedron2 cube
825
826 prop_t2_shares_edge_with_t12 :: Cube -> Bool
827 prop_t2_shares_edge_with_t12 cube =
828 (v2 t2) == (v3 t12) && (v3 t2) == (v2 t12)
829 where
830 t2 = tetrahedron2 cube
831 t12 = tetrahedron12 cube
832
833 prop_t3_shares_edge_with_t21 :: Cube -> Bool
834 prop_t3_shares_edge_with_t21 cube =
835 (v2 t3) == (v3 t21) && (v3 t3) == (v2 t21)
836 where
837 t3 = tetrahedron3 cube
838 t21 = tetrahedron21 cube
839
840 prop_t4_shares_edge_with_t5 :: Cube -> Bool
841 prop_t4_shares_edge_with_t5 cube =
842 (v1 t4) == (v1 t5) && (v3 t4) == (v2 t5)
843 where
844 t4 = tetrahedron4 cube
845 t5 = tetrahedron5 cube
846
847 prop_t4_shares_edge_with_t7 :: Cube -> Bool
848 prop_t4_shares_edge_with_t7 cube =
849 (v1 t4) == (v1 t7) && (v2 t4) == (v3 t7)
850 where
851 t4 = tetrahedron4 cube
852 t7 = tetrahedron7 cube
853
854 prop_t4_shares_edge_with_t10 :: Cube -> Bool
855 prop_t4_shares_edge_with_t10 cube =
856 (v2 t4) == (v3 t10) && (v3 t4) == (v2 t10)
857 where
858 t4 = tetrahedron4 cube
859 t10 = tetrahedron10 cube
860
861 prop_t5_shares_edge_with_t6 :: Cube -> Bool
862 prop_t5_shares_edge_with_t6 cube =
863 (v1 t5) == (v1 t6) && (v3 t5) == (v2 t6)
864 where
865 t5 = tetrahedron5 cube
866 t6 = tetrahedron6 cube
867
868 prop_t5_shares_edge_with_t16 :: Cube -> Bool
869 prop_t5_shares_edge_with_t16 cube =
870 (v2 t5) == (v3 t16) && (v3 t5) == (v2 t16)
871 where
872 t5 = tetrahedron5 cube
873 t16 = tetrahedron16 cube
874
875 prop_t6_shares_edge_with_t7 :: Cube -> Bool
876 prop_t6_shares_edge_with_t7 cube =
877 (v1 t6) == (v1 t7) && (v3 t6) == (v2 t7)
878 where
879 t6 = tetrahedron6 cube
880 t7 = tetrahedron7 cube
881
882 prop_t7_shares_edge_with_t20 :: Cube -> Bool
883 prop_t7_shares_edge_with_t20 cube =
884 (v2 t7) == (v3 t20) && (v2 t7) == (v3 t20)
885 where
886 t7 = tetrahedron7 cube
887 t20 = tetrahedron20 cube