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