This commit is contained in:
Yingjie Wang 2023-11-09 20:53:55 -05:00
parent 10e9d6775e
commit f7fb3365d7
3 changed files with 17161 additions and 30648 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*.csv
__pycache__/

47802
rainbow.nb

File diff suppressed because it is too large Load Diff

View File

@ -23,11 +23,11 @@ points = []
def init():
for x in np.linspace(-r + dx, r-dx, N):
stack.append(Ray([x, 2*r], [0,-1], 1))
stack.append(Ray([x, 2*r], [0,-1], 10*np.abs(x)))
print(np.linspace(-r + dx, r-dx, N))
def reflection_and_refraction(ray:Ray, intersection_point, normal, n):
print("reflection/refraction at the point:", intersection_point)
# print("reflection/refraction at the point:", intersection_point)
k_n = np.dot(ray.direction, normal)
if k_n > 0:
n1,n2 = n,1
@ -67,6 +67,7 @@ def trace(disk:Disk, stack:list, max_ray:int):
points.append(np.concatenate((ray.origin, ray.origin+ray.direction,[ray.intensity])))
if direction[1] > 0:
result.append([np.arccos(direction[1]), ray.intensity*direction[1]])
print("ray trace finish, total ray count:",ray_count)
init()
# stack.append(Ray([0.8, 2*r], [0,-1], 1))