-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDataTypes.hs
54 lines (48 loc) · 1.88 KB
/
DataTypes.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
{-# LANGUAGE DeriveGeneric, DeriveAnyClass #-}
module DataTypes where
import Prelude
import Control.DeepSeq
import GHC.Generics
type Point = Vec3
type Color = Vec3
data Vec3 = Vec3 Double Double Double
deriving (Show, Generic, NFData)
data Vec4 = Vec4 Double Double Double Double
deriving Show
data Vector2 a = Vector2 a a
deriving Show
data Vector3 a = Vector3 a a a
deriving Show
-- Sphere Vec3 (center) Double (radius) Int (np) Int (nf) | Plane Vec4 (coefficients)
data Object = Sphere { getCenter :: Vec3, getRadius :: Double, getNp :: Int, getNf :: Int }
| Plane { getCoef :: Vec4, getNp :: Int, getNf :: Int }
deriving Show
-- Camera Point (camera pos) Point (at point) Vec3 (up Vec3tor) Double (fovy)
data Camera = Camera Point Point Vec3 Double
deriving Show
-- Image Int (width) Int (height)
data Image = Image Int Int
deriving Show
-- Light Point (source) Color (intensity) Vec3c (attenuation)
data Light = Light { getPt :: Point, getCol :: Color, getAtt :: Vec3 }
deriving Show
-- Ray Point (origin) Vec3 (direction)
data Ray = Ray Point Vec3
deriving Show
-- Solid Color (RGB components) | CheckerBoard Color (color1) Color (color2) Double (square size)
data Pigment = Solid Color | CheckerBoard Color Color Double
deriving Show
-- PhongCoef Double (ambient coef) Double (diffuse coef) Double (specular coef) Double (shininess)
data PhongCoef = PhongCoef { getKa :: Double
, getKd :: Double
, getKs :: Double
, getAlpha :: Double
}
deriving Show
-- Surface PhongCoef Double (reflectivity coef) Double (transmission coef) Double (index of refraction)
data Surface = Surface { getPhongCoef :: PhongCoef
, getKr :: Double
, getKt :: Double
, getKi :: Double
}
deriving Show