-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathray.py
More file actions
19 lines (19 loc) · 838 Bytes
/
ray.py
File metadata and controls
19 lines (19 loc) · 838 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# P2.0 Final project
# REDACTED(I <3 not doxing myself)
# Ray class
from vector3 import Vector3
class Ray:
__slots__ = 'origin', 'direction', 'scattered', 'attenuation', 'time'
def __init__(self, origin: Vector3, direction: Vector3, scattered=False, attenuation=Vector3(0,0,0), time=0):
self.origin = origin
self.time = time
self.direction = direction
self.scattered = scattered
self.attenuation = attenuation
@staticmethod
def CreateNullRay() -> 'Ray':
'''This function is used by materials which do not scatter rays to return a null ray with blank values
and the scattered attribute set to false'''
return Ray(Vector3(0,0,0), Vector3(0,0,0))
def PointAtTime(self, time: float):
return self.origin + Vector3.MultiplyScalar(self.direction, time)