import qualified Face (Face(Face, v0, v1, v2, v3))
import FunctionValues
import Point
-import Tetrahedron hiding (c)
+import Tetrahedron hiding (c, fv)
import ThreeDimensional
data Cube = Cube { h :: Double,
tetrahedron :: Cube -> Int -> Tetrahedron
tetrahedron c 0 =
- Tetrahedron (Cube.fv c) v0' v1' v2' v3' vol 0
+ Tetrahedron (Cube.fv c) v0' v1' v2' v3' vol
where
v0' = center c
v1' = center (front_face c)
vol = tetrahedra_volume c
tetrahedron c 1 =
- Tetrahedron fv' v0' v1' v2' v3' vol 1
+ Tetrahedron fv' v0' v1' v2' v3' vol
where
v0' = center c
v1' = center (front_face c)
vol = tetrahedra_volume c
tetrahedron c 2 =
- Tetrahedron fv' v0' v1' v2' v3' vol 2
+ Tetrahedron fv' v0' v1' v2' v3' vol
where
v0' = center c
v1' = center (front_face c)
vol = tetrahedra_volume c
tetrahedron c 3 =
- Tetrahedron fv' v0' v1' v2' v3' vol 3
+ Tetrahedron fv' v0' v1' v2' v3' vol
where
v0' = center c
v1' = center (front_face c)
vol = tetrahedra_volume c
tetrahedron c 4 =
- Tetrahedron fv' v0' v1' v2' v3' vol 4
+ Tetrahedron fv' v0' v1' v2' v3' vol
where
v0' = center c
v1' = center (top_face c)
vol = tetrahedra_volume c
tetrahedron c 5 =
- Tetrahedron fv' v0' v1' v2' v3' vol 5
+ Tetrahedron fv' v0' v1' v2' v3' vol
where
v0' = center c
v1' = center (top_face c)
v2' = Face.v1 (top_face c)
v3' = Face.v2 (top_face c)
- fv' = rotate cwy $ rotate cwz $ Tetrahedron.fv (tetrahedron c 0)
+ fv' = rotate cwy $ rotate cwz $ fv c
vol = tetrahedra_volume c
tetrahedron c 6 =
- Tetrahedron fv' v0' v1' v2' v3' vol 6
+ Tetrahedron fv' v0' v1' v2' v3' vol
where
v0' = center c
v1' = center (top_face c)
v3' = Face.v3 (top_face c)
fv' = rotate cwy $ rotate cwz
$ rotate cwz
- $ Tetrahedron.fv (tetrahedron c 0)
+ $ fv c
vol = tetrahedra_volume c
tetrahedron c 7 =
- Tetrahedron fv' v0' v1' v2' v3' vol 7
+ Tetrahedron fv' v0' v1' v2' v3' vol
where
v0' = center c
v1' = center (top_face c)
v2' = Face.v3 (top_face c)
v3' = Face.v0 (top_face c)
- fv' = rotate cwy $ rotate ccwz $ Tetrahedron.fv (tetrahedron c 0)
+ fv' = rotate cwy $ rotate ccwz $ fv c
vol = tetrahedra_volume c
tetrahedron c 8 =
- Tetrahedron fv' v0' v1' v2' v3' vol 8
+ Tetrahedron fv' v0' v1' v2' v3' vol
where
v0' = center c
v1' = center (back_face c)
v2' = Face.v0 (back_face c)
v3' = Face.v1 (back_face c)
- fv' = rotate cwy $ rotate cwy $ Tetrahedron.fv (tetrahedron c 0)
+ fv' = rotate cwy $ rotate cwy $ fv c
vol = tetrahedra_volume c
tetrahedron c 9 =
- Tetrahedron fv' v0' v1' v2' v3' vol 9
+ Tetrahedron fv' v0' v1' v2' v3' vol
where
v0' = center c
v1' = center (back_face c)
v3' = Face.v2 (back_face c)
fv' = rotate cwy $ rotate cwy
$ rotate cwx
- $ Tetrahedron.fv (tetrahedron c 0)
+ $ fv c
vol = tetrahedra_volume c
tetrahedron c 10 =
- Tetrahedron fv' v0' v1' v2' v3' vol 10
+ Tetrahedron fv' v0' v1' v2' v3' vol
where
v0' = center c
v1' = center (back_face c)
fv' = rotate cwy $ rotate cwy
$ rotate cwx
$ rotate cwx
- $ Tetrahedron.fv (tetrahedron c 0)
+ $ fv c
vol = tetrahedra_volume c
tetrahedron c 11 =
- Tetrahedron fv' v0' v1' v2' v3' vol 11
+ Tetrahedron fv' v0' v1' v2' v3' vol
where
v0' = center c
v1' = center (back_face c)
v3' = Face.v0 (back_face c)
fv' = rotate cwy $ rotate cwy
$ rotate ccwx
- $ Tetrahedron.fv (tetrahedron c 0)
+ $ fv c
vol = tetrahedra_volume c
tetrahedron c 12 =
- Tetrahedron fv' v0' v1' v2' v3' vol 12
+ Tetrahedron fv' v0' v1' v2' v3' vol
where
v0' = center c
v1' = center (down_face c)
v2' = Face.v0 (down_face c)
v3' = Face.v1 (down_face c)
- fv' = rotate ccwy (Tetrahedron.fv (tetrahedron c 0))
+ fv' = rotate ccwy $ fv c
vol = tetrahedra_volume c
tetrahedron c 13 =
- Tetrahedron fv' v0' v1' v2' v3' vol 13
+ Tetrahedron fv' v0' v1' v2' v3' vol
where
v0' = center c
v1' = center (down_face c)
v2' = Face.v1 (down_face c)
v3' = Face.v2 (down_face c)
- fv' = rotate ccwy $ rotate ccwz $ Tetrahedron.fv (tetrahedron c 0)
+ fv' = rotate ccwy $ rotate ccwz $ fv c
vol = tetrahedra_volume c
tetrahedron c 14 =
- Tetrahedron fv' v0' v1' v2' v3' vol 14
+ Tetrahedron fv' v0' v1' v2' v3' vol
where
v0' = center c
v1' = center (down_face c)
v3' = Face.v3 (down_face c)
fv' = rotate ccwy $ rotate ccwz
$ rotate ccwz
- $ Tetrahedron.fv (tetrahedron c 0)
+ $ fv c
vol = tetrahedra_volume c
tetrahedron c 15 =
- Tetrahedron fv' v0' v1' v2' v3' vol 15
+ Tetrahedron fv' v0' v1' v2' v3' vol
where
v0' = center c
v1' = center (down_face c)
v2' = Face.v3 (down_face c)
v3' = Face.v0 (down_face c)
- fv' = rotate ccwy $ rotate cwz $ Tetrahedron.fv (tetrahedron c 0)
+ fv' = rotate ccwy $ rotate cwz $ fv c
vol = tetrahedra_volume c
tetrahedron c 16 =
- Tetrahedron fv' v0' v1' v2' v3' vol 16
+ Tetrahedron fv' v0' v1' v2' v3' vol
where
v0' = center c
v1' = center (right_face c)
v2' = Face.v0 (right_face c)
v3' = Face.v1 (right_face c)
- fv' = rotate ccwz (Tetrahedron.fv (tetrahedron c 0))
+ fv' = rotate ccwz $ fv c
vol = tetrahedra_volume c
tetrahedron c 17 =
- Tetrahedron fv' v0' v1' v2' v3' vol 17
+ Tetrahedron fv' v0' v1' v2' v3' vol
where
v0' = center c
v1' = center (right_face c)
v2' = Face.v1 (right_face c)
v3' = Face.v2 (right_face c)
- fv' = rotate ccwz $ rotate cwy $ Tetrahedron.fv (tetrahedron c 0)
+ fv' = rotate ccwz $ rotate cwy $ fv c
vol = tetrahedra_volume c
tetrahedron c 18 =
- Tetrahedron fv' v0' v1' v2' v3' vol 18
+ Tetrahedron fv' v0' v1' v2' v3' vol
where
v0' = center c
v1' = center (right_face c)
v3' = Face.v3 (right_face c)
fv' = rotate ccwz $ rotate cwy
$ rotate cwy
- $ Tetrahedron.fv (tetrahedron c 0)
+ $ fv c
vol = tetrahedra_volume c
tetrahedron c 19 =
- Tetrahedron fv' v0' v1' v2' v3' vol 19
+ Tetrahedron fv' v0' v1' v2' v3' vol
where
v0' = center c
v1' = center (right_face c)
v2' = Face.v3 (right_face c)
v3' = Face.v0 (right_face c)
fv' = rotate ccwz $ rotate ccwy
- $ Tetrahedron.fv (tetrahedron c 0)
+ $ fv c
vol = tetrahedra_volume c
tetrahedron c 20 =
- Tetrahedron fv' v0' v1' v2' v3' vol 20
+ Tetrahedron fv' v0' v1' v2' v3' vol
where
v0' = center c
v1' = center (left_face c)
v2' = Face.v0 (left_face c)
v3' = Face.v1 (left_face c)
- fv' = rotate cwz (Tetrahedron.fv (tetrahedron c 0))
+ fv' = rotate cwz $ fv c
vol = tetrahedra_volume c
tetrahedron c 21 =
- Tetrahedron fv' v0' v1' v2' v3' vol 21
+ Tetrahedron fv' v0' v1' v2' v3' vol
where
v0' = center c
v1' = center (left_face c)
v2' = Face.v1 (left_face c)
v3' = Face.v2 (left_face c)
- fv' = rotate cwz $ rotate ccwy $ Tetrahedron.fv (tetrahedron c 0)
+ fv' = rotate cwz $ rotate ccwy $ fv c
vol = tetrahedra_volume c
tetrahedron c 22 =
- Tetrahedron fv' v0' v1' v2' v3' vol 22
+ Tetrahedron fv' v0' v1' v2' v3' vol
where
v0' = center c
v1' = center (left_face c)
v3' = Face.v3 (left_face c)
fv' = rotate cwz $ rotate ccwy
$ rotate ccwy
- $ Tetrahedron.fv (tetrahedron c 0)
+ $ fv c
vol = tetrahedra_volume c
tetrahedron c 23 =
- Tetrahedron fv' v0' v1' v2' v3' vol 23
+ Tetrahedron fv' v0' v1' v2' v3' vol
where
v0' = center c
v1' = center (left_face c)
v2' = Face.v3 (left_face c)
v3' = Face.v0 (left_face c)
fv' = rotate cwz $ rotate cwy
- $ Tetrahedron.fv (tetrahedron c 0)
+ $ fv c
vol = tetrahedra_volume c
-- Feels dirty, but whatever.
)
import Numeric.LinearAlgebra hiding (i, scale)
import Prelude hiding (LT)
-import Test.QuickCheck (Arbitrary(..), Gen, choose)
+import Test.QuickCheck (Arbitrary(..), Gen)
import Cardinal
import Comparisons (nearly_ge)
v1 :: Point,
v2 :: Point,
v3 :: Point,
- precomputed_volume :: Double,
-
- -- | Between 0 and 23; used to quickly determine which
- -- tetrahedron I am in the parent 'Cube' without
- -- having to compare them all.
- number :: Int
+ precomputed_volume :: Double
}
deriving (Eq)
rnd_v2 <- arbitrary :: Gen Point
rnd_v3 <- arbitrary :: Gen Point
rnd_fv <- arbitrary :: Gen FunctionValues
- rnd_no <- choose (0,23)
-- We can't assign an incorrect precomputed volume,
-- so we have to calculate the correct one here.
- let t' = Tetrahedron rnd_fv rnd_v0 rnd_v1 rnd_v2 rnd_v3 0 rnd_no
+ let t' = Tetrahedron rnd_fv rnd_v0 rnd_v1 rnd_v2 rnd_v3 0
let vol = volume t'
- return (Tetrahedron rnd_fv rnd_v0 rnd_v1 rnd_v2 rnd_v3 vol rnd_no)
+ return (Tetrahedron rnd_fv rnd_v0 rnd_v1 rnd_v2 rnd_v3 vol)
instance Show Tetrahedron where
show t = "Tetrahedron:\n" ++
- " no: " ++ (show (number t)) ++ "\n" ++
" fv: " ++ (show (fv t)) ++ "\n" ++
" v0: " ++ (show (v0 t)) ++ "\n" ++
" v1: " ++ (show (v1 t)) ++ "\n" ++
instance ThreeDimensional Tetrahedron where
- center (Tetrahedron _ v0' v1' v2' v3' _ _) =
+ center (Tetrahedron _ v0' v1' v2' v3' _) =
(v0' + v1' + v2' + v3') `scale` (1/4)
contains_point t p =