通过光线跟踪分配颜色值

时间:2019-06-03 04:27:39

标签: python matplotlib multidimensional-array

我正在尝试使用光线跟踪创建一个python程序,以基于表面上反射光线的大小为绘图分配颜色值。我已经有一个以[x,y,z]形式计算归一化反射光线的代码。而且,该表面被限制在以原点为中心的2x2三维立方体中。基于从表面到立方体的壁的反射射线的大小,我想分配颜色值以使用matplotlib和Axes3D创建彩色图。有什么帮助!

#light[R_max,R_max,R_max]
for i in range(200):
    for j in range(100):
        #this is the point on the surface that will be used to calculate everything for each loop
        point=[X[i,j],Y[i,j],Z[i,j]]
        incident=[point[0]-initial[0],point[1]-initial[1],point[2]-initial[2]]
        normal=np.zeros(3)
        normal=np.cross([theta_x[i,j],theta_y[i,j],theta_z[i,j]],[phi_x[i,j],phi_y[i,j],phi_z[i,j]])
        if j==0:
            normal=np.array([0,0,1])
        if j==100:
            normal=np.array([0,0,-1])

        proj_normal=normal*np.dot(incident,normal)
        reflected=incident-2*proj_normal
        #this is the normalized reflected ray in [?,?,?] form at the point 
        normalized_reflected=reflected/np.sqrt(reflected[0]**2+reflected[1]**2+reflected[2]**2)

0 个答案:

没有答案