summaryrefslogtreecommitdiffstats
path: root/raytracer.hs
diff options
context:
space:
mode:
authorMatthias Braendli <matthias.braendli@u-blox.com>2013-12-04 13:03:21 +0100
committerMatthias Braendli <matthias.braendli@u-blox.com>2013-12-04 13:03:21 +0100
commitf254406fe7a0b4a66a9d2fb96801e32594398d46 (patch)
tree936169e9c3d505f34caf9083542ffcad0ff8561d /raytracer.hs
parenta515b2adda5c93da698cda7315de57ecc535c898 (diff)
downloadhaskell-f254406fe7a0b4a66a9d2fb96801e32594398d46.tar.gz
haskell-f254406fe7a0b4a66a9d2fb96801e32594398d46.tar.bz2
haskell-f254406fe7a0b4a66a9d2fb96801e32594398d46.zip
add MIT license
Diffstat (limited to 'raytracer.hs')
-rw-r--r--raytracer.hs35
1 files changed, 31 insertions, 4 deletions
diff --git a/raytracer.hs b/raytracer.hs
index 0ade439..63489a3 100644
--- a/raytracer.hs
+++ b/raytracer.hs
@@ -1,15 +1,42 @@
+-- An ugly raytracer in Haskell
+-- ****************************
+--
+-- Written as an excuse to learn Haskell, and as a refresher for 3d geometry concepts.
+--
+-- The MIT License (MIT)
+--
+-- Copyright (c) 2013 Matthias P. Braendli
+--
+-- Permission is hereby granted, free of charge, to any person obtaining a copy
+-- of this software and associated documentation files (the "Software"), to deal
+-- in the Software without restriction, including without limitation the rights
+-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+-- copies of the Software, and to permit persons to whom the Software is
+-- furnished to do so, subject to the following conditions:
+--
+-- The above copyright notice and this permission notice shall be included in all
+-- copies or substantial portions of the Software.
+--
+-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+-- SOFTWARE.
import System.IO
import Data.Char
import Debug.Trace
--- ppm image file
--- P3 width height maxcolorval r g b r g b r g b ...
+
+-- ppm image file format:
+-- P3 <width> <height> <maxcolorval> r g b\nr g b\nr g b\n...
-- max line length: 70
type Angle = Double
type Direction = (Angle, Angle) -- azimut, inclination
-type Color = (Int, Int, Int)
-type Coord = (Double, Double, Double)
+type Color = (Int, Int, Int) -- red green blue
+type Coord = (Double, Double, Double) -- x, y, z (x and y on floor, z up)
data Sphere = Sphere Coord Double Color deriving (Show, Eq)
degrees = pi / 180