1 {-# LANGUAGE TypeSynonymInstances #-}
6 type Point = (Double, Double, Double)
8 x_coord :: Point -> Double
11 y_coord :: Point -> Double
14 z_coord :: Point -> Double
17 instance Num Point where
18 p1 + p2 = (x1+x2, y1+y2, z1+z2)
27 p1 - p2 = (x1-x2, y1-y2, z1-z2)
36 p1 * p2 = (x1*x2, y1*y2, z1*z2)
45 abs (x, y, z) = (abs x, abs y, abs z)
46 signum (x, y, z) = (signum x, signum y, signum z)
47 fromInteger n = (fromInteger n, fromInteger n, fromInteger n)
50 scale :: Point -> Double -> Point
51 scale (x, y, z) d = (x*d, y*d, z*d)