X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FPoint.hs;h=d8b8dd858fba42d443a61069437484278b0ceb3a;hb=16f16e8407c31330f1c29118b06925722da56282;hp=8b720cf193c8a94b2963e4c75f78a194cd8dd87d;hpb=a499efdb0e215ac424fe7c38a52430daebefc22b;p=spline3.git diff --git a/src/Point.hs b/src/Point.hs index 8b720cf..d8b8dd8 100644 --- a/src/Point.hs +++ b/src/Point.hs @@ -6,7 +6,7 @@ module Point ( scale ) where -import Test.Tasty.QuickCheck ( Arbitrary(..) ) +import Test.Tasty.QuickCheck ( Arbitrary( arbitrary ) ) -- | Represents a point in three dimensions. We use a custom type (as @@ -24,7 +24,7 @@ instance Arbitrary Point where instance Num Point where - (Point x1 y1 z1) + (Point x2 y2 z2) = Point (x1+x2) (y1+y2) (z1+z2) + (Point x1 y1 z1) + (Point x2 y2 z2) = Point (x1 + x2) (y1 + y2) (z1 + z2) (Point x1 y1 z1) - (Point x2 y2 z2) = Point (x1-x2) (y1-y2) (z1-z2) (Point x1 y1 z1) * (Point x2 y2 z2) = Point (x1*x2) (y1*y2) (z1*z2) abs (Point x y z) = Point (abs x) (abs y) (abs z) @@ -32,7 +32,7 @@ instance Num Point where fromInteger n = Point coord coord coord where - coord = fromInteger n + coord = fromInteger n :: Double -- | Scale a point by a constant. @@ -44,4 +44,4 @@ scale (Point x y z) d = Point (x*d) (y*d) (z*d) {-# INLINE dot #-} dot :: Point -> Point -> Double dot (Point x1 y1 z1) (Point x2 y2 z2) = - (x2 - x1)^(2::Int) + (y2 - y1)^(2::Int) + (z2 - z1)^(2::Int) + (x2 - x1) ^ (2::Int) + (y2 - y1) ^ (2::Int) + (z2 - z1) ^ (2::Int)