From f254406fe7a0b4a66a9d2fb96801e32594398d46 Mon Sep 17 00:00:00 2001 From: Matthias Braendli Date: Wed, 4 Dec 2013 13:03:21 +0100 Subject: add MIT license --- raytracer.hs | 35 +++++++++++++++++++++++++++++++---- 1 file 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 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 -- cgit v1.2.3