Ray#

class Ray(origin, direction, intensity: float = 1.0, wavelength=None, length=None, alive=True, qo=None, w0=None, **kwargs)[source]#

Bases: Vector

Geometric ray object, with Gaussian beam parameters.

__init__(origin, direction, intensity: float = 1.0, wavelength=None, length=None, alive=True, qo=None, w0=None, **kwargs)[source]#

Initialize a ray.

Parameters:
  • origin – Ray origin in lab coordinates.

  • direction – Propagation direction (normalized internally).

  • intensity – Relative ray intensity.

  • wavelength – Wavelength in model units.

  • length – Optional finite rendering/segment length.

  • alive – If False, ray is ignored in interaction steps.

  • qo – Optional Gaussian beam complex q at origin.

  • w0 – Optional beam waist radius used to derive qo.

property direction: ndarray#

Unit propagation direction vector.

property n: float#

Return refractive index function.

property transform_matrix: ndarray#

Return rotation matrix mapping local ray frame to lab frame.

property tangent_1: ndarray#

Return unit tangent vector 1 orthogonal to propagation.

property tangent_2: ndarray#

Return unit tangent vector 2 orthogonal to propagation.

pathlength(t: float = 0) float[source]#

Return accumulated optical path length at parameter t.

phase(t: float = 0) float[source]#

Return optical phase modulo 2*pi at parameter t.

q_at_waist(w0: float | ndarray)[source]#

Return Gaussian q at waist.

q_at_z(z: float | ndarray)[source]#

Return Gaussian q after propagation distance z.

distance_to_waist(q: complex | ndarray)[source]#

Return distance from given q plane to waist plane.

waist(q: complex | ndarray)[source]#

Return waist radius implied by q for this wavelength/index.

rayleigh_range(q: complex | ndarray)[source]#

Return Rayleigh range from q.

radius_of_curvature(q: complex | ndarray)[source]#

Return wavefront curvature radius from q.

spot_size(z: float | ndarray)[source]#

Return spot size at propagation distance z.

Propagate(z) Ray[source]#

Return a copied ray which is the current ray propagated by distance z.

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

Render the ray.

Parameters:
  • ax – Matplotlib axis to render on.

  • type – “Z” for 2D rendering xOy plane, “3D” for 3D rendering.

  • **kwargs – Additional rendering options. - color: (default “black”) Color of the ray. - physical_color: (default False) If True, color is based on wavelength. - linewidth: (default 0.5) Width of the ray line. - linestyle: (default “-”) Style of the ray line. - ray_arrow: (default False) If True, draw an arrow indicating direction. - gaussian_beam: (default False) If True, render Gaussian beam envelope. - detailed_render: (default False) If True, render detailed Gaussian beam contours. - render_line: (default True) If True, render the ray line. - arrow: (default False) If True, draw an arrow indicating direction in 3D. - spot_size_scale: (default 1.0) Scale factor for the Gaussian beam spot size. - annote_waist: (default False) If True, annotate the waist position.

Returns:

The ray is rendered on the provided axis.

Return type:

None