4 import Data.Maybe (fromJust)
9 import Cube hiding (i, j, k)
11 import FunctionValues (value_at)
16 -- | Check the value of c0030 for tetrahedron0 belonging to the
17 -- cube centered on (1,1,1) with a grid constructed from the
18 -- trilinear values. See example one in the paper.
19 test_trilinear_c0030 :: Assertion
20 test_trilinear_c0030 =
21 assertAlmostEqual "c0030 is correct" (c t 0 0 3 0) (17/8)
23 g = make_grid 1 trilinear
24 cube = fromJust $ cube_at g 1 1 1
28 -- | Check the value of c0003 for tetrahedron0 belonging to the
29 -- cube centered on (1,1,1) with a grid constructed from the
30 -- trilinear values. See example one in the paper.
31 test_trilinear_c0003 :: Assertion
32 test_trilinear_c0003 =
33 assertAlmostEqual "c0003 is correct" (c t 0 0 0 3) (27/8)
35 g = make_grid 1 trilinear
36 cube = fromJust $ cube_at g 1 1 1
40 -- | Check the value of c0021 for tetrahedron0 belonging to the
41 -- cube centered on (1,1,1) with a grid constructed from the
42 -- trilinear values. See example one in the paper.
43 test_trilinear_c0021 :: Assertion
44 test_trilinear_c0021 =
45 assertAlmostEqual "c0021 is correct" (c t 0 0 2 1) (61/24)
47 g = make_grid 1 trilinear
48 cube = fromJust $ cube_at g 1 1 1
52 -- | Check the value of c0012 for tetrahedron0 belonging to the
53 -- cube centered on (1,1,1) with a grid constructed from the
54 -- trilinear values. See example one in the paper.
55 test_trilinear_c0012 :: Assertion
56 test_trilinear_c0012 =
57 assertAlmostEqual "c0012 is correct" (c t 0 0 1 2) (71/24)
59 g = make_grid 1 trilinear
60 cube = fromJust $ cube_at g 1 1 1
64 -- | Check the value of c0120 for tetrahedron0 belonging to the
65 -- cube centered on (1,1,1) with a grid constructed from the
66 -- trilinear values. See example one in the paper.
67 test_trilinear_c0120 :: Assertion
68 test_trilinear_c0120 =
69 assertAlmostEqual "c0120 is correct" (c t 0 1 2 0) (55/24)
71 g = make_grid 1 trilinear
72 cube = fromJust $ cube_at g 1 1 1
76 -- | Check the value of c0102 for tetrahedron0 belonging to the
77 -- cube centered on (1,1,1) with a grid constructed from the
78 -- trilinear values. See example one in the paper.
79 test_trilinear_c0102 :: Assertion
80 test_trilinear_c0102 =
81 assertAlmostEqual "c0102 is correct" (c t 0 1 0 2) (73/24)
83 g = make_grid 1 trilinear
84 cube = fromJust $ cube_at g 1 1 1
88 -- | Check the value of c0111 for tetrahedron0 belonging to the
89 -- cube centered on (1,1,1) with a grid constructed from the
90 -- trilinear values. See example one in the paper.
91 test_trilinear_c0111 :: Assertion
92 test_trilinear_c0111 =
93 assertAlmostEqual "c0111 is correct" (c t 0 1 1 1) (8/3)
95 g = make_grid 1 trilinear
96 cube = fromJust $ cube_at g 1 1 1
100 -- | Check the value of c0210 for tetrahedron0 belonging to the
101 -- cube centered on (1,1,1) with a grid constructed from the
102 -- trilinear values. See example one in the paper.
103 test_trilinear_c0210 :: Assertion
104 test_trilinear_c0210 =
105 assertAlmostEqual "c0210 is correct" (c t 0 2 1 0) (29/12)
107 g = make_grid 1 trilinear
108 cube = fromJust $ cube_at g 1 1 1
109 t = tetrahedron0 cube
112 -- | Check the value of c0201 for tetrahedron0 belonging to the
113 -- cube centered on (1,1,1) with a grid constructed from the
114 -- trilinear values. See example one in the paper.
115 test_trilinear_c0201 :: Assertion
116 test_trilinear_c0201 =
117 assertAlmostEqual "c0201 is correct" (c t 0 2 0 1) (11/4)
119 g = make_grid 1 trilinear
120 cube = fromJust $ cube_at g 1 1 1
121 t = tetrahedron0 cube
124 -- | Check the value of c0300 for tetrahedron0 belonging to the
125 -- cube centered on (1,1,1) with a grid constructed from the
126 -- trilinear values. See example one in the paper.
127 test_trilinear_c0300 :: Assertion
128 test_trilinear_c0300 =
129 assertAlmostEqual "c0300 is correct" (c t 0 3 0 0) (5/2)
131 g = make_grid 1 trilinear
132 cube = fromJust $ cube_at g 1 1 1
133 t = tetrahedron0 cube
136 -- | Check the value of c1020 for tetrahedron0 belonging to the
137 -- cube centered on (1,1,1) with a grid constructed from the
138 -- trilinear values. See example one in the paper.
139 test_trilinear_c1020 :: Assertion
140 test_trilinear_c1020 =
141 assertAlmostEqual "c1020 is correct" (c t 1 0 2 0) (8/3)
143 g = make_grid 1 trilinear
144 cube = fromJust $ cube_at g 1 1 1
145 t = tetrahedron0 cube
148 -- | Check the value of c1002 for tetrahedron0 belonging to the
149 -- cube centered on (1,1,1) with a grid constructed from the
150 -- trilinear values. See example one in the paper.
151 test_trilinear_c1002 :: Assertion
152 test_trilinear_c1002 =
153 assertAlmostEqual "c1002 is correct" (c t 1 0 0 2) (23/6)
155 g = make_grid 1 trilinear
156 cube = fromJust $ cube_at g 1 1 1
157 t = tetrahedron0 cube
160 -- | Check the value of c1011 for tetrahedron0 belonging to the
161 -- cube centered on (1,1,1) with a grid constructed from the
162 -- trilinear values. See example one in the paper.
163 test_trilinear_c1011 :: Assertion
164 test_trilinear_c1011 =
165 assertAlmostEqual "c1011 is correct" (c t 1 0 1 1) (13/4)
167 g = make_grid 1 trilinear
168 cube = fromJust $ cube_at g 1 1 1
169 t = tetrahedron0 cube
172 -- | Check the value of c1110 for tetrahedron0 belonging to the
173 -- cube centered on (1,1,1) with a grid constructed from the
174 -- trilinear values. See example one in the paper.
175 test_trilinear_c1110 :: Assertion
176 test_trilinear_c1110 =
177 assertAlmostEqual "c1110 is correct" (c t 1 1 1 0) (23/8)
179 g = make_grid 1 trilinear
180 cube = fromJust $ cube_at g 1 1 1
181 t = tetrahedron0 cube
184 -- | Check the value of c1101 for tetrahedron0 belonging to the
185 -- cube centered on (1,1,1) with a grid constructed from the
186 -- trilinear values. See example one in the paper.
187 test_trilinear_c1101 :: Assertion
188 test_trilinear_c1101 =
189 assertAlmostEqual "c1101 is correct" (c t 1 1 0 1) (27/8)
191 g = make_grid 1 trilinear
192 cube = fromJust $ cube_at g 1 1 1
193 t = tetrahedron0 cube
196 -- | Check the value of c1200 for tetrahedron0 belonging to the
197 -- cube centered on (1,1,1) with a grid constructed from the
198 -- trilinear values. See example one in the paper.
199 test_trilinear_c1200 :: Assertion
200 test_trilinear_c1200 =
201 assertAlmostEqual "c1200 is correct" (c t 1 2 0 0) 3
203 g = make_grid 1 trilinear
204 cube = fromJust $ cube_at g 1 1 1
205 t = tetrahedron0 cube
208 -- | Check the value of c2010 for tetrahedron0 belonging to the
209 -- cube centered on (1,1,1) with a grid constructed from the
210 -- trilinear values. See example one in the paper.
211 test_trilinear_c2010 :: Assertion
212 test_trilinear_c2010 =
213 assertAlmostEqual "c2010 is correct" (c t 2 0 1 0) (10/3)
215 g = make_grid 1 trilinear
216 cube = fromJust $ cube_at g 1 1 1
217 t = tetrahedron0 cube
220 -- | Check the value of c2001 for tetrahedron0 belonging to the
221 -- cube centered on (1,1,1) with a grid constructed from the
222 -- trilinear values. See example one in the paper.
223 test_trilinear_c2001 :: Assertion
224 test_trilinear_c2001 =
225 assertAlmostEqual "c2001 is correct" (c t 2 0 0 1) 4
227 g = make_grid 1 trilinear
228 cube = fromJust $ cube_at g 1 1 1
229 t = tetrahedron0 cube
232 -- | Check the value of c2100 for tetrahedron0 belonging to the
233 -- cube centered on (1,1,1) with a grid constructed from the
234 -- trilinear values. See example one in the paper.
235 test_trilinear_c2100 :: Assertion
236 test_trilinear_c2100 =
237 assertAlmostEqual "c2100 is correct" (c t 2 1 0 0) (7/2)
239 g = make_grid 1 trilinear
240 cube = fromJust $ cube_at g 1 1 1
241 t = tetrahedron0 cube
244 -- | Check the value of c3000 for tetrahedron0 belonging to the
245 -- cube centered on (1,1,1) with a grid constructed from the
246 -- trilinear values. See example one in the paper.
247 test_trilinear_c3000 :: Assertion
248 test_trilinear_c3000 =
249 assertAlmostEqual "c3000 is correct" (c t 3 0 0 0) 4
251 g = make_grid 1 trilinear
252 cube = fromJust $ cube_at g 1 1 1
253 t = tetrahedron0 cube
256 -- | Make sure that v0 of tetrahedron0 belonging to the cube centered
257 -- on (1,1,1) with a grid constructed from the trilinear values
258 -- winds up in the right place. See example one in the paper.
259 test_trilinear_f0_t0_v0 :: Assertion
260 test_trilinear_f0_t0_v0 =
261 assertEqual "v0 is correct" (v0 t) (1, 1, 1)
263 g = make_grid 1 trilinear
264 cube = fromJust $ cube_at g 1 1 1
265 t = tetrahedron0 cube
268 -- | Make sure that v1 of tetrahedron0 belonging to the cube centered
269 -- on (1,1,1) with a grid constructed from the trilinear values
270 -- winds up in the right place. See example one in the paper.
271 test_trilinear_f0_t0_v1 :: Assertion
272 test_trilinear_f0_t0_v1 =
273 assertEqual "v1 is correct" (v1 t) (0.5, 1, 1)
275 g = make_grid 1 trilinear
276 cube = fromJust $ cube_at g 1 1 1
277 t = tetrahedron0 cube
280 -- | Make sure that v2 of tetrahedron0 belonging to the cube centered
281 -- on (1,1,1) with a grid constructed from the trilinear values
282 -- winds up in the right place. See example one in the paper.
283 test_trilinear_f0_t0_v2 :: Assertion
284 test_trilinear_f0_t0_v2 =
285 assertEqual "v2 is correct" (v2 t) (0.5, 0.5, 1.5)
287 g = make_grid 1 trilinear
288 cube = fromJust $ cube_at g 1 1 1
289 t = tetrahedron0 cube
292 -- | Make sure that v3 of tetrahedron0 belonging to the cube centered
293 -- on (1,1,1) with a grid constructed from the trilinear values
294 -- winds up in the right place. See example one in the paper.
295 test_trilinear_f0_t0_v3 :: Assertion
296 test_trilinear_f0_t0_v3 =
297 assertClose "v3 is correct" (v3 t) (0.5, 1.5, 1.5)
299 g = make_grid 1 trilinear
300 cube = fromJust $ cube_at g 1 1 1
301 t = tetrahedron0 cube
304 test_trilinear_reproduced :: Assertion
305 test_trilinear_reproduced =
306 assertTrue "trilinears are reproduced correctly" $
307 and [p (i', j', k') ~= value_at trilinear i j k
312 let p = polynomial t,
313 let i' = fromIntegral i,
314 let j' = fromIntegral j,
315 let k' = fromIntegral k]
317 g = make_grid 1 trilinear
318 c0 = fromJust $ cube_at g 1 1 1
321 test_zeros_reproduced :: Assertion
322 test_zeros_reproduced =
323 assertTrue "the zero function is reproduced correctly" $
324 and [p (i', j', k') ~= value_at zeros i j k
328 let i' = fromIntegral i,
329 let j' = fromIntegral j,
330 let k' = fromIntegral k]
332 g = make_grid 1 zeros
333 c0 = fromJust $ cube_at g 1 1 1
338 -- | Make sure we can reproduce a 9x9x9 trilinear from the 3x3x3 one.
339 test_trilinear9x9x9_reproduced :: Assertion
340 test_trilinear9x9x9_reproduced =
341 assertTrue "trilinear 9x9x9 is reproduced correctly" $
342 and [p (i', j', k') ~= value_at trilinear9x9x9 i j k
347 let p = polynomial t,
348 let i' = (fromIntegral i) * 0.5,
349 let j' = (fromIntegral j) * 0.5,
350 let k' = (fromIntegral k) * 0.5]
352 g = make_grid 1 trilinear
353 c0 = fromJust $ cube_at g 1 1 1