i :: Int,
j :: Int,
k :: Int,
- fv :: FunctionValues }
+ fv :: FunctionValues,
+ tetrahedra_volume :: Double }
deriving (Eq)
j' <- choose (coordmin, coordmax)
k' <- choose (coordmin, coordmax)
fv' <- arbitrary :: Gen FunctionValues
- return (Cube h' i' j' k' fv')
+ (Positive tet_vol) <- arbitrary :: Gen (Positive Double)
+ return (Cube h' i' j' k' fv' tet_vol)
where
coordmin = -268435456 -- -(2^29 / 2)
coordmax = 268435456 -- +(2^29 / 2)
-- | Returns an empty 'Cube'.
empty_cube :: Cube
-empty_cube = Cube 0 0 0 0 empty_values
+empty_cube = Cube 0 0 0 0 empty_values 0
-- | The left-side boundary of the cube. See Sorokina and Zeilfelder,
v1' = center (front_face c)
v2' = Face.v0 (front_face c)
v3' = Face.v1 (front_face c)
- vol = 0
+ vol = tetrahedra_volume c
tetrahedron1 :: Cube -> Tetrahedron
tetrahedron1 c =
v2' = Face.v1 (front_face c)
v3' = Face.v2 (front_face c)
fv' = rotate ccwx (Cube.fv c)
- vol = 0
+ vol = tetrahedra_volume c
tetrahedron2 :: Cube -> Tetrahedron
tetrahedron2 c =
v2' = Face.v2 (front_face c)
v3' = Face.v3 (front_face c)
fv' = rotate ccwx $ rotate ccwx $ Cube.fv c
- vol = 0
+ vol = tetrahedra_volume c
tetrahedron3 :: Cube -> Tetrahedron
tetrahedron3 c =
v2' = Face.v3 (front_face c)
v3' = Face.v0 (front_face c)
fv' = rotate cwx (Cube.fv c)
- vol = 0
+ vol = tetrahedra_volume c
tetrahedron4 :: Cube -> Tetrahedron
tetrahedron4 c =
v2' = Face.v0 (top_face c)
v3' = Face.v1 (top_face c)
fv' = rotate cwy (Cube.fv c)
- vol = 0
+ vol = tetrahedra_volume c
tetrahedron5 :: Cube -> Tetrahedron
tetrahedron5 c =
v2' = Face.v1 (top_face c)
v3' = Face.v2 (top_face c)
fv' = rotate cwy $ rotate cwz $ Tetrahedron.fv (tetrahedron0 c)
- vol = 0
+ vol = tetrahedra_volume c
tetrahedron6 :: Cube -> Tetrahedron
tetrahedron6 c =
fv' = rotate cwy $ rotate cwz
$ rotate cwz
$ Tetrahedron.fv (tetrahedron0 c)
- vol = 0
+ vol = tetrahedra_volume c
tetrahedron7 :: Cube -> Tetrahedron
tetrahedron7 c =
v2' = Face.v3 (top_face c)
v3' = Face.v0 (top_face c)
fv' = rotate cwy $ rotate ccwz $ Tetrahedron.fv (tetrahedron0 c)
- vol = 0
+ vol = tetrahedra_volume c
tetrahedron8 :: Cube -> Tetrahedron
tetrahedron8 c =
v2' = Face.v0 (back_face c)
v3' = Face.v1 (back_face c)
fv' = rotate cwy $ rotate cwy $ Tetrahedron.fv (tetrahedron0 c)
- vol = 0
+ vol = tetrahedra_volume c
tetrahedron9 :: Cube -> Tetrahedron
tetrahedron9 c =
fv' = rotate cwy $ rotate cwy
$ rotate cwx
$ Tetrahedron.fv (tetrahedron0 c)
- vol = 0
+ vol = tetrahedra_volume c
tetrahedron10 :: Cube -> Tetrahedron
tetrahedron10 c =
$ rotate cwx
$ Tetrahedron.fv (tetrahedron0 c)
- vol = 0
+ vol = tetrahedra_volume c
tetrahedron11 :: Cube -> Tetrahedron
tetrahedron11 c =
fv' = rotate cwy $ rotate cwy
$ rotate ccwx
$ Tetrahedron.fv (tetrahedron0 c)
- vol = 0
+ vol = tetrahedra_volume c
tetrahedron12 :: Cube -> Tetrahedron
v2' = Face.v0 (down_face c)
v3' = Face.v1 (down_face c)
fv' = rotate ccwy (Tetrahedron.fv (tetrahedron0 c))
- vol = 0
+ vol = tetrahedra_volume c
tetrahedron13 :: Cube -> Tetrahedron
v2' = Face.v1 (down_face c)
v3' = Face.v2 (down_face c)
fv' = rotate ccwy $ rotate ccwz $ Tetrahedron.fv (tetrahedron0 c)
- vol = 0
+ vol = tetrahedra_volume c
tetrahedron14 :: Cube -> Tetrahedron
fv' = rotate ccwy $ rotate ccwz
$ rotate ccwz
$ Tetrahedron.fv (tetrahedron0 c)
- vol = 0
+ vol = tetrahedra_volume c
tetrahedron15 :: Cube -> Tetrahedron
v2' = Face.v3 (down_face c)
v3' = Face.v0 (down_face c)
fv' = rotate ccwy $ rotate cwz $ Tetrahedron.fv (tetrahedron0 c)
- vol = 0
+ vol = tetrahedra_volume c
tetrahedron16 :: Cube -> Tetrahedron
v2' = Face.v0 (right_face c)
v3' = Face.v1 (right_face c)
fv' = rotate ccwz (Tetrahedron.fv (tetrahedron0 c))
- vol = 0
+ vol = tetrahedra_volume c
tetrahedron17 :: Cube -> Tetrahedron
v2' = Face.v1 (right_face c)
v3' = Face.v2 (right_face c)
fv' = rotate ccwz $ rotate cwy $ Tetrahedron.fv (tetrahedron0 c)
- vol = 0
+ vol = tetrahedra_volume c
tetrahedron18 :: Cube -> Tetrahedron
fv' = rotate ccwz $ rotate cwy
$ rotate cwy
$ Tetrahedron.fv (tetrahedron0 c)
- vol = 0
+ vol = tetrahedra_volume c
tetrahedron19 :: Cube -> Tetrahedron
v3' = Face.v0 (right_face c)
fv' = rotate ccwz $ rotate ccwy
$ Tetrahedron.fv (tetrahedron0 c)
- vol = 0
+ vol = tetrahedra_volume c
tetrahedron20 :: Cube -> Tetrahedron
v2' = Face.v0 (left_face c)
v3' = Face.v1 (left_face c)
fv' = rotate cwz (Tetrahedron.fv (tetrahedron0 c))
- vol = 0
+ vol = tetrahedra_volume c
tetrahedron21 :: Cube -> Tetrahedron
v2' = Face.v1 (left_face c)
v3' = Face.v2 (left_face c)
fv' = rotate cwz $ rotate ccwy $ Tetrahedron.fv (tetrahedron0 c)
- vol = 0
+ vol = tetrahedra_volume c
tetrahedron22 :: Cube -> Tetrahedron
fv' = rotate cwz $ rotate ccwy
$ rotate ccwy
$ Tetrahedron.fv (tetrahedron0 c)
- vol = 0
+ vol = tetrahedra_volume c
tetrahedron23 :: Cube -> Tetrahedron
v3' = Face.v0 (left_face c)
fv' = rotate cwz $ rotate cwy
$ Tetrahedron.fv (tetrahedron0 c)
- vol = 0
+ vol = tetrahedra_volume c
tetrahedra :: Cube -> [Tetrahedron]
rnd_v2 <- arbitrary :: Gen Point
rnd_v3 <- arbitrary :: Gen Point
rnd_fv <- arbitrary :: Gen FunctionValues
- rnd_vol <- arbitrary :: Gen Double
- return (Tetrahedron rnd_fv rnd_v0 rnd_v1 rnd_v2 rnd_v3 rnd_vol)
+ -- 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
+ let vol = volume t'
+ return (Tetrahedron rnd_fv rnd_v0 rnd_v1 rnd_v2 rnd_v3 vol)
instance Show Tetrahedron where
-- | The barycentric coordinates of a point with respect to v0.
b0 :: Tetrahedron -> (RealFunction Point)
-b0 t point = (volume inner_tetrahedron) / (volume t)
+b0 t point = (volume inner_tetrahedron) / (precomputed_volume t)
where
inner_tetrahedron = t { v0 = point }
-- | The barycentric coordinates of a point with respect to v1.
b1 :: Tetrahedron -> (RealFunction Point)
-b1 t point = (volume inner_tetrahedron) / (volume t)
+b1 t point = (volume inner_tetrahedron) / (precomputed_volume t)
where
inner_tetrahedron = t { v1 = point }
-- | The barycentric coordinates of a point with respect to v2.
b2 :: Tetrahedron -> (RealFunction Point)
-b2 t point = (volume inner_tetrahedron) / (volume t)
+b2 t point = (volume inner_tetrahedron) / (precomputed_volume t)
where
inner_tetrahedron = t { v2 = point }
-- | The barycentric coordinates of a point with respect to v3.
b3 :: Tetrahedron -> (RealFunction Point)
-b3 t point = (volume inner_tetrahedron) / (volume t)
+b3 t point = (volume inner_tetrahedron) / (precomputed_volume t)
where
inner_tetrahedron = t { v3 = point }