From: Michael Orlitzky Date: Mon, 29 Aug 2011 23:06:38 +0000 (-0400) Subject: Modify the Grid module to use ScaleFactors. X-Git-Tag: 0.0.1~203 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=23118274318c8f1bb9e469eb68297b80418a7d4f;p=spline3.git Modify the Grid module to use ScaleFactors. --- diff --git a/src/Grid.hs b/src/Grid.hs index 7996319..6a9a8e5 100644 --- a/src/Grid.hs +++ b/src/Grid.hs @@ -10,6 +10,7 @@ import Test.QuickCheck (Arbitrary(..), Gen, Positive(..)) import Cube (Cube(Cube), find_containing_tetrahedra) import FunctionValues import Point (Point) +import ScaleFactor import Tetrahedron (polynomial) import Values (Values3D, dims, empty3d, zoom_shape) @@ -114,26 +115,25 @@ find_containing_cube g p = {-# INLINE zoom_lookup #-} -zoom_lookup :: Grid -> Int -> a -> (R.DIM3 -> Double) +zoom_lookup :: Grid -> ScaleFactor -> a -> (R.DIM3 -> Double) zoom_lookup g scale_factor _ = zoom_result g scale_factor {-# INLINE zoom_result #-} -zoom_result :: Grid -> Int -> R.DIM3 -> Double -zoom_result g scale_factor (R.Z R.:. i R.:. j R.:. k) = +zoom_result :: Grid -> ScaleFactor -> R.DIM3 -> Double +zoom_result g (sfx, sfy, sfz) (R.Z R.:. i R.:. j R.:. k) = f p where - sf = fromIntegral scale_factor - i' = fromIntegral i / sf - j' = fromIntegral j / sf - k' = fromIntegral k / sf + i' = (fromIntegral i) / (fromIntegral sfx) + j' = (fromIntegral j) / (fromIntegral sfy) + k' = (fromIntegral k) / (fromIntegral sfz) p = (i', j', k') :: Point c = find_containing_cube g p t = head (find_containing_tetrahedra c p) f = polynomial t -zoom :: Grid -> Int -> Values3D +zoom :: Grid -> ScaleFactor -> Values3D zoom g scale_factor | xsize == 0 || ysize == 0 || zsize == 0 = empty3d | otherwise =