This repository has been archived by the owner on Nov 23, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
data.py
103 lines (96 loc) · 2.83 KB
/
data.py
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import utility
class Point(object):
def __init__(self, x,y,z):
self.x = x
self.y = y
self.z = z
def __eq__(self,other):
if (utility.epsilon_equal(self.x,other.x)
& utility.epsilon_equal(self.y,other.y)
& utility.epsilon_equal(self.z,other.z)):
return True
else :
return False
class Vector(object):
def __init__(self, x,y,z):
self.x = x
self.y = y
self.z = z
def __eq__(self,other):
if (utility.epsilon_equal(self.x,other.x)
& utility.epsilon_equal(self.y,other.y)
& utility.epsilon_equal(self.z,other.z)):
return True
else :
return False
class Ray(object):
def __init__(self, pt,dir):
self.pt = pt
self.dir = dir
def __eq__(self,other):
if (utility.epsilon_equal(self.pt.x,other.pt.x)
& utility.epsilon_equal(self.pt.y,other.pt.y)
& utility.epsilon_equal(self.pt.z,other.pt.z)
& utility.epsilon_equal(self.dir.x,other.dir.x)
& utility.epsilon_equal(self.dir.y,other.dir.y)
& utility.epsilon_equal(self.dir.z,other.dir.z)):
return True
else :
return False
class Sphere(object):
def __init__(self,center,radius,color,finish):
self.center = center
self.radius = radius
self.color = color
self.finish = finish
def __eq__(self, other):
if (utility.epsilon_equal(self.center.x,other.center.x)
& utility.epsilon_equal(self.center.y,other.center.y)
& utility.epsilon_equal(self.center.z,other.center.z)
& utility.epsilon_equal(self.radius,other.radius)
& utility.epsilon_equal(self.color,other.color)
& utility.epsilon_equal(self.finish.ambient,other.finish.ambient)
& utility.epsilon_equal(self.finish.diffuse,other.finish.diffuse)):
return True
else :
return False
class Color(object):
def __init__(self,r,g,b):
self.r = r
self.g = g
self.b = b
def __eq__(self, other):
if (utility.epsilon_equal(self.r,other.r)
& utility.epsilon_equal(self.g,other.g)
& utility.epsilon_equal(self.b,other.b)):
return True
else :
return False
class Finish(object):
def __init__(self,ambient,diffuse,specular,roughness):
self.ambient = ambient
self.diffuse = diffuse
self.specular = specular
self.roughness = roughness
def __eq__(self, other):
if (utility.epsilon_equal(self.ambient,other.ambient)
& utility.epsilon_equal(self.diffuse,other.diffuse)
& utility.epsilon_equal(self.specular,other.specular)
& utility.epsilon_equal(self.roughness,other.roughness)):
return True
else :
return False
class Light(object):
def __init__(self,pt,color):
self.pt = pt
self.color = color
def __eq__(self, other):
if (utility.epsilon_equal(self.pt.x,other.pt.x)
& utility.epsilon_equal(self.pt.y,other.pt.y)
& utility.epsilon_equal(self.pt.z,other.pt.z)
& utility.epsilon_equal(self.color.r,other.color.r)
& utility.epsilon_equal(self.color.g,other.color.g)
& utility.epsilon_equal(self.color.b,other.color.b)):
return True
else :
return False