From a4db38068b365e04c22a432e07ad07cc66b43ae2 Mon Sep 17 00:00:00 2001 From: Claude Heiland-Allen Date: Mon, 12 Jul 2010 11:00:29 +0100 Subject: [PATCH] explicit export list; comment out unused code --- src/Vector.hs | 47 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/src/Vector.hs b/src/Vector.hs index d2d71fa..a0dbc48 100644 --- a/src/Vector.hs +++ b/src/Vector.hs @@ -16,17 +16,26 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . -} -module Vector where - -import Numeric (showFFloat) +module Vector + ( R + , V(..) + , M(..) + , (^*) + , (^/) + , (^+^) + , (^-^) + , (^|-|^) + , (^^*^) + , (^^*^^) + , translate + , scale + , rotate + ) where type R = Double data V = V !R !R !R deriving (Show, Read, Eq, Ord) data M = M !V !V !V deriving (Show, Read, Eq, Ord) -identity :: M -identity = M (V 1 0 0) (V 0 1 0) (V 0 0 1) - translate :: R -> R -> M translate x y = M (V 1 0 x) (V 0 1 y) (V 0 0 1) @@ -39,13 +48,6 @@ rotate a = M (V c s 0) (V (-s) c 0) (V 0 0 1) s = sin a c = cos a -sumV :: V -> R -sumV (V a b c) = a + b + c - -transposeM :: M -> M -transposeM (M (V a b c) (V d e f) (V g h i)) = - M (V a d g) (V b e h) (V c f i) - (^*) :: V -> R -> V (V a b c) ^* x = V (a*x) (b*x) (c*x) @@ -58,8 +60,13 @@ transposeM (M (V a b c) (V d e f) (V g h i)) = (^-^) :: V -> V -> V (V a b c) ^-^ (V x y z) = V (a-x) (b-y) (c-z) +{- dot :: V -> V -> R (V a b c) `dot` (V x y z) = sumV \$ V (a*x) (b*y) (c*z) +-} + +dot :: V -> V -> R +(V a b c) `dot` (V x y z) = a*x + b*y + c*z {- (^^*^) :: M -> V -> V @@ -89,6 +96,19 @@ dot :: V -> V -> R (^|-|^) :: V -> V -> R u ^|-|^ v = let d = u ^-^ v in sqrt \$ d `dot` d +{- +import Numeric (showFFloat) + +sumV :: V -> R +sumV (V a b c) = a + b + c + +identity :: M +identity = M (V 1 0 0) (V 0 1 0) (V 0 0 1) + +transposeM :: M -> M +transposeM (M (V a b c) (V d e f) (V g h i)) = + M (V a d g) (V b e h) (V c f i) + prettyR :: R -> String prettyR x = (if x < 0 then id else ('+':)) \$ showFFloat (Just 6) x "" @@ -97,3 +117,4 @@ prettyV (V a b c) = unwords . map prettyR \$ [a,b,c] prettyM :: M -> String prettyM (M a b c) = unlines . map prettyV \$ [a,b,c] +-} -- 2.1.4