5 import qualified Face (Face(Face, v0, v1, v2, v3))
8 import Tetrahedron hiding (c)
9 import ThreeDimensional
11 data Cube = Cube { h :: Double,
15 fv :: FunctionValues }
19 instance Show Cube where
21 "Cube_" ++ subscript ++ "\n" ++
22 " h: " ++ (show (h c)) ++ "\n" ++
23 " Center: " ++ (show (center c)) ++ "\n" ++
24 " xmin: " ++ (show (xmin c)) ++ "\n" ++
25 " xmax: " ++ (show (xmax c)) ++ "\n" ++
26 " ymin: " ++ (show (ymin c)) ++ "\n" ++
27 " ymax: " ++ (show (ymax c)) ++ "\n" ++
28 " zmin: " ++ (show (zmin c)) ++ "\n" ++
29 " zmax: " ++ (show (zmax c)) ++ "\n" ++
30 " fv: " ++ (show (Cube.fv c)) ++ "\n"
33 (show (i c)) ++ "," ++ (show (j c)) ++ "," ++ (show (k c))
37 empty_cube = Cube 0 0 0 0 empty_values
40 -- | The left-side boundary of the cube. See Sorokina and Zeilfelder,
42 xmin :: Cube -> Double
43 xmin c = (2*i' - 1)*delta / 2
45 i' = fromIntegral (i c) :: Double
48 -- | The right-side boundary of the cube. See Sorokina and Zeilfelder,
50 xmax :: Cube -> Double
51 xmax c = (2*i' + 1)*delta / 2
53 i' = fromIntegral (i c) :: Double
56 -- | The front boundary of the cube. See Sorokina and Zeilfelder,
58 ymin :: Cube -> Double
59 ymin c = (2*j' - 1)*delta / 2
61 j' = fromIntegral (j c) :: Double
64 -- | The back boundary of the cube. See Sorokina and Zeilfelder,
66 ymax :: Cube -> Double
67 ymax c = (2*j' + 1)*delta / 2
69 j' = fromIntegral (j c) :: Double
72 -- | The bottom boundary of the cube. See Sorokina and Zeilfelder,
74 zmin :: Cube -> Double
75 zmin c = (2*k' - 1)*delta / 2
77 k' = fromIntegral (k c) :: Double
80 -- | The top boundary of the cube. See Sorokina and Zeilfelder,
82 zmax :: Cube -> Double
83 zmax c = (2*k' + 1)*delta / 2
85 k' = fromIntegral (k c) :: Double
88 instance ThreeDimensional Cube where
89 -- | The center of Cube_ijk coincides with v_ijk at
90 -- (ih, jh, kh). See Sorokina and Zeilfelder, p. 76.
94 i' = fromIntegral (i c) :: Double
95 j' = fromIntegral (j c) :: Double
96 k' = fromIntegral (k c) :: Double
102 | (x_coord p) < (xmin c) = False
103 | (x_coord p) > (xmax c) = False
104 | (y_coord p) < (ymin c) = False
105 | (y_coord p) > (ymax c) = False
106 | (z_coord p) < (zmin c) = False
107 | (z_coord p) > (zmax c) = False
114 -- | The top (in the direction of z) face of the cube.
115 top_face :: Cube -> Face.Face
116 top_face c = Face.Face v0' v1' v2' v3'
119 v0' = (center c) + (delta, -delta, delta)
120 v1' = (center c) + (delta, delta, delta)
121 v2' = (center c) + (-delta, delta, delta)
122 v3' = (center c) + (-delta, -delta, delta)
126 -- | The back (in the direction of x) face of the cube.
127 back_face :: Cube -> Face.Face
128 back_face c = Face.Face v0' v1' v2' v3'
131 v0' = (center c) + (delta, -delta, -delta)
132 v1' = (center c) + (delta, delta, -delta)
133 v2' = (center c) + (delta, delta, delta)
134 v3' = (center c) + (delta, -delta, delta)
137 -- The bottom face (in the direction of -z) of the cube.
138 down_face :: Cube -> Face.Face
139 down_face c = Face.Face v0' v1' v2' v3'
142 v0' = (center c) + (-delta, -delta, -delta)
143 v1' = (center c) + (-delta, delta, -delta)
144 v2' = (center c) + (delta, delta, -delta)
145 v3' = (center c) + (delta, -delta, -delta)
149 -- | The front (in the direction of -x) face of the cube.
150 front_face :: Cube -> Face.Face
151 front_face c = Face.Face v0' v1' v2' v3'
154 v0' = (center c) + (-delta, -delta, delta)
155 v1' = (center c) + (-delta, delta, delta)
156 v2' = (center c) + (-delta, delta, -delta)
157 v3' = (center c) + (-delta, -delta, -delta)
159 -- | The left (in the direction of -y) face of the cube.
160 left_face :: Cube -> Face.Face
161 left_face c = Face.Face v0' v1' v2' v3'
164 v0' = (center c) + (delta, -delta, delta)
165 v1' = (center c) + (-delta, -delta, delta)
166 v2' = (center c) + (-delta, -delta, -delta)
167 v3' = (center c) + (delta, -delta, -delta)
170 -- | The right (in the direction of y) face of the cube.
171 right_face :: Cube -> Face.Face
172 right_face c = Face.Face v0' v1' v2' v3'
175 v0' = (center c) + (-delta, delta, delta)
176 v1' = (center c) + (delta, delta, delta)
177 v2' = (center c) + (delta, delta, -delta)
178 v3' = (center c) + (-delta, delta, -delta)
181 tetrahedron0 :: Cube -> Tetrahedron
183 Tetrahedron (Cube.fv c) v0' v1' v2' v3'
186 v1' = center (front_face c)
187 v2' = Face.v0 (front_face c)
188 v3' = Face.v1 (front_face c)
190 tetrahedron1 :: Cube -> Tetrahedron
192 Tetrahedron fv' v0' v1' v2' v3'
195 v1' = center (front_face c)
196 v2' = Face.v1 (front_face c)
197 v3' = Face.v2 (front_face c)
198 fv' = rotate (Cube.fv c) ccwx
200 tetrahedron2 :: Cube -> Tetrahedron
202 Tetrahedron fv' v0' v1' v2' v3'
205 v1' = center (front_face c)
206 v2' = Face.v2 (front_face c)
207 v3' = Face.v3 (front_face c)
208 fv' = rotate (Cube.fv c) (ccwx . ccwx)
210 tetrahedron3 :: Cube -> Tetrahedron
212 Tetrahedron fv' v0' v1' v2' v3'
215 v1' = center (front_face c)
216 v2' = Face.v3 (front_face c)
217 v3' = Face.v0 (front_face c)
218 fv' = rotate (Cube.fv c) cwx
220 tetrahedron4 :: Cube -> Tetrahedron
222 Tetrahedron fv' v0' v1' v2' v3'
225 v1' = center (top_face c)
226 v2' = Face.v0 (top_face c)
227 v3' = Face.v1 (top_face c)
228 fv' = rotate (Cube.fv c) cwy
230 tetrahedron5 :: Cube -> Tetrahedron
232 Tetrahedron fv' v0' v1' v2' v3'
235 v1' = center (top_face c)
236 v2' = Face.v1 (top_face c)
237 v3' = Face.v2 (top_face c)
238 fv' = rotate (Tetrahedron.fv (tetrahedron4 c)) ccwz
240 tetrahedron6 :: Cube -> Tetrahedron
242 Tetrahedron fv' v0' v1' v2' v3'
245 v1' = center (top_face c)
246 v2' = Face.v2 (top_face c)
247 v3' = Face.v3 (top_face c)
248 fv' = rotate (Tetrahedron.fv (tetrahedron4 c)) (ccwz . ccwz)
250 tetrahedron7 :: Cube -> Tetrahedron
252 Tetrahedron fv' v0' v1' v2' v3'
255 v1' = center (top_face c)
256 v2' = Face.v3 (top_face c)
257 v3' = Face.v0 (top_face c)
258 fv' = rotate (Tetrahedron.fv (tetrahedron4 c)) cwz
260 tetrahedron8 :: Cube -> Tetrahedron
262 Tetrahedron fv' v0' v1' v2' v3'
265 v1' = center (back_face c)
266 v2' = Face.v0 (back_face c)
267 v3' = Face.v1 (back_face c)
268 fv' = rotate (Tetrahedron.fv (tetrahedron4 c)) cwy
270 tetrahedron9 :: Cube -> Tetrahedron
272 Tetrahedron fv' v0' v1' v2' v3'
275 v1' = center (back_face c)
276 v2' = Face.v1 (back_face c)
277 v3' = Face.v2 (back_face c)
278 fv' = rotate (Tetrahedron.fv (tetrahedron8 c)) ccwx
280 tetrahedron10 :: Cube -> Tetrahedron
282 Tetrahedron fv' v0' v1' v2' v3'
285 v1' = center (back_face c)
286 v2' = Face.v2 (back_face c)
287 v3' = Face.v3 (back_face c)
288 fv' = rotate (Tetrahedron.fv (tetrahedron8 c)) (ccwx . ccwx)
291 tetrahedron11 :: Cube -> Tetrahedron
293 Tetrahedron fv' v0' v1' v2' v3'
296 v1' = center (back_face c)
297 v2' = Face.v3 (back_face c)
298 v3' = Face.v0 (back_face c)
299 fv' = rotate (Tetrahedron.fv (tetrahedron8 c)) cwx
302 tetrahedron12 :: Cube -> Tetrahedron
304 Tetrahedron fv' v0' v1' v2' v3'
307 v1' = center (down_face c)
308 v2' = Face.v0 (down_face c)
309 v3' = Face.v1 (down_face c)
310 fv' = rotate (Tetrahedron.fv (tetrahedron8 c)) cwy
313 tetrahedron13 :: Cube -> Tetrahedron
315 Tetrahedron fv' v0' v1' v2' v3'
318 v1' = center (down_face c)
319 v2' = Face.v1 (down_face c)
320 v3' = Face.v2 (down_face c)
321 fv' = rotate (Tetrahedron.fv (tetrahedron12 c)) ccwz
324 tetrahedron14 :: Cube -> Tetrahedron
326 Tetrahedron fv' v0' v1' v2' v3'
329 v1' = center (down_face c)
330 v2' = Face.v2 (down_face c)
331 v3' = Face.v3 (down_face c)
332 fv' = rotate (Tetrahedron.fv (tetrahedron13 c)) (ccwz . ccwz)
335 tetrahedron15 :: Cube -> Tetrahedron
337 Tetrahedron fv' v0' v1' v2' v3'
340 v1' = center (down_face c)
341 v2' = Face.v3 (down_face c)
342 v3' = Face.v0 (down_face c)
343 fv' = rotate (Tetrahedron.fv (tetrahedron12 c)) cwz
346 tetrahedron16 :: Cube -> Tetrahedron
348 Tetrahedron fv' v0' v1' v2' v3'
351 v1' = center (right_face c)
352 v2' = Face.v0 (right_face c)
353 v3' = Face.v1 (right_face c)
354 fv' = rotate (Tetrahedron.fv (tetrahedron0 c)) ccwz
357 tetrahedron17 :: Cube -> Tetrahedron
359 Tetrahedron fv' v0' v1' v2' v3'
362 v1' = center (right_face c)
363 v2' = Face.v1 (right_face c)
364 v3' = Face.v2 (right_face c)
365 fv' = rotate (Tetrahedron.fv (tetrahedron16 c)) cwy
368 tetrahedron18 :: Cube -> Tetrahedron
370 Tetrahedron fv' v0' v1' v2' v3'
373 v1' = center (right_face c)
374 v2' = Face.v2 (right_face c)
375 v3' = Face.v3 (right_face c)
376 fv' = rotate (Tetrahedron.fv (tetrahedron16 c)) (cwy . cwy)
379 tetrahedron19 :: Cube -> Tetrahedron
381 Tetrahedron fv' v0' v1' v2' v3'
384 v1' = center (right_face c)
385 v2' = Face.v3 (right_face c)
386 v3' = Face.v0 (right_face c)
387 fv' = rotate (Tetrahedron.fv (tetrahedron16 c)) ccwy
390 tetrahedron20 :: Cube -> Tetrahedron
392 Tetrahedron fv' v0' v1' v2' v3'
395 v1' = center (left_face c)
396 v2' = Face.v0 (left_face c)
397 v3' = Face.v1 (left_face c)
398 fv' = rotate (Tetrahedron.fv (tetrahedron0 c)) cwz
401 tetrahedron21 :: Cube -> Tetrahedron
403 Tetrahedron fv' v0' v1' v2' v3'
406 v1' = center (left_face c)
407 v2' = Face.v1 (left_face c)
408 v3' = Face.v2 (left_face c)
409 fv' = rotate (Tetrahedron.fv (tetrahedron20 c)) ccwy
412 tetrahedron22 :: Cube -> Tetrahedron
414 Tetrahedron fv' v0' v1' v2' v3'
417 v1' = center (left_face c)
418 v2' = Face.v2 (left_face c)
419 v3' = Face.v3 (left_face c)
420 fv' = rotate (Tetrahedron.fv (tetrahedron20 c)) ccwy
423 tetrahedron23 :: Cube -> Tetrahedron
425 Tetrahedron fv' v0' v1' v2' v3'
428 v1' = center (left_face c)
429 v2' = Face.v3 (left_face c)
430 v3' = Face.v0 (left_face c)
431 fv' = rotate (Tetrahedron.fv (tetrahedron20 c)) ccwy
434 tetrahedrons :: Cube -> [Tetrahedron]