rayoptics.raytr.raytrace module

Functions to support ray tracing a sequential optical model

bend(d_in, normal, n_in, n_out)[source]

refract incoming direction, d_in, about normal

reflect(d_in, normal)[source]

reflect incoming direction, d_in, about normal

phase(ifc, inc_pt, d_in, normal, ifc_cntxt)[source]

apply phase shift to incoming direction, d_in, about normal

trace(seq_model, pt0, dir0, wvl, **kwargs)[source]

fundamental raytrace function

Parameters:
  • seq_model – the sequential model to be traced

  • pt0 – starting point in coords of first interface

  • dir0 – starting direction cosines in coords of first interface

  • wvl – wavelength in nm

  • eps – accuracy tolerance for surface intersection calculation

Returns:

(ray, op_delta, wvl)

  • ray is a list for each interface in path_pkg of these elements: [pt, after_dir, after_dst, normal]

    • pt: the intersection point of the ray

    • after_dir: the ray direction cosine following the interface

    • after_dst: after_dst: the geometric distance to the next interface

    • normal: the surface normal at the intersection point

  • op_delta - optical path wrt equally inclined chords to the optical axis

  • wvl - wavelength (in nm) that the ray was traced in

trace_raw(path, pt0, dir0, wvl, eps=1e-12, check_apertures=False, **kwargs)[source]

fundamental raytrace function

Parameters:
  • path – an iterator containing interfaces and gaps to be traced. for each iteration, the sequence or generator should return a list containing: Intfc, Gap, Trfm, Index, Z_Dir

  • pt0 – starting point in coords of first interface

  • dir0 – starting direction cosines in coords of first interface

  • wvl – wavelength in nm

  • eps – accuracy tolerance for surface intersection calculation

  • check_apertures – if True, do point_inside() test on inc_pt

Returns:

(ray, op_delta, wvl)

  • ray is a list for each interface in path of these elements: [pt, after_dir, after_dst, normal]

    • pt: the intersection point of the ray

    • after_dir: the ray direction cosine following the interface

    • after_dst: the geometric distance to the next interface

    • normal: the surface normal at the intersection point

  • op_delta - optical path wrt equally inclined chords to the optical axis

  • wvl - wavelength (in nm) that the ray was traced in

calc_optical_path(ray, path)[source]

computes equally inclined chords and path info for ray

Parameters:
  • ray – ray data for traced ray

  • path – an iterator containing interfaces and gaps to be traced. for each iteration, the sequence or generator should return a list containing: Intfc, Gap, Trfm, Index, Z_Dir

Returns:

ray_op

  • ray_op - the optical path between the first and last optical surfaces