aboutsummaryrefslogtreecommitdiffstats
path: root/src/Vec.hs
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2019-02-03 13:39:23 +0000
committerYann Herklotz <ymherklotz@gmail.com>2019-02-03 13:39:31 +0000
commitdec2042515df84b0f8ebb611f925efea314da7a0 (patch)
tree906c15b4d77e4e1bb314495f28155484fba5ee61 /src/Vec.hs
parent7fb50745f7f99f8ee4491070661dbbf3f97dec19 (diff)
downloadmirror-ball-dec2042515df84b0f8ebb611f925efea314da7a0.tar.gz
mirror-ball-dec2042515df84b0f8ebb611f925efea314da7a0.zip
Small fixes in the Vec library
Diffstat (limited to 'src/Vec.hs')
-rw-r--r--src/Vec.hs6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/Vec.hs b/src/Vec.hs
index 3f5a839..2e08b46 100644
--- a/src/Vec.hs
+++ b/src/Vec.hs
@@ -34,7 +34,7 @@ instance Functor Sph where
findZ :: (Floating a) => a -> a -> Vec a
findZ x y =
- Vec (x, y, sqrt (1 - x^^2 - y^^2))
+ Vec (x, y, sqrt (1 - x**2 - y**2))
dot :: (Num a) => Vec a -> Vec a -> a
dot (Vec (x1, y1, z1)) (Vec (x2, y2, z2)) =
@@ -59,8 +59,10 @@ toSpherical (Vec (x, y, z))
Sph (acos y, pi / 2)
| z == 0 =
Sph (acos y, - pi / 2)
+ | z < 0 && x >= 0 =
+ Sph (acos y, pi + atan (x / z))
| z < 0 =
- Sph (acos y, signum x * pi + atan (x / z))
+ Sph (acos y, - pi + atan (x / z))
| otherwise =
Sph (acos y, atan (x / z))