gradoptics.ray_tracing.ray_tracing

gradoptics.ray_tracing.ray_tracing.trace_rays(incident_rays, scene)

Performs one iteration of ray tracing, i.e. finds the closest object in the scene each ray will intersect, and computes the reflected or refracted rays. Rays with nan components are returned for rays that do not have intersections

Parameters
  • incident_rays – Batch of incident rays (Rays)

  • scene – Scene in which the rays are travelling (Scene)

Returns

(tuple) - Reflected or refracted rays after one iteration of ray tracing (Rays) - Times at which the rays intersect the closest object to them and nan for rays that have no

intersection (torch.tensor)

  • Boolean tensor that indicates if the incident_rays have been reflected/refracted or no (torch.tensor)

gradoptics.ray_tracing.ray_tracing.forward_ray_tracing(incident_rays, scene, max_iterations=2, ax=None)

Performs forward ray tracing, i.e. computes the path taken by the rays incident_rays in the scene scene until the maximum number of bounces max_iterations is reached, or until the rays hit a sensor

Parameters
  • incident_rays – Rays that should be traced in the scene (Rays)

  • scene – Scene in which the rays are travelling (Scene)

  • max_iterations – Maximum number of bounces in the scene (int)

  • ax – 3d axes in which the rays are plotted (if ax is not None) as they traverse the scene (mpl_toolkits.mplot3d.axes3d.Axes3D). Default is None

gradoptics.ray_tracing.ray_tracing.backward_ray_tracing(incident_rays, scene, light_source, integrator, max_iterations=2)

Performs backward ray tracing, i.e. computes the path taken by the rays incident_rays in the scene scene until the maximum number of bounces max_iterations is reached, or until the rays hit the light source light_source

Parameters
  • incident_rays – Rays that should be traced in the scene (Rays)

  • scene – Scene in which the rays are travelling (Scene)

  • light_source – Light source (BaseLightSource)

  • integrator – An integrator to compute line integrals (BaseIntegrator)

  • max_iterations – Maximum number of bounces in the scene (int)

Returns

the intensity carried by the rays incident_rays (Rays)

gradoptics.ray_tracing.ray_tracing.render_pixels(sensor, lens, scene, light_source, samples_per_pixel, directions_per_sample, px_i, px_j, integrator, device='cpu', max_iterations=3)