]> gitweb.michael.orlitzky.com - spline3.git/blob - src/Tests/Face.hs
Add a test for p. 78, (2.5).
[spline3.git] / src / Tests / Face.hs
1 module Tests.Face
2 where
3
4 import Test.QuickCheck
5
6 import Comparisons
7 import Cube (Cube(grid), top)
8 import Face (face0,
9 face2,
10 face5,
11 tetrahedron0,
12 tetrahedron1,
13 tetrahedron2,
14 tetrahedron3,
15 tetrahedrons)
16 import Grid (Grid(h))
17 import Tetrahedron
18
19 -- QuickCheck Tests.
20
21 -- | Since the grid size is necessarily positive, all tetrahedrons
22 -- (which comprise cubes of positive volume) must have positive volume
23 -- as well.
24 prop_all_volumes_positive :: Cube -> Property
25 prop_all_volumes_positive c =
26 (delta > 0) ==> (null nonpositive_volumes)
27 where
28 delta = h (grid c)
29 ts = tetrahedrons c
30 volumes = map volume ts
31 nonpositive_volumes = filter (<= 0) volumes
32
33
34 -- | Given in Sorokina and Zeilfelder, p. 78.
35 prop_cijk1_identity :: Cube -> Bool
36 prop_cijk1_identity cube =
37 and [ c t0' i j k 1 ~= (c t1' (i+1) j k 0) * ((b0 t0') (v3 t1')) +
38 (c t1' i (j+1) k 0) * ((b1 t0') (v3 t1')) +
39 (c t1' i j (k+1) 0) * ((b2 t0') (v3 t1')) +
40 (c t1' i j k 1) * ((b3 t0') (v3 t1')) | i <- [0..2],
41 j <- [0..2],
42 k <- [0..2],
43 i + j + k == 2]
44 where
45 t0 = tetrahedron0 (face0 cube)
46 t1 = tetrahedron1 (face0 cube)
47 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
48 t1' = Tetrahedron cube (v3 t1) (v2 t1) (v0 t1) (v1 t1)
49
50 -- | Given in Sorokina and Zeilfelder, p. 79.
51 prop_c0120_identity1 :: Cube -> Bool
52 prop_c0120_identity1 cube =
53 c t0' 0 1 2 0 ~= (c t0' 0 0 2 1 + c t1' 0 0 2 1) / 2
54 where
55 t0 = tetrahedron0 (face0 cube)
56 t1 = tetrahedron1 (face0 cube)
57 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
58 t1' = Tetrahedron cube (v3 t1) (v2 t1) (v0 t1) (v1 t1)
59
60
61 -- | Given in Sorokina and Zeilfelder, p. 79.
62 prop_c0210_identity1 :: Cube -> Bool
63 prop_c0210_identity1 cube =
64 c t0' 0 2 1 0 ~= (c t0' 0 1 1 1 + c t1' 0 1 1 1) / 2
65 where
66 t0 = tetrahedron0 (face0 cube)
67 t1 = tetrahedron1 (face0 cube)
68 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
69 t1' = Tetrahedron cube (v3 t1) (v2 t1) (v0 t1) (v1 t1)
70
71
72 -- | Given in Sorokina and Zeilfelder, p. 79.
73 prop_c0300_identity1 :: Cube -> Bool
74 prop_c0300_identity1 cube =
75 c t0' 0 3 0 0 ~= (c t0' 0 2 0 1 + c t1' 0 2 0 1) / 2
76 where
77 t0 = tetrahedron0 (face0 cube)
78 t1 = tetrahedron1 (face0 cube)
79 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
80 t1' = Tetrahedron cube (v3 t1) (v2 t1) (v0 t1) (v1 t1)
81
82 -- | Given in Sorokina and Zeilfelder, p. 79.
83 prop_c1110_identity :: Cube -> Bool
84 prop_c1110_identity cube =
85 c t0' 1 1 1 0 ~= (c t0' 1 0 1 1 + c t1' 1 0 1 1) / 2
86 where
87 t0 = tetrahedron0 (face0 cube)
88 t1 = tetrahedron1 (face0 cube)
89 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
90 t1' = Tetrahedron cube (v3 t1) (v2 t1) (v0 t1) (v1 t1)
91
92
93 -- | Given in Sorokina and Zeilfelder, p. 79.
94 prop_c1200_identity1 :: Cube -> Bool
95 prop_c1200_identity1 cube =
96 c t0' 1 2 0 0 ~= (c t0' 1 1 0 1 + c t1' 1 1 0 1) / 2
97 where
98 t0 = tetrahedron0 (face0 cube)
99 t1 = tetrahedron1 (face0 cube)
100 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
101 t1' = Tetrahedron cube (v3 t1) (v2 t1) (v0 t1) (v1 t1)
102
103
104 -- | Given in Sorokina and Zeilfelder, p. 79.
105 prop_c2100_identity1 :: Cube -> Bool
106 prop_c2100_identity1 cube =
107 c t0' 2 1 0 0 ~= (c t0' 2 0 0 1 + c t1' 2 0 0 1) / 2
108 where
109 t0 = tetrahedron0 (face0 cube)
110 t1 = tetrahedron1 (face0 cube)
111 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
112 t1' = Tetrahedron cube (v3 t1) (v2 t1) (v0 t1) (v1 t1)
113
114
115 -- | Given in Sorokina and Zeilfelder, p. 79.
116 prop_c0102_identity1 :: Cube -> Bool
117 prop_c0102_identity1 cube =
118 c t0' 0 1 0 2 ~= (c t0' 0 0 1 2 + c t3' 0 0 1 2) / 2
119 where
120 t0 = tetrahedron0 (face0 cube)
121 t3 = tetrahedron3 (face0 cube)
122 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
123 t3' = Tetrahedron cube (v3 t3) (v2 t3) (v1 t3) (v0 t3)
124
125
126 -- | Given in Sorokina and Zeilfelder, p. 79.
127 prop_c0201_identity1 :: Cube -> Bool
128 prop_c0201_identity1 cube =
129 c t0' 0 2 0 1 ~= (c t0' 0 1 1 1 + c t3' 0 1 1 1) / 2
130 where
131 t0 = tetrahedron0 (face0 cube)
132 t3 = tetrahedron3 (face0 cube)
133 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
134 t3' = Tetrahedron cube (v3 t3) (v2 t3) (v1 t3) (v0 t3)
135
136
137 -- | Given in Sorokina and Zeilfelder, p. 79.
138 prop_c0300_identity2 :: Cube -> Bool
139 prop_c0300_identity2 cube =
140 c t0' 3 0 0 0 ~= (c t0' 0 2 1 0 + c t3' 0 2 1 0) / 2
141 where
142 t0 = tetrahedron0 (face0 cube)
143 t3 = tetrahedron3 (face0 cube)
144 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
145 t3' = Tetrahedron cube (v3 t3) (v2 t3) (v1 t3) (v0 t3)
146
147 -- | Given in Sorokina and Zeilfelder, p. 79.
148 prop_c1101_identity :: Cube -> Bool
149 prop_c1101_identity cube =
150 c t0' 1 1 0 1 ~= (c t0' 1 1 0 1 + c t3' 1 1 0 1) / 2
151 where
152 t0 = tetrahedron0 (face0 cube)
153 t3 = tetrahedron3 (face0 cube)
154 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
155 t3' = Tetrahedron cube (v3 t3) (v2 t3) (v1 t3) (v0 t3)
156
157
158 -- | Given in Sorokina and Zeilfelder, p. 79.
159 prop_c1200_identity2 :: Cube -> Bool
160 prop_c1200_identity2 cube =
161 c t0' 1 1 1 0 ~= (c t0' 1 1 1 0 + c t3' 1 1 1 0) / 2
162 where
163 t0 = tetrahedron0 (face0 cube)
164 t3 = tetrahedron3 (face0 cube)
165 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
166 t3' = Tetrahedron cube (v3 t3) (v2 t3) (v1 t3) (v0 t3)
167
168
169 -- | Given in Sorokina and Zeilfelder, p. 79.
170 prop_c2100_identity2 :: Cube -> Bool
171 prop_c2100_identity2 cube =
172 c t0' 2 1 0 0 ~= (c t0' 2 0 1 0 + c t3' 2 0 1 0) / 2
173 where
174 t0 = tetrahedron0 (face0 cube)
175 t3 = tetrahedron3 (face0 cube)
176 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
177 t3' = Tetrahedron cube (v3 t3) (v2 t3) (v1 t3) (v0 t3)
178
179
180 -- | Given in Sorokina and Zeilfelder, p. 79.
181 prop_c3000_identity :: Cube -> Bool
182 prop_c3000_identity cube =
183 c t0' 3 0 0 0 ~= c t0' 2 1 0 0 + c t2' 2 1 0 0 - ((c t0' 2 0 1 0 + c t0' 2 0 0 1)/ 2)
184 where
185 t0 = tetrahedron0 (face0 cube)
186 t2 = tetrahedron2 (face5 cube)
187 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
188 t2' = Tetrahedron cube (v3 t2) (v2 t2) (v1 t2) (v0 t2)
189
190
191 -- | Given in Sorokina and Zeilfelder, p. 79.
192 prop_c2010_identity :: Cube -> Bool
193 prop_c2010_identity cube =
194 c t0' 2 0 1 0 ~= c t0' 1 1 1 0 + c t2' 1 1 1 0 - ((c t0' 1 0 2 0 + c t0' 1 0 1 1)/ 2)
195 where
196 t0 = tetrahedron0 (face0 cube)
197 t2 = tetrahedron2 (face5 cube)
198 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
199 t2' = Tetrahedron cube (v3 t2) (v2 t2) (v1 t2) (v0 t2)
200
201
202 -- | Given in Sorokina and Zeilfelder, p. 79.
203 prop_c2001_identity :: Cube -> Bool
204 prop_c2001_identity cube =
205 c t0' 2 0 0 1 ~= c t0' 1 1 0 1 + c t2' 1 1 0 1 - ((c t0' 1 0 0 2 + c t0' 1 0 1 1)/ 2)
206 where
207 t0 = tetrahedron0 (face0 cube)
208 t2 = tetrahedron2 (face5 cube)
209 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
210 t2' = Tetrahedron cube (v3 t2) (v2 t2) (v1 t2) (v0 t2)
211
212 -- | Given in Sorokina and Zeilfelder, p. 79.
213 prop_c1020_identity :: Cube -> Bool
214 prop_c1020_identity cube =
215 c t0' 1 0 2 0 ~= c t0' 0 1 2 0 + c t2' 0 1 2 0 - ((c t0' 0 0 3 0 + c t0' 0 0 2 1)/ 2)
216 where
217 t0 = tetrahedron0 (face0 cube)
218 t2 = tetrahedron2 (face5 cube)
219 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
220 t2' = Tetrahedron cube (v3 t2) (v2 t2) (v1 t2) (v0 t2)
221
222
223 -- | Given in Sorokina and Zeilfelder, p. 79.
224 prop_c1002_identity :: Cube -> Bool
225 prop_c1002_identity cube =
226 c t0' 1 0 0 2 ~= c t0' 0 1 0 2 + c t2' 0 1 0 2 - ((c t0' 0 0 0 3 + c t0' 0 0 1 2)/ 2)
227 where
228 t0 = tetrahedron0 (face0 cube)
229 t2 = tetrahedron2 (face5 cube)
230 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
231 t2' = Tetrahedron cube (v3 t2) (v2 t2) (v1 t2) (v0 t2)
232
233
234 -- | Given in Sorokina and Zeilfelder, p. 79.
235 prop_c1011_identity :: Cube -> Bool
236 prop_c1011_identity cube =
237 c t0' 1 0 1 1 ~= c t0' 0 1 1 1 + c t2' 0 1 1 1 - ((c t0' 0 0 1 2 + c t0' 0 0 2 1)/ 2)
238 where
239 t0 = tetrahedron0 (face0 cube)
240 t2 = tetrahedron2 (face5 cube)
241 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
242 t2' = Tetrahedron cube (v3 t2) (v2 t2) (v1 t2) (v0 t2)
243
244
245 -- | Given in Sorokina and Zeilfelder, p. 80.
246 prop_c0120_identity2 :: Cube -> Bool
247 prop_c0120_identity2 cube =
248 c t0' 0 1 2 0 ~= (c t0' 1 0 2 0 + c t1' 1 0 2 0) / 2
249 where
250 t0 = tetrahedron0 (face0 cube)
251 t1 = tetrahedron0 (face2 (top cube))
252 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
253 t1' = Tetrahedron cube (v3 t1) (v2 t1) (v0 t1) (v1 t1)
254
255
256 -- | Given in Sorokina and Zeilfelder, p. 80.
257 prop_c0102_identity2 :: Cube -> Bool
258 prop_c0102_identity2 cube =
259 c t0' 0 1 0 2 ~= (c t0' 1 0 0 2 + c t1' 1 0 0 2) / 2
260 where
261 t0 = tetrahedron0 (face0 cube)
262 t1 = tetrahedron0 (face2 (top cube))
263 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
264 t1' = Tetrahedron cube (v3 t1) (v2 t1) (v0 t1) (v1 t1)
265
266
267 -- | Given in Sorokina and Zeilfelder, p. 80.
268 prop_c0111_identity :: Cube -> Bool
269 prop_c0111_identity cube =
270 c t0' 0 1 1 1 ~= (c t0' 1 0 1 1 + c t1' 1 0 1 1) / 2
271 where
272 t0 = tetrahedron0 (face0 cube)
273 t1 = tetrahedron0 (face2 (top cube))
274 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
275 t1' = Tetrahedron cube (v3 t1) (v2 t1) (v0 t1) (v1 t1)
276
277
278 -- | Given in Sorokina and Zeilfelder, p. 80.
279 prop_c0210_identity2 :: Cube -> Bool
280 prop_c0210_identity2 cube =
281 c t0 0 2 1 0 ~= (c t0 1 1 1 0 + c t1 1 1 1 0) / 2
282 where
283 t0 = tetrahedron0 (face0 cube)
284 t1 = tetrahedron0 (face2 (top cube))
285 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
286 t1' = Tetrahedron cube (v3 t1) (v2 t1) (v0 t1) (v1 t1)
287
288
289 -- | Given in Sorokina and Zeilfelder, p. 80.
290 prop_c0201_identity2 :: Cube -> Bool
291 prop_c0201_identity2 cube =
292 c t0 0 2 0 1 ~= (c t0 1 1 0 1 + c t1 1 1 0 1) / 2
293 where
294 t0 = tetrahedron0 (face0 cube)
295 t1 = tetrahedron0 (face2 (top cube))
296 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
297 t1' = Tetrahedron cube (v3 t1) (v2 t1) (v0 t1) (v1 t1)
298
299
300 -- | Given in Sorokina and Zeilfelder, p. 80.
301 prop_c0300_identity3 :: Cube -> Bool
302 prop_c0300_identity3 cube =
303 c t0 0 3 0 0 ~= (c t0 1 2 0 0 + c t1 1 2 0 0) / 2
304 where
305 t0 = tetrahedron0 (face0 cube)
306 t1 = tetrahedron0 (face2 (top cube))
307 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
308 t1' = Tetrahedron cube (v3 t1) (v2 t1) (v0 t1) (v1 t1)