From: Michael Orlitzky Date: Fri, 2 Sep 2011 14:35:06 +0000 (-0400) Subject: Revert "Attempt to use precomputed volumes everywhere, tests fail en masse." X-Git-Tag: 0.0.1~178 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=c4701eee43e313f634d3d76faee681ff28d76b72;p=spline3.git Revert "Attempt to use precomputed volumes everywhere, tests fail en masse." This reverts commit ffc644b4eaf951619bfe59a2050f455814263cb2. --- diff --git a/src/Cube.hs b/src/Cube.hs index 077fbbc..0122aea 100644 --- a/src/Cube.hs +++ b/src/Cube.hs @@ -15,8 +15,7 @@ data Cube = Cube { h :: Double, i :: Int, j :: Int, k :: Int, - fv :: FunctionValues, - tetrahedra_volume :: Double } + fv :: FunctionValues } deriving (Eq) @@ -27,8 +26,7 @@ instance Arbitrary Cube where j' <- choose (coordmin, coordmax) k' <- choose (coordmin, coordmax) fv' <- arbitrary :: Gen FunctionValues - (Positive tet_vol) <- arbitrary :: Gen (Positive Double) - return (Cube h' i' j' k' fv' tet_vol) + return (Cube h' i' j' k' fv') where coordmin = -268435456 -- -(2^29 / 2) coordmax = 268435456 -- +(2^29 / 2) @@ -53,7 +51,7 @@ instance Show Cube where -- | Returns an empty 'Cube'. empty_cube :: Cube -empty_cube = Cube 0 0 0 0 empty_values 0 +empty_cube = Cube 0 0 0 0 empty_values -- | The left-side boundary of the cube. See Sorokina and Zeilfelder, @@ -199,14 +197,9 @@ right_face c = Face.Face v0' v1' v2' v3' v3' = (center c) + (-delta, delta, -delta) -make_tetrahedron :: Cube -> Point -> Point -> Point -> Point -> Tetrahedron -make_tetrahedron c v0 v1 v2 v3 = - Tetrahedron (Cube.fv c) v0 v1 v2 v3 (tetrahedra_volume c) - - tetrahedron0 :: Cube -> Tetrahedron tetrahedron0 c = - make_tetrahedron c v0' v1' v2' v3' + Tetrahedron (Cube.fv c) v0' v1' v2' v3' where v0' = center c v1' = center (front_face c) @@ -215,7 +208,7 @@ tetrahedron0 c = tetrahedron1 :: Cube -> Tetrahedron tetrahedron1 c = - make_tetrahedron c v0' v1' v2' v3' + Tetrahedron fv' v0' v1' v2' v3' where v0' = center c v1' = center (front_face c) @@ -225,7 +218,7 @@ tetrahedron1 c = tetrahedron2 :: Cube -> Tetrahedron tetrahedron2 c = - make_tetrahedron c v0' v1' v2' v3' + Tetrahedron fv' v0' v1' v2' v3' where v0' = center c v1' = center (front_face c) @@ -235,7 +228,7 @@ tetrahedron2 c = tetrahedron3 :: Cube -> Tetrahedron tetrahedron3 c = - make_tetrahedron c v0' v1' v2' v3' + Tetrahedron fv' v0' v1' v2' v3' where v0' = center c v1' = center (front_face c) @@ -245,7 +238,7 @@ tetrahedron3 c = tetrahedron4 :: Cube -> Tetrahedron tetrahedron4 c = - make_tetrahedron c v0' v1' v2' v3' + Tetrahedron fv' v0' v1' v2' v3' where v0' = center c v1' = center (top_face c) @@ -255,7 +248,7 @@ tetrahedron4 c = tetrahedron5 :: Cube -> Tetrahedron tetrahedron5 c = - make_tetrahedron c v0' v1' v2' v3' + Tetrahedron fv' v0' v1' v2' v3' where v0' = center c v1' = center (top_face c) @@ -265,7 +258,7 @@ tetrahedron5 c = tetrahedron6 :: Cube -> Tetrahedron tetrahedron6 c = - make_tetrahedron c v0' v1' v2' v3' + Tetrahedron fv' v0' v1' v2' v3' where v0' = center c v1' = center (top_face c) @@ -277,7 +270,7 @@ tetrahedron6 c = tetrahedron7 :: Cube -> Tetrahedron tetrahedron7 c = - make_tetrahedron c v0' v1' v2' v3' + Tetrahedron fv' v0' v1' v2' v3' where v0' = center c v1' = center (top_face c) @@ -287,7 +280,7 @@ tetrahedron7 c = tetrahedron8 :: Cube -> Tetrahedron tetrahedron8 c = - make_tetrahedron c v0' v1' v2' v3' + Tetrahedron fv' v0' v1' v2' v3' where v0' = center c v1' = center (back_face c) @@ -297,7 +290,7 @@ tetrahedron8 c = tetrahedron9 :: Cube -> Tetrahedron tetrahedron9 c = - make_tetrahedron c v0' v1' v2' v3' + Tetrahedron fv' v0' v1' v2' v3' where v0' = center c v1' = center (back_face c) @@ -309,7 +302,7 @@ tetrahedron9 c = tetrahedron10 :: Cube -> Tetrahedron tetrahedron10 c = - make_tetrahedron c v0' v1' v2' v3' + Tetrahedron fv' v0' v1' v2' v3' where v0' = center c v1' = center (back_face c) @@ -323,7 +316,7 @@ tetrahedron10 c = tetrahedron11 :: Cube -> Tetrahedron tetrahedron11 c = - make_tetrahedron c v0' v1' v2' v3' + Tetrahedron fv' v0' v1' v2' v3' where v0' = center c v1' = center (back_face c) @@ -336,7 +329,7 @@ tetrahedron11 c = tetrahedron12 :: Cube -> Tetrahedron tetrahedron12 c = - make_tetrahedron c v0' v1' v2' v3' + Tetrahedron fv' v0' v1' v2' v3' where v0' = center c v1' = center (down_face c) @@ -347,7 +340,7 @@ tetrahedron12 c = tetrahedron13 :: Cube -> Tetrahedron tetrahedron13 c = - make_tetrahedron c v0' v1' v2' v3' + Tetrahedron fv' v0' v1' v2' v3' where v0' = center c v1' = center (down_face c) @@ -358,7 +351,7 @@ tetrahedron13 c = tetrahedron14 :: Cube -> Tetrahedron tetrahedron14 c = - make_tetrahedron c v0' v1' v2' v3' + Tetrahedron fv' v0' v1' v2' v3' where v0' = center c v1' = center (down_face c) @@ -371,7 +364,7 @@ tetrahedron14 c = tetrahedron15 :: Cube -> Tetrahedron tetrahedron15 c = - make_tetrahedron c v0' v1' v2' v3' + Tetrahedron fv' v0' v1' v2' v3' where v0' = center c v1' = center (down_face c) @@ -382,7 +375,7 @@ tetrahedron15 c = tetrahedron16 :: Cube -> Tetrahedron tetrahedron16 c = - make_tetrahedron c v0' v1' v2' v3' + Tetrahedron fv' v0' v1' v2' v3' where v0' = center c v1' = center (right_face c) @@ -393,7 +386,7 @@ tetrahedron16 c = tetrahedron17 :: Cube -> Tetrahedron tetrahedron17 c = - make_tetrahedron c v0' v1' v2' v3' + Tetrahedron fv' v0' v1' v2' v3' where v0' = center c v1' = center (right_face c) @@ -404,7 +397,7 @@ tetrahedron17 c = tetrahedron18 :: Cube -> Tetrahedron tetrahedron18 c = - make_tetrahedron c v0' v1' v2' v3' + Tetrahedron fv' v0' v1' v2' v3' where v0' = center c v1' = center (right_face c) @@ -417,7 +410,7 @@ tetrahedron18 c = tetrahedron19 :: Cube -> Tetrahedron tetrahedron19 c = - make_tetrahedron c v0' v1' v2' v3' + Tetrahedron fv' v0' v1' v2' v3' where v0' = center c v1' = center (right_face c) @@ -429,7 +422,7 @@ tetrahedron19 c = tetrahedron20 :: Cube -> Tetrahedron tetrahedron20 c = - make_tetrahedron c v0' v1' v2' v3' + Tetrahedron fv' v0' v1' v2' v3' where v0' = center c v1' = center (left_face c) @@ -440,7 +433,7 @@ tetrahedron20 c = tetrahedron21 :: Cube -> Tetrahedron tetrahedron21 c = - make_tetrahedron c v0' v1' v2' v3' + Tetrahedron fv' v0' v1' v2' v3' where v0' = center c v1' = center (left_face c) @@ -451,7 +444,7 @@ tetrahedron21 c = tetrahedron22 :: Cube -> Tetrahedron tetrahedron22 c = - make_tetrahedron c v0' v1' v2' v3' + Tetrahedron fv' v0' v1' v2' v3' where v0' = center c v1' = center (left_face c) @@ -464,7 +457,7 @@ tetrahedron22 c = tetrahedron23 :: Cube -> Tetrahedron tetrahedron23 c = - make_tetrahedron c v0' v1' v2' v3' + Tetrahedron fv' v0' v1' v2' v3' where v0' = center c v1' = center (left_face c) diff --git a/src/Grid.hs b/src/Grid.hs index 435f095..7325d2b 100644 --- a/src/Grid.hs +++ b/src/Grid.hs @@ -57,10 +57,7 @@ cubes g | i <- [0..xmax], j <- [0..ymax], k <- [0..zmax], - let delta = h g, - let tet_vol = (1/24)*(delta^(3::Int)), - let cube_ijk = - Cube delta i j k (make_values fvs i j k) tet_vol] + let cube_ijk = Cube (h g) i j k (make_values fvs i j k)] where xmax = xsize - 1 ymax = ysize - 1 diff --git a/src/Tests/Tetrahedron.hs b/src/Tests/Tetrahedron.hs index 3b511d2..8f83808 100644 --- a/src/Tests/Tetrahedron.hs +++ b/src/Tests/Tetrahedron.hs @@ -34,8 +34,7 @@ tetrahedron1_geometry_tests = v1 = p1, v2 = p2, v3 = p3, - fv = empty_values, - precomputed_volume = 0 } + fv = empty_values } volume1 :: Assertion volume1 = @@ -69,8 +68,7 @@ tetrahedron2_geometry_tests = v1 = p1, v2 = p2, v3 = p3, - fv = empty_values, - precomputed_volume = 0 } + fv = empty_values } volume1 :: Assertion volume1 = assertEqual "volume1 is correct" True (vol ~= (1/3)) @@ -108,8 +106,7 @@ containment_tests = v1 = p1, v2 = p2, v3 = p3, - fv = empty_values, - precomputed_volume = 0 } + fv = empty_values } contained = contains_point t exterior_point @@ -123,8 +120,7 @@ containment_tests = v1 = p1, v2 = p2, v3 = p3, - fv = empty_values, - precomputed_volume = 0 } + fv = empty_values } contained = contains_point t exterior_point @@ -138,8 +134,7 @@ containment_tests = v1 = p1, v2 = p2, v3 = p3, - fv = empty_values, - precomputed_volume = 0 } + fv = empty_values } contained = contains_point t exterior_point @@ -153,8 +148,7 @@ containment_tests = v1 = p1, v2 = p2, v3 = p3, - fv = empty_values, - precomputed_volume = 0 } + fv = empty_values } contained = contains_point t exterior_point diff --git a/src/Tetrahedron.hs b/src/Tetrahedron.hs index 4606761..95233e0 100644 --- a/src/Tetrahedron.hs +++ b/src/Tetrahedron.hs @@ -3,7 +3,7 @@ where import Numeric.LinearAlgebra hiding (i, scale) import Prelude hiding (LT) -import Test.QuickCheck (Arbitrary(..), Gen, Positive(..)) +import Test.QuickCheck (Arbitrary(..), Gen) import Cardinal import Comparisons (nearly_ge) @@ -17,8 +17,7 @@ data Tetrahedron = Tetrahedron { fv :: FunctionValues, v0 :: Point, v1 :: Point, v2 :: Point, - v3 :: Point, - precomputed_volume :: Double } + v3 :: Point } deriving (Eq) @@ -29,8 +28,7 @@ instance Arbitrary Tetrahedron where rnd_v2 <- arbitrary :: Gen Point rnd_v3 <- arbitrary :: Gen Point rnd_fv <- arbitrary :: Gen FunctionValues - (Positive rnd_vol) <- arbitrary :: Gen (Positive Double) - return (Tetrahedron rnd_fv rnd_v0 rnd_v1 rnd_v2 rnd_v3 rnd_vol) + return (Tetrahedron rnd_fv rnd_v0 rnd_v1 rnd_v2 rnd_v3) instance Show Tetrahedron where @@ -267,27 +265,27 @@ volume t -- | The barycentric coordinates of a point with respect to v0. b0 :: Tetrahedron -> (RealFunction Point) -b0 t point = (volume inner_tetrahedron) / (precomputed_volume t) +b0 t point = (volume inner_tetrahedron) / (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) / (precomputed_volume t) +b1 t point = (volume inner_tetrahedron) / (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) / (precomputed_volume t) +b2 t point = (volume inner_tetrahedron) / (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) / (precomputed_volume t) +b3 t point = (volume inner_tetrahedron) / (volume t) where inner_tetrahedron = t { v3 = point }