From: Michael Orlitzky Date: Fri, 6 May 2011 22:10:15 +0000 (-0400) Subject: Add the code to rotate a FunctionValues object. X-Git-Tag: 0.0.1~335 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=cd45e5bb439301e3610d986ece0346a2e7e5c36d;p=spline3.git Add the code to rotate a FunctionValues object. --- diff --git a/src/FunctionValues.hs b/src/FunctionValues.hs index e9ff064..9fd3c78 100644 --- a/src/FunctionValues.hs +++ b/src/FunctionValues.hs @@ -73,7 +73,7 @@ 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 :: [[[Double]]] -> Int -> Int -> Int -> Double value_at values i j k = ((values !! k) !! j) !! i @@ -106,3 +106,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 }