]> gitweb.michael.orlitzky.com - spline3.git/blob - src/Tests/Face.hs
f9de1e7c6f6e8dde049693d08f5d264148d1662c
[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. 79.
35 prop_c0120_identity1 :: Cube -> Bool
36 prop_c0120_identity1 cube =
37 c t0' 0 1 2 0 ~= (c t0' 0 0 2 1 + c t1' 0 0 2 1) / 2
38 where
39 t0 = tetrahedron0 (face0 cube)
40 t1 = tetrahedron1 (face0 cube)
41 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
42 t1' = Tetrahedron cube (v3 t1) (v2 t1) (v0 t1) (v1 t1)
43
44
45 -- | Given in Sorokina and Zeilfelder, p. 79.
46 prop_c0210_identity1 :: Cube -> Bool
47 prop_c0210_identity1 cube =
48 c t0' 0 2 1 0 ~= (c t0' 0 1 1 1 + c t1' 0 1 1 1) / 2
49 where
50 t0 = tetrahedron0 (face0 cube)
51 t1 = tetrahedron1 (face0 cube)
52 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
53 t1' = Tetrahedron cube (v3 t1) (v2 t1) (v0 t1) (v1 t1)
54
55
56 -- | Given in Sorokina and Zeilfelder, p. 79.
57 prop_c0300_identity1 :: Cube -> Bool
58 prop_c0300_identity1 cube =
59 c t0' 0 3 0 0 ~= (c t0' 0 2 0 1 + c t1' 0 2 0 1) / 2
60 where
61 t0 = tetrahedron0 (face0 cube)
62 t1 = tetrahedron1 (face0 cube)
63 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
64 t1' = Tetrahedron cube (v3 t1) (v2 t1) (v0 t1) (v1 t1)
65
66 -- | Given in Sorokina and Zeilfelder, p. 79.
67 prop_c1110_identity :: Cube -> Bool
68 prop_c1110_identity cube =
69 c t0' 1 1 1 0 ~= (c t0' 1 0 1 1 + c t1' 1 0 1 1) / 2
70 where
71 t0 = tetrahedron0 (face0 cube)
72 t1 = tetrahedron1 (face0 cube)
73 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
74 t1' = Tetrahedron cube (v3 t1) (v2 t1) (v0 t1) (v1 t1)
75
76
77 -- | Given in Sorokina and Zeilfelder, p. 79.
78 prop_c1200_identity1 :: Cube -> Bool
79 prop_c1200_identity1 cube =
80 c t0' 1 2 0 0 ~= (c t0' 1 1 0 1 + c t1' 1 1 0 1) / 2
81 where
82 t0 = tetrahedron0 (face0 cube)
83 t1 = tetrahedron1 (face0 cube)
84 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
85 t1' = Tetrahedron cube (v3 t1) (v2 t1) (v0 t1) (v1 t1)
86
87
88 -- | Given in Sorokina and Zeilfelder, p. 79.
89 prop_c2100_identity1 :: Cube -> Bool
90 prop_c2100_identity1 cube =
91 c t0' 2 1 0 0 ~= (c t0' 2 0 0 1 + c t1' 2 0 0 1) / 2
92 where
93 t0 = tetrahedron0 (face0 cube)
94 t1 = tetrahedron1 (face0 cube)
95 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
96 t1' = Tetrahedron cube (v3 t1) (v2 t1) (v0 t1) (v1 t1)
97
98
99 -- | Given in Sorokina and Zeilfelder, p. 79.
100 prop_c0102_identity1 :: Cube -> Bool
101 prop_c0102_identity1 cube =
102 c t0' 0 1 0 2 ~= (c t0' 0 0 1 2 + c t3' 0 0 1 2) / 2
103 where
104 t0 = tetrahedron0 (face0 cube)
105 t3 = tetrahedron3 (face0 cube)
106 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
107 t3' = Tetrahedron cube (v3 t3) (v2 t3) (v1 t3) (v0 t3)
108
109
110 -- | Given in Sorokina and Zeilfelder, p. 79.
111 prop_c0201_identity1 :: Cube -> Bool
112 prop_c0201_identity1 cube =
113 c t0' 0 2 0 1 ~= (c t0' 0 1 1 1 + c t3' 0 1 1 1) / 2
114 where
115 t0 = tetrahedron0 (face0 cube)
116 t3 = tetrahedron3 (face0 cube)
117 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
118 t3' = Tetrahedron cube (v3 t3) (v2 t3) (v1 t3) (v0 t3)
119
120
121 -- | Given in Sorokina and Zeilfelder, p. 79.
122 prop_c0300_identity2 :: Cube -> Bool
123 prop_c0300_identity2 cube =
124 c t0' 3 0 0 0 ~= (c t0' 0 2 1 0 + c t3' 0 2 1 0) / 2
125 where
126 t0 = tetrahedron0 (face0 cube)
127 t3 = tetrahedron3 (face0 cube)
128 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
129 t3' = Tetrahedron cube (v3 t3) (v2 t3) (v1 t3) (v0 t3)
130
131 -- | Given in Sorokina and Zeilfelder, p. 79.
132 prop_c1101_identity :: Cube -> Bool
133 prop_c1101_identity cube =
134 c t0' 1 1 0 1 ~= (c t0' 1 1 0 1 + c t3' 1 1 0 1) / 2
135 where
136 t0 = tetrahedron0 (face0 cube)
137 t3 = tetrahedron3 (face0 cube)
138 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
139 t3' = Tetrahedron cube (v3 t3) (v2 t3) (v1 t3) (v0 t3)
140
141
142 -- | Given in Sorokina and Zeilfelder, p. 79.
143 prop_c1200_identity2 :: Cube -> Bool
144 prop_c1200_identity2 cube =
145 c t0' 1 1 1 0 ~= (c t0' 1 1 1 0 + c t3' 1 1 1 0) / 2
146 where
147 t0 = tetrahedron0 (face0 cube)
148 t3 = tetrahedron3 (face0 cube)
149 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
150 t3' = Tetrahedron cube (v3 t3) (v2 t3) (v1 t3) (v0 t3)
151
152
153 -- | Given in Sorokina and Zeilfelder, p. 79.
154 prop_c2100_identity2 :: Cube -> Bool
155 prop_c2100_identity2 cube =
156 c t0' 2 1 0 0 ~= (c t0' 2 0 1 0 + c t3' 2 0 1 0) / 2
157 where
158 t0 = tetrahedron0 (face0 cube)
159 t3 = tetrahedron3 (face0 cube)
160 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
161 t3' = Tetrahedron cube (v3 t3) (v2 t3) (v1 t3) (v0 t3)
162
163
164 -- | Given in Sorokina and Zeilfelder, p. 79.
165 prop_c3000_identity :: Cube -> Bool
166 prop_c3000_identity cube =
167 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)
168 where
169 t0 = tetrahedron0 (face0 cube)
170 t2 = tetrahedron2 (face5 cube)
171 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
172 t2' = Tetrahedron cube (v3 t2) (v2 t2) (v1 t2) (v0 t2)
173
174
175 -- | Given in Sorokina and Zeilfelder, p. 79.
176 prop_c2010_identity :: Cube -> Bool
177 prop_c2010_identity cube =
178 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)
179 where
180 t0 = tetrahedron0 (face0 cube)
181 t2 = tetrahedron2 (face5 cube)
182 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
183 t2' = Tetrahedron cube (v3 t2) (v2 t2) (v1 t2) (v0 t2)
184
185
186 -- | Given in Sorokina and Zeilfelder, p. 79.
187 prop_c2001_identity :: Cube -> Bool
188 prop_c2001_identity cube =
189 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)
190 where
191 t0 = tetrahedron0 (face0 cube)
192 t2 = tetrahedron2 (face5 cube)
193 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
194 t2' = Tetrahedron cube (v3 t2) (v2 t2) (v1 t2) (v0 t2)
195
196 -- | Given in Sorokina and Zeilfelder, p. 79.
197 prop_c1020_identity :: Cube -> Bool
198 prop_c1020_identity cube =
199 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)
200 where
201 t0 = tetrahedron0 (face0 cube)
202 t2 = tetrahedron2 (face5 cube)
203 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
204 t2' = Tetrahedron cube (v3 t2) (v2 t2) (v1 t2) (v0 t2)
205
206
207 -- | Given in Sorokina and Zeilfelder, p. 79.
208 prop_c1002_identity :: Cube -> Bool
209 prop_c1002_identity cube =
210 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)
211 where
212 t0 = tetrahedron0 (face0 cube)
213 t2 = tetrahedron2 (face5 cube)
214 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
215 t2' = Tetrahedron cube (v3 t2) (v2 t2) (v1 t2) (v0 t2)
216
217
218 -- | Given in Sorokina and Zeilfelder, p. 79.
219 prop_c1011_identity :: Cube -> Bool
220 prop_c1011_identity cube =
221 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)
222 where
223 t0 = tetrahedron0 (face0 cube)
224 t2 = tetrahedron2 (face5 cube)
225 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
226 t2' = Tetrahedron cube (v3 t2) (v2 t2) (v1 t2) (v0 t2)
227
228
229 -- | Given in Sorokina and Zeilfelder, p. 80.
230 prop_c0120_identity2 :: Cube -> Bool
231 prop_c0120_identity2 cube =
232 c t0' 0 1 2 0 ~= (c t0' 1 0 2 0 + c t1' 1 0 2 0) / 2
233 where
234 t0 = tetrahedron0 (face0 cube)
235 t1 = tetrahedron0 (face2 (top cube))
236 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
237 t1' = Tetrahedron cube (v3 t1) (v2 t1) (v0 t1) (v1 t1)
238
239
240 -- | Given in Sorokina and Zeilfelder, p. 80.
241 prop_c0102_identity2 :: Cube -> Bool
242 prop_c0102_identity2 cube =
243 c t0' 0 1 0 2 ~= (c t0' 1 0 0 2 + c t1' 1 0 0 2) / 2
244 where
245 t0 = tetrahedron0 (face0 cube)
246 t1 = tetrahedron0 (face2 (top cube))
247 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
248 t1' = Tetrahedron cube (v3 t1) (v2 t1) (v0 t1) (v1 t1)
249
250
251 -- | Given in Sorokina and Zeilfelder, p. 80.
252 prop_c0111_identity :: Cube -> Bool
253 prop_c0111_identity cube =
254 c t0' 0 1 1 1 ~= (c t0' 1 0 1 1 + c t1' 1 0 1 1) / 2
255 where
256 t0 = tetrahedron0 (face0 cube)
257 t1 = tetrahedron0 (face2 (top cube))
258 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
259 t1' = Tetrahedron cube (v3 t1) (v2 t1) (v0 t1) (v1 t1)
260
261
262 -- | Given in Sorokina and Zeilfelder, p. 80.
263 prop_c0210_identity2 :: Cube -> Bool
264 prop_c0210_identity2 cube =
265 c t0 0 2 1 0 ~= (c t0 1 1 1 0 + c t1 1 1 1 0) / 2
266 where
267 t0 = tetrahedron0 (face0 cube)
268 t1 = tetrahedron0 (face2 (top cube))
269 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
270 t1' = Tetrahedron cube (v3 t1) (v2 t1) (v0 t1) (v1 t1)
271
272
273 -- | Given in Sorokina and Zeilfelder, p. 80.
274 prop_c0201_identity2 :: Cube -> Bool
275 prop_c0201_identity2 cube =
276 c t0 0 2 0 1 ~= (c t0 1 1 0 1 + c t1 1 1 0 1) / 2
277 where
278 t0 = tetrahedron0 (face0 cube)
279 t1 = tetrahedron0 (face2 (top cube))
280 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
281 t1' = Tetrahedron cube (v3 t1) (v2 t1) (v0 t1) (v1 t1)
282
283
284 -- | Given in Sorokina and Zeilfelder, p. 80.
285 prop_c0300_identity3 :: Cube -> Bool
286 prop_c0300_identity3 cube =
287 c t0 0 3 0 0 ~= (c t0 1 2 0 0 + c t1 1 2 0 0) / 2
288 where
289 t0 = tetrahedron0 (face0 cube)
290 t1 = tetrahedron0 (face2 (top cube))
291 t0' = Tetrahedron cube (v3 t0) (v2 t0) (v1 t0) (v0 t0)
292 t1' = Tetrahedron cube (v3 t1) (v2 t1) (v0 t1) (v1 t1)