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