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