-
Notifications
You must be signed in to change notification settings - Fork 0
/
calculator.py
28 lines (20 loc) · 987 Bytes
/
calculator.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
import numpy as np
import brdffunc as b
np.seterr(divide='ignore', invalid='ignore')
def incident(theta_i, phi_i):
return np.array([np.sin(theta_i)*np.cos(phi_i), np.sin(theta_i)*np.cos(phi_i),np.cos(phi_i)])
def view(theta_r, phi_r):
return np.array([np.sin(theta_r)*np.cos(phi_r), np.sin(theta_r)*np.sin(phi_r), np.cos(theta_r)])
def normal():
return np.array([0, 0, 1])
def half(theta_i, phi_i, theta_r, phi_r):
return np.array([(np.sin(theta_i)*np.cos(phi_i)+np.sin(theta_r)*np.cos(phi_r))/2, (np.sin(theta_i)*np.sin(phi_i)+np.sin(theta_r)*np.sin(phi_r))/2, (np.cos(theta_i)+np.cos(theta_r))/2])
def normalize(array):
normalized_v = array/np.linalg.norm(array)
return normalized_v
def delta(half, normal):
return (np.dot(half, normal))/(np.linalg.norm(half)*np.linalg.norm(normal))
def alpha(incident, view):
return np.dot(incident, view)/(2*np.linalg.norm(incident)*np.linalg.norm((view)))
def deg2rad(degree):
return degree * np.pi /180