summaryrefslogtreecommitdiff
path: root/testsuite/tests/dph/nbody/Util.hs
blob: 5f78802c83ca0ed2d582fc2c022d66d70634e190 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

module Util
        ( magV
        , mulSV
        , normaliseV)
where
        
-- | The magnitude of a vector.
magV :: (Double, Double) -> Double
magV (x, y)     = sqrt (x * x + y * y)
        
-- | Multiply a vector by a scalar.
mulSV :: Double -> (Double, Double) -> (Double, Double)
mulSV s (x, y)  = (s * x, s * y)
        
-- | Normalise a vector, so it has a magnitude of 1.
normaliseV :: (Double, Double) -> (Double, Double)
normaliseV v    = mulSV (1 / magV v) v