Advertisement
Guest User

Untitled

a guest
Apr 1st, 2015
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. #TODO ===== BEGIN SOLUTION HERE =====
  2.  
  3. tmin = np.inf
  4. tempEnd = ray.eyePoint + ray.viewDirection
  5. tempEnd = np.append(tempEnd, [1])
  6. tempEye = np.array([ray.eyePoint[0], ray.eyePoint[1], ray.eyePoint[2], 1])
  7. tempDirection = np.array([ray.viewDirection[0], ray.viewDirection[1], ray.viewDirection[2], 1])
  8. tempEnd = np.dot(tempEnd, self.Minv)
  9. tempEye = np.dot(tempEye, self.Minv)
  10. tempDirection = np.dot(tempDirection, self.Minv)
  11. tempDirection = tempEnd - tempEye
  12. ray.eyePoint = np.array([tempEye[0], tempEye[1], tempEye[2]])
  13. ray.viewDirection = np.array([tempDirection[0], tempDirection[1], tempDirection[2]])
  14.  
  15. for node in self.children:
  16.  
  17. tempSect = node.intersect(ray)
  18.  
  19. if (tempSect.t < tmin):
  20.  
  21. isect = tempSect
  22. tmin = isect.t
  23.  
  24. tempn = np.array([isect.n[0], isect.n[1], isect.n[2], 1])
  25. tempp = np.array([isect.p[0], isect.p[1], isect.p[2], 1])
  26.  
  27. tempn = np.dot(self.M, tempn)
  28. tempp = np.dot(self.M, tempp)
  29.  
  30. isect.n = GT.normalize(np.array([tempn[0], tempn[1], tempn[2]]))
  31. isect.p = np.array([tempp[0], tempp[1], tempp[2]])
  32.  
  33. # ===== END SOLUTION HERE =====
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement