X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FFunctionValues.hs;h=e8bdcb8e2d1f294216d38fa24d3b56fcc4cba786;hb=51adbba172ccaa70c4832809de334674a8ba6a0f;hp=e9ff0647f413b3f530757725f3bab382ac33a730;hpb=6fb9ab6b6068870323e996da931fc04c7710e3e4;p=spline3.git diff --git a/src/FunctionValues.hs b/src/FunctionValues.hs index e9ff064..e8bdcb8 100644 --- a/src/FunctionValues.hs +++ b/src/FunctionValues.hs @@ -73,9 +73,15 @@ eval f (Difference x y) = (eval f x) - (eval f y) eval f (Product x y) = (eval f x) * (eval f y) eval f (Quotient x y) = (eval f x) / (eval f y) -value_at :: [[[Double]]] -> Int -> Int -> Int -> Double -value_at values i j k = - ((values !! k) !! j) !! i +value_at :: [[[Double]]] -> Int -> Int -> Int -> Double +value_at values i j k + | i < 0 = 0 + | j < 0 = 0 + | k < 0 = 0 + | length values <= k = 0 + | length (values !! k) <= j = 0 + | length ((values !! k) !! j) <= i = 0 + | otherwise = ((values !! k) !! j) !! i make_values :: [[[Double]]] -> Int -> Int -> Int -> FunctionValues make_values values i j k = @@ -106,3 +112,33 @@ make_values values i j k = back_right_down = value_at values (i+1) (j+1) (k-1), back_right_top = value_at values (i+1) (j+1) (k+1), interior = value_at values i j k } + +rotate :: FunctionValues -> (Cardinal -> Cardinal) -> FunctionValues +rotate fv rotation = + FunctionValues { front = eval fv (rotation F), + back = eval fv (rotation B), + left = eval fv (rotation L), + right = eval fv (rotation R), + down = eval fv (rotation D), + top = eval fv (rotation T), + front_left = eval fv (rotation FL), + front_right = eval fv (rotation FR), + front_down = eval fv (rotation FD), + front_top = eval fv (rotation FT), + back_left = eval fv (rotation BL), + back_right = eval fv (rotation BR), + back_down = eval fv (rotation BD), + back_top = eval fv (rotation BT), + left_down = eval fv (rotation LD), + left_top = eval fv (rotation LT), + right_down = eval fv (rotation RD), + right_top = eval fv (rotation RT), + front_left_down = eval fv (rotation FLD), + front_left_top = eval fv (rotation FLT), + front_right_down = eval fv (rotation FRD), + front_right_top = eval fv (rotation FRT), + back_left_down = eval fv (rotation BLD), + back_left_top = eval fv (rotation BLT), + back_right_down = eval fv (rotation BRD), + back_right_top = eval fv (rotation BRT), + interior = interior fv }