OpticalComponent#

OpticalComponent#

class OpticalComponent(origin, **kwargs)[source]#

Bases: Vector

Base class for optical elements represented in a local coordinate frame.

__init__(origin, **kwargs)[source]#

Initialize a component at a lab-frame origin.

Parameters:
  • origin – Component origin in lab coordinates.

  • **kwargs – Optional display metadata such as name, label, render_obj, and render_comp_vec.

property normal#

Return the surface normal in lab coordinates.

property tangent_Y#

Return local +Y axis expressed in lab coordinates.

property tangent_Z#

Return local +Z axis expressed in lab coordinates.

get_bbox_local()[source]#
property bbox#

Return cached axis-aligned bounding box in lab coordinates.

get_bbox() tuple[source]#

Compute axis-aligned bounding box in lab frame.

Returns:

Tuple (xmin, xmax, ymin, ymax, zmin, zmax) in lab coordinates.

ray_to_local_coordinates(ray: Ray) Ray[source]#

Transform a ray from lab frame into this component’s local frame.

point_to_lab_coordinates(point_local: ndarray) ndarray[source]#

Transform a point from local frame back to the lab frame.

ray_to_lab_coordinates(ray: Ray) Ray[source]#

Transform a ray from local frame back to the lab frame.

get_interact_count(ray_id)[source]#
should_interact(ray_id)[source]#
increase_interact_count(ray_id)[source]#
intersect_point_local(ray: Ray) Tuple[ndarray, float] | Tuple[None, None][source]#

Find first valid intersection with the component in local coordinates.

Parameters:

ray – Input ray already expressed in the component local frame.

Returns:

(P, t) where P is the local intersection point and t is the ray parameter. Returns (None, None) if no valid hit exists.

interact_local(ray: Ray) List[Ray][source]#

Compute outgoing rays in local coordinates.

Subclasses must implement optical behavior using local-frame geometry.

render(ax, type: str, **kwargs)[source]#

Render the component boundary in 2D ("Z") or 3D ("3D").

interact(ray: Ray) Tuple[float, List[Ray]] | Tuple[None, None][source]#

Apply component interaction in local frame and return lab-frame rays.

Parameters:

ray – Input ray in lab coordinates.

Returns:

Tuple (t, rays) where t is the hit distance and rays contains the truncated incoming segment plus newly generated outgoing rays in lab coordinates. Returns (None, None) when no interaction occurs.

patch_block(width, height)[source]#

Create a Block patch sharing this component pose and aperture.

gather_components(avoid_flatten_classname: List = [], ignore_classname: List = []) List[source]#

Return a flattened metadata list for this component hierarchy.

Parameters:
  • avoid_flatten_classname – Class names whose children are not expanded.

  • ignore_classname – Class names excluded from output.

Returns:

A list of serializable dictionaries describing components.