Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #TODO ===== BEGIN SOLUTION HERE =====
- tmin = np.inf
- tempEnd = ray.eyePoint + ray.viewDirection
- tempEnd = np.append(tempEnd, [1])
- tempEye = np.array([ray.eyePoint[0], ray.eyePoint[1], ray.eyePoint[2], 1])
- tempDirection = np.array([ray.viewDirection[0], ray.viewDirection[1], ray.viewDirection[2], 1])
- tempEnd = np.dot(tempEnd, self.Minv)
- tempEye = np.dot(tempEye, self.Minv)
- tempDirection = np.dot(tempDirection, self.Minv)
- tempDirection = tempEnd - tempEye
- ray.eyePoint = np.array([tempEye[0], tempEye[1], tempEye[2]])
- ray.viewDirection = np.array([tempDirection[0], tempDirection[1], tempDirection[2]])
- for node in self.children:
- tempSect = node.intersect(ray)
- if (tempSect.t < tmin):
- isect = tempSect
- tmin = isect.t
- tempn = np.array([isect.n[0], isect.n[1], isect.n[2], 1])
- tempp = np.array([isect.p[0], isect.p[1], isect.p[2], 1])
- tempn = np.dot(self.M, tempn)
- tempp = np.dot(self.M, tempp)
- isect.n = GT.normalize(np.array([tempn[0], tempn[1], tempn[2]]))
- isect.p = np.array([tempp[0], tempp[1], tempp[2]])
- # ===== END SOLUTION HERE =====
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement