From 2a9adab396ba76158abbcb2435f55211a0b63333 Mon Sep 17 00:00:00 2001 From: Yann Herklotz Grave Date: Wed, 20 Feb 2019 16:50:12 +0000 Subject: Update library and remove unnecessary files --- mirror-ball.cabal | 1 - src/Main.hs | 1 - src/Vec.hs | 76 ------------------------------------------------------- stack.yaml | 2 +- 4 files changed, 1 insertion(+), 79 deletions(-) delete mode 100644 src/Vec.hs diff --git a/mirror-ball.cabal b/mirror-ball.cabal index 314c440..0da2c31 100644 --- a/mirror-ball.cabal +++ b/mirror-ball.cabal @@ -17,7 +17,6 @@ executable mirror-ball hs-source-dirs: src main-is: Main.hs default-language: Haskell2010 - other-modules: Vec ghc-options: -threaded build-depends: base >= 4.7 && < 5 , bytestring >= 0.10.8.2 diff --git a/src/Main.hs b/src/Main.hs index da1ef80..a2fb368 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -9,7 +9,6 @@ import qualified Data.Text as T import Data.Word (Word8) import PFM import System.Directory (createDirectoryIfMissing) -import Vec clamp :: PFMColour -> PPMColour clamp (PFMColour ri gi bi) = diff --git a/src/Vec.hs b/src/Vec.hs deleted file mode 100644 index f23cd8e..0000000 --- a/src/Vec.hs +++ /dev/null @@ -1,76 +0,0 @@ -{-| -Module : Vec -Description : Small Vector module -Copyright : (c) 2019, Yann Herklotz Grave -License : GPL-3 -Maintainer : ymherklotz [at] gmail [dot] com -Stability : experimental -Portability : POSIX - -Small Vector module --} - -module Vec where - -newtype Vec a = Vec { unVec :: (a, a, a) } - deriving (Show) - -instance Functor Vec where - fmap f (Vec (a, b, c)) = Vec (f a, f b, f c) - -instance (Num a) => Num (Vec a) where - (Vec (x1, y1, z1)) + (Vec (x2, y2, z2)) = Vec (x1 + x2, y1 + y2, z1 + z2) - (Vec (x1, y1, z1)) - (Vec (x2, y2, z2)) = Vec (x1 - x2, y1 - y2, z1 - z2) - (Vec (x1, y1, z1)) * (Vec (x2, y2, z2)) = Vec (x1 * x2, y1 * y2, z1 * z2) - abs = fmap abs - signum = fmap signum - fromInteger i = Vec (fromInteger i, 0, 0) - -newtype Sph a = Sph { unSph :: (a, a) } - deriving (Show) - -instance Functor Sph where - fmap f (Sph (a, b)) = Sph (f a, f b) - -findZ :: (RealFloat a) => a -> a -> Vec a -findZ x y = - Vec (x, y, z) - where - sq = sqrt (1 - x**2 - y**2) - z = if isNaN sq then 0 else sq - -dot :: (Num a) => Vec a -> Vec a -> a -dot (Vec (x1, y1, z1)) (Vec (x2, y2, z2)) = - x1 * x2 + y1 * y2 + z1 * z2 - -normalise :: (RealFloat a) => Int -> (Int, Int) -> Vec a -normalise size (y, x) = - findZ (scale x) $ scale y - where - scale a = 2 * fromIntegral a / fromIntegral size - 1 - -reflect :: (RealFloat a) => Int -> Vec a -> (Int, Int) -> Vec a -reflect size v (y, x) = - l - v - where - n = normalise size (y, x) - l = ((2 * dot n v)*) <$> n - -toSpherical :: (Floating a, Eq a, Ord a) => Vec a -> Sph a -toSpherical (Vec (x, y, z)) - | z == 0 && x >= 0 = - 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, - pi + atan (x / z)) - | otherwise = - Sph (acos y, atan (x / z)) - -indexLatLong :: (RealFrac a, Floating a) => Int -> Int -> Sph a -> (Int, Int) -indexLatLong w h (Sph (theta, phi)) = - ( floor $ theta / pi * fromIntegral h - , floor $ ((phi / (2 * pi)) + 0.5) * fromIntegral w - ) diff --git a/stack.yaml b/stack.yaml index 45c8984..da187f0 100644 --- a/stack.yaml +++ b/stack.yaml @@ -39,7 +39,7 @@ packages: # (e.g., acme-missiles-0.3) extra-deps: - git: https://github.com/ymherklotz/pfm.git - commit: c0118f29bcfc1fb7cf61da7260e4fdc2283be241 + commit: 733de0cfaac119c0e1a309014a1da4a3aeaad01d # Override default flag values for local packages and extra-deps # flags: {} -- cgit