OpticalComponent#
OpticalComponent#
- class OpticalComponent(origin, **kwargs)[source]#
Bases:
VectorBase 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, andrender_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.
- 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.
- 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)wherePis the local intersection point andtis 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.
- 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)wheretis the hit distance andrayscontains the truncated incoming segment plus newly generated outgoing rays in lab coordinates. Returns(None, None)when no interaction occurs.
- 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.