Scene

giant.ray_tracer.scene:

class giant.ray_tracer.scene.Scene(target_objs=None, light_obj=None, obscuring_objs=None)[source]

This is a container for SceneObject instances that provides an easy interface for tracing and rendering.

This is most useful when you have multiple objects that you want to trace at once, as the scene will trace all of the objects for you, and choose the first intersection for each ray between all of the objects (if desired).

This is also useful because it can calculate the apparent location of objects in the scene (if they have the position_function and orientation_function attributes defined) while applying corrections for light time and stellar aberration. This can be done for all objects in a scene using method update() or for individual object using calculate_apparent_position(). Any objects that do not define the mentioned attributes will likely not be placed correctly in the scene when using these methods and thus warnings will be printed.

Parameters:
  • target_objs (List[SceneObject] | SceneObject | None) – The objects that are to be traced/rendered in a scene as a list of SceneObject.

  • light_obj (SceneObject | None) – The light object. This is just used to track the position of the light, therefore it is typically just a wrapper around a Point

  • obscuring_objs (List[SceneObject] | None) – A list of objects that shouldn’t be rendered but may be used externally from the scene to identify whether targets are visible or not.

order: int

The number of digits that are required to represent the unique id of all objects contained in the scene

This is used to comprise the facet number in the INTERSECT_DTYPE when tracing the scene such that the resulting id is

[-target index-][---surface id---]
                [------order-----]

where target index is the index into the target_objs list, surface id is the ID returned by the surface that the ray struck encoded in order digits (zero padded on the left). This is also used when tracing to determine whether the Rays.ignore attribute applies to the object currently being traced.

Typically users shouldn’t need to worry about this too much since it is primarily handled entirely internal to the class

property target_objs: List[SceneObject] | None

A list of objects to be tracked/rendered in the scene.

This must be set before a call to get_illumination_inputs()

property obscuring_objs: List[SceneObject] | None

A list of objects to be kept up to date with the scene but which are not actually used in the scene

property light_obj: SceneObject | None

An object describing the location of the light source in the scene.

This must be set before a call to get_illumination_inputs()

Summary of Methods

calculate_apparent_position

This method calculates the apparent position of objects in the scene in the camera frame optionally correcting for "LT" (light time), "S" (stellar aberration", or "LTPS" (light time and aberration).

get_first

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

get_illumination_inputs

This method returns the required inputs for an illumination function to compute the illumination for each ray.

phase_angle

This method computes the phase angle between the observer, the target at target_index and the light_obj.

raster_render

Computes the geometry for rendering a target using rasterization, not ray tracing.

trace

Trace trace_rays through the current scene and return the intersections with the objects in the scene for each ray (optionally only the first intersection for each ray).

update

This method changes the scene to reflect the time specified by image optionally using corrections of "LT" (light time), "S" (stellar aberration", or "LTPS" (light time and aberration).