From: Michael Orlitzky Date: Thu, 8 Sep 2011 21:36:13 +0000 (-0400) Subject: Remove the Tetrahedron 'number' field. X-Git-Tag: 0.0.1~140 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=4d695b8d0b05a02d562bdee3d2a1b98ce6a5e747;p=spline3.git Remove the Tetrahedron 'number' field. --- diff --git a/src/Cube.hs b/src/Cube.hs index 41d4060..b0b153e 100644 --- a/src/Cube.hs +++ b/src/Cube.hs @@ -17,7 +17,7 @@ import Cardinal 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, @@ -211,7 +211,7 @@ right_face c = Face.Face v0' v1' v2' v3' 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) @@ -220,7 +220,7 @@ tetrahedron c 0 = 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) @@ -230,7 +230,7 @@ tetrahedron c 1 = 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) @@ -240,7 +240,7 @@ tetrahedron c 2 = 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) @@ -250,7 +250,7 @@ tetrahedron c 3 = 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) @@ -260,17 +260,17 @@ tetrahedron c 4 = 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) @@ -278,31 +278,31 @@ tetrahedron c 6 = 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) @@ -310,11 +310,11 @@ tetrahedron c 9 = 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) @@ -323,12 +323,12 @@ tetrahedron c 10 = 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) @@ -336,31 +336,31 @@ tetrahedron c 11 = 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) @@ -368,41 +368,41 @@ tetrahedron c 14 = 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) @@ -410,42 +410,42 @@ tetrahedron c 18 = 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) @@ -453,18 +453,18 @@ tetrahedron c 22 = 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. diff --git a/src/Tetrahedron.hs b/src/Tetrahedron.hs index 87332b9..9f68364 100644 --- a/src/Tetrahedron.hs +++ b/src/Tetrahedron.hs @@ -8,7 +8,7 @@ import qualified Data.Vector as V ( ) 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) @@ -24,12 +24,7 @@ data Tetrahedron = 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) @@ -41,18 +36,16 @@ instance Arbitrary Tetrahedron where 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" ++ @@ -61,7 +54,7 @@ instance Show Tetrahedron where 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 =