From: Michael Orlitzky Date: Fri, 2 Sep 2011 16:41:17 +0000 (-0400) Subject: Fix (I think) the cube offset issue. X-Git-Tag: 0.0.1~174 X-Git-Url: http://gitweb.michael.orlitzky.com/?p=spline3.git;a=commitdiff_plain;h=763af71ab386625469069de1cbbbf52a18f526fe Fix (I think) the cube offset issue. --- diff --git a/src/Grid.hs b/src/Grid.hs index d9fa975..d87114f 100644 --- a/src/Grid.hs +++ b/src/Grid.hs @@ -98,8 +98,8 @@ calculate_containing_cube_coordinate g coord -- Don't use a cube on the boundary if we can help it. This -- returns cube #1 if we would have returned cube #0 and cube #1 -- exists. - | coord == offset && (xsize > 0 && ysize > 0 && zsize > 0) = 1 | coord < offset = 0 + | coord == offset && (xsize > 1 && ysize > 1 && zsize > 1) = 1 | otherwise = (ceiling ( (coord + offset) / cube_width )) - 1 where (xsize, ysize, zsize) = dims (function_values g) @@ -130,9 +130,10 @@ zoom_result :: Grid -> ScaleFactor -> R.DIM3 -> Double zoom_result g (sfx, sfy, sfz) (R.Z R.:. i R.:. j R.:. k) = f p where - i' = (fromIntegral i) / (fromIntegral sfx) - j' = (fromIntegral j) / (fromIntegral sfy) - k' = (fromIntegral k) / (fromIntegral sfz) + offset = (h g)/2 + i' = (fromIntegral i) / (fromIntegral sfx) - offset + j' = (fromIntegral j) / (fromIntegral sfy) - offset + k' = (fromIntegral k) / (fromIntegral sfz) - offset p = (i', j', k') :: Point c = find_containing_cube g p t = find_containing_tetrahedron c p