Advertisement
Guest User

Untitled

a guest
Mar 29th, 2015
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. #TODO ===== BEGIN SOLUTION HERE =====
  2.  
  3. dirDOTnorm = np.dot(ray.viewDirection, self.normal);
  4.  
  5. if (dirDOTnorm != 0): # If it is not parallel.
  6.  
  7. t = np.dot((np.array([0.,0.,0.]) - ray.eyePoint), self.normal) / dirDOTnorm;
  8.  
  9. if (t > EPS_DISTANCE): # If the t is positive.
  10.  
  11. isect.t = t;
  12. isect.p = ray.eyePoint + t * ray.viewDirection;
  13. isect.n = self.normal;
  14.  
  15. if (self.material2 == None): # If not checkboard.
  16.  
  17. isect.material = self.material;
  18.  
  19. else: # If checkboard.
  20.  
  21. xz = np.ceil(ray.eyePoint + t * ray.viewDirection[0]) + np.ceil(ray.eyePoint + t * ray.viewDirection[2]);
  22.  
  23. if (xz % 2 == 0): # If even.
  24.  
  25. isect.material = self.material;
  26.  
  27. else : # Odd.
  28.  
  29. isect.material = self.material2;
  30.  
  31. # ===== END SOLUTION HERE =====
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement