gradoptics.light_sources.light_source_from_distribution

class gradoptics.light_sources.light_source_from_distribution.LightSourceFromDistribution(distribution, bounding_shape=None)

Bases: gradoptics.light_sources.base_light_source.BaseLightSource

Models a light source from a distribution. It emits rays in 4pi, with their origins sampled from the distribution.

__init__(distribution, bounding_shape=None)
Parameters
  • distribution – Distribution from which photons will be sampled (BaseDistribution)

  • bounding_shape – A bounding shape that bounds the light source (BoundingShape). Default is None

Note

A bounding shape is required if this light source is used with backward ray tracing

sample_rays(nb_rays, device='cpu', sample_in_2pi=False)

Samples rays from the light source

Parameters
  • nb_rays – Number of rays to sample (int)

  • device – The desired device of returned tensor (str). Default is 'cpu'

Returns

Sampled rays (Rays)

plot(ax, **kwargs)

Plots the position of the light source on the provided axes.

Parameters

ax – 3d axes (mpl_toolkits.mplot3d.axes3d.Axes3D)

pdf(x)

Returns the pdf function of the distribution evaluated at x

Warning

The pdf may be unnormalized

Parameters

x – Value where the pdf should be evaluated (torch.tensor)

Returns

The pdf function evaluated at x (torch.tensor)