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