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