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 withnan
components are returned for rays that do not have intersections- Parameters
- Returns
(
tuple
) - Reflected or refracted rays after one iteration of ray tracing (Rays
) - Times at which the rays intersect the closest object to them andnan
for rays that have nointersection (
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 scenescene
until the maximum number of bouncesmax_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 notNone
) as they traverse the scene (mpl_toolkits.mplot3d.axes3d.Axes3D
). Default isNone
- 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 scenescene
until the maximum number of bouncesmax_iterations
is reached, or until the rays hit the light sourcelight_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)