Scene.get_first

giant.ray_tracer.scene:

static Scene.get_first(res, traced_rays)[source]

This static method identifies the first intersection for each ray when there are more than 1 object in the scene.

Each object in the scene is responsible for identifying the first intersection with itself for each ray. The scene is then responsible for identify which object was struck first which is handled by this method.

This method works by considering the intersection for each ray with each object, and then finding the the intersection with the minimum distance between the ray and the camera.

Parameters:
  • res (ndarray) – The first intersection for each ray with each target_objs in the scene as a numpy array with dtype INTERSECT_DTYPE and shape (k,n) where k is len(self.target_objs) and n is the number of rays

  • traced_rays (Rays) – The rays that these results pertain to

Returns:

numpy array of shape (n) with the first intersect for each ray and data type INTERSECT_DTYPE

Return type:

ndarray