-- | The Grid module just contains the Grid type and two constructors
-- for it. We hide the main Grid constructor because we don't want
-- to allow instantiation of a grid with h <= 0.
-- | The Grid module just contains the Grid type and two constructors
-- for it. We hide the main Grid constructor because we don't want
-- to allow instantiation of a grid with h <= 0.
import Comparisons ((~=))
import Cube (Cube(Cube),
find_containing_tetrahedron,
import Comparisons ((~=))
import Cube (Cube(Cube),
find_containing_tetrahedron,
tetrahedron)
import Examples (trilinear, trilinear9x9x9, zeros, naturals_1d)
import FunctionValues (make_values, value_at)
tetrahedron)
import Examples (trilinear, trilinear9x9x9, zeros, naturals_1d)
import FunctionValues (make_values, value_at)
import ScaleFactor (ScaleFactor)
import Tetrahedron (Tetrahedron, c, polynomial, v0, v1, v2, v3)
import ThreeDimensional (ThreeDimensional(..))
import ScaleFactor (ScaleFactor)
import Tetrahedron (Tetrahedron, c, polynomial, v0, v1, v2, v3)
import ThreeDimensional (ThreeDimensional(..))
-- centered on that position. If there is no cube there (i.e. the
-- position is outside of the grid), it will throw an error.
cube_at :: Grid -> Int -> Int -> Int -> Cube
-- centered on that position. If there is no cube there (i.e. the
-- position is outside of the grid), it will throw an error.
cube_at :: Grid -> Int -> Int -> Int -> Cube
| i < 0 = error "i < 0 in cube_at"
| i >= xsize = error "i >= xsize in cube_at"
| j < 0 = error "j < 0 in cube_at"
| i < 0 = error "i < 0 in cube_at"
| i >= xsize = error "i >= xsize in cube_at"
| j < 0 = error "j < 0 in cube_at"
-- Since our grid is rectangular, we can figure this out without having
-- to check every cube.
find_containing_cube :: Grid -> Point -> Cube
-- Since our grid is rectangular, we can figure this out without having
-- to check every cube.
find_containing_cube :: Grid -> Point -> Cube
i = calculate_containing_cube_coordinate g x
j = calculate_containing_cube_coordinate g y
k = calculate_containing_cube_coordinate g z
i = calculate_containing_cube_coordinate g x
j = calculate_containing_cube_coordinate g y
k = calculate_containing_cube_coordinate g z
m' = (fromIntegral m) / (fromIntegral sfx) - offset
n' = (fromIntegral n) / (fromIntegral sfy) - offset
o' = (fromIntegral o) / (fromIntegral sfz) - offset
m' = (fromIntegral m) / (fromIntegral sfx) - offset
n' = (fromIntegral n) / (fromIntegral sfy) - offset
o' = (fromIntegral o) / (fromIntegral sfz) - offset
test_trilinear_reproduced :: Assertion
test_trilinear_reproduced =
assertTrue "trilinears are reproduced correctly" $
test_trilinear_reproduced :: Assertion
test_trilinear_reproduced =
assertTrue "trilinears are reproduced correctly" $
test_trilinear9x9x9_reproduced :: Assertion
test_trilinear9x9x9_reproduced =
assertTrue "trilinear 9x9x9 is reproduced correctly" $
test_trilinear9x9x9_reproduced :: Assertion
test_trilinear9x9x9_reproduced =
assertTrue "trilinear 9x9x9 is reproduced correctly" $