OpticalRayTracing.LensType
Lens(surfaces::AbstractMatrix)

Construct a lens from a 3 column surface matrix where the first column corresponds to the radii of curvature, the second column to the thicknesses, and the third to the refractive indices.

The computed result wraps a two column lens matrix where the first column refers to the reduced thickness τ = t / n of the distance prior to the surface and the second column refers to the surface power.

julia> Lens([
           Inf 0.0 1.0 # object space
           50.0 3.0 1.5
           -50.0 0.0 1.0
       ])
2×2 Lens:
 0.0  0.01
 2.0  0.01

Lens(M, n)

Construct a lens directly from a two column lens matrix M containing the reduced thicknesses and surface powers corresponding to a refractive index vector n.

julia> Lens([0.0 0.01; 2.0 0.01], [1.0, 1.5, 1.0])
2×2 Lens:
 0.0  0.01
 2.0  0.01

See also: compute_surfaces.

source
OpticalRayTracing.SAFunction
SA(y::Vector, ε::Vector, degree::Int)

Fits spherical aberration transverse ray errors to a polynomial of the given degree using linear least squares. y & ε are the XP heights and ray errors returned by TSA. The returned vector corresponds to the coefficients for a tangential ray aberration expansion of the form: ε = By³ + Cy⁵ + Dy⁷ …

source
OpticalRayTracing.TSAFunction
TSA(system, [k_rays::Int])

Computes the transverse ray aberration errors for spherical aberration using a real ray trace. k_rays controls how many rays are plotted. Returns vectors with the ray heights at the exit pupil and the ray errors at the paraxial plane.

See also: SA, caustic, raytrace.

source
OpticalRayTracing.aberrationsFunction
aberrations(system, [λ], [δn])

Compute the third order wavefront error coefficients based on Seidel sums for a given system or ray basis. Results are in waves at the d-line by default. The dispersion vector δn allows calculation of chromatic aberration.

The returned Aberration type holds the system totals in the WIJK fields (e.g. W040) while the per surface contributions are held in the long form fields (e.g. spherical).

The coefficients assume a positive valued field.

source
OpticalRayTracing.compute_surfacesFunction
compute_surfaces(lens::Lens)

Compute the surface matrix from a given Lens.

julia> compute_surfaces(Lens([0.0 0.01; 2.0 0.01], [1.0, 1.5, 1.0]))
3×3 Matrix{Float64}:
  Inf   0.0  1.0
  50.0  3.0  1.5
 -50.0  0.0  1.0

See also: Lens.

source
OpticalRayTracing.field_curvesFunction
field_curves(W::Aberration; k = k, kwargs...)

Plot the third order longitudinal astigmatic field curves. Requires using a Makie backend. k controls the discretization / number of plot elements.

H on the plot refers to the normalized field parameter.

P, T, & S on the plot refer to the Petzval field, the Tangential field, and the Sagittal field.

See also: percent_distortion, rayfan, spot_diagram, wavefan.

source
OpticalRayTracing.full_traceFunction
full_trace(system, H, [k_rays], [focus] = BFD)
full_trace(surfaces, ray_basis)

Sample the pupil using real rays to compute the transverse ray errors at the focus position along with the RMS spot size. Returns a RealRayError holding the x & y ray error vectors along with the corresponding r & t pupil polar coordinates.

The RMS spot size is computed from the centroid rather than the chief ray.

H is the normalized field parameter while k_rays refers to the number of rays.

See also: raytrace, wavegrad.

source
OpticalRayTracing.incidencesFunction
incidences(system)

Compute the paraxial incidence angles over the system. Returns a four column matrix with the first two columns referring to the optical angles ni & for the marginal & chief ray, respectively, and the last two columns referring to the physical angles i, ī.

source
OpticalRayTracing.optimizeFunction
optimize(system, v, constraints, [aberr], [weights])

Optimize an optical system such that the surface layout over the indices v minimizes the weighted aberrations provided in aberr subject to the given constraints.

See also: solve.

source
OpticalRayTracing.rayfanFunction
rayfan(W::Aberration; k = k, kwargs...)

Plot the third order ray intercept curves for the given system of aberrations. Requires using a Makie backend. k controls the discretization / number of plot elements.

H on the plot refers to the normalized field parameter and can be adjusted with a slider.

See also: field_curves, percent_distortion, spot_diagram, wavefan.

source
OpticalRayTracing.rayplotFunction
rayplot(system)
rayplot(surfaces, ray_basis)

Plots the given system or ray bundle using Makie; requires installation of a Makie backend such as GLMakie.

See also: rayplot!.

source
OpticalRayTracing.raypointsFunction
raypoints(marginal::ParaxialRay{Marginal}, chief::ParaxialRay{Chief})

Return the coordinates for the given ray basis; useful for manual plotting.

source
OpticalRayTracing.raytraceFunction
raytrace(surfaces, y, ω, [a]; clip = false)
raytrace(lens::Lens, y, ω)

Trace a paraxial ray with height y and angle / slope ω = nu returning a ParaxialRay{Tangential} holding the ynu matrix.

If a set of aperture semi-diameters a is specified and clip = true any blocked ray will result in NaN in the trace matrix.


raytrace(system::System, ȳ, s)

Trace the paraxial marginal and chief ray through a given system for a given object height and distance from the objective; these are signed quantities.

See also: solve, incidences.


raytrace(surfaces::AbstractMatrix, y, U, ::Type{RealRay})

Trace a real ray through the surfaces with initial height y and initial angle U.


raytrace(surfaces::AbstractMatrix, y, x, U, V, ::Type{Vector{RealRay}})

Trace a real ray through the lens in three dimensions. U refers to the angle the ray makes with the optical z-axis in the y-direction and V to the angle it makes with the z-axis in the x-direction.

This method returns a two-tuple of vectors holding the x and y coordinates at each surface.

See also: trace_marginal_ray, full_trace.

source
OpticalRayTracing.reverse_transferFunction
reverse_transfer(M::TransferMatrix, v::Vector, τ′, τ)

Transfer an input [y, nu] vector in the reverse direction, extending by image & object space distances τ′, τ.

See also: transfer.

source
OpticalRayTracing.solveFunction
solve(surfaces::Matrix, a::Vector, h′::Float64)
solve(layout::Layout, a, h′)
solve(lens::Lens, a, h′)

Solve a lens, returning a System holding the relevant properties. a denotes the clear aperture semi-diameters while h′ indicates the image height.

Fields are:

  • f: effective focal length;
  • EBFD: effective back focal distance;
  • EFFD: effective front focal distance;
  • N: f-number;
  • FOV: full field of view in degrees;
  • stop: surface matrix index denoting the aperture stop;
  • EP: entrance pupil containing fields: D: diameter, t: distance from the front vertex;
  • XP: exit pupil containing fields: D: diameter, t: distance from the back vertex;
  • marginal: marginal ray;
  • chief: chief ray;
  • trace: the full yu ray trace for the marginal & chief rays;
  • H: Lagrange invariant;
  • P1: front principal plane location w.r.t the front vertex;
  • P2: back principal plane location w.r.t the back vertex;
  • PN: nodal point shift from the principal points;
  • M: the vertex matrix;
  • lens: Lens of the system;
  • layout: the surface layout / prescription if specified.

See also: raytrace, incidences.

source
OpticalRayTracing.vignettingFunction
vignetting(system, [a = system.a])

Perform a vignetting analysis on the System for the given aperture sizes.

Determines the maximum FOVs corresponding to those sizes as well as returning a Vignetting data structure holding a semi-diameter matrix in its M field with columns corresponding to conditions:

  • input;
  • stop limited;
  • unvignetted;
  • half-vignetted;
  • fully vignetted.

The fields of view are stored in the FOV field with rows corresponding to the unvignetted, half-vignetted, and fully vignetted cases and the columns corresponding to the full fields of view in degrees, paraxial chief ray slopes, and image heights, respectively.

system can also be a traced RayBasis corresponding to the marginal & chief rays of a non-collimated beam for an object not at infinity.

source
OpticalRayTracing.wavefanFunction
wavefan(W::Aberration; k = k, kwargs...)

Plot the input aberrations as a a composite wavefront error over the pupil in the tangential and sagittal directions. Requires using a Makie backend. k controls the discretization / number of plot elements.

H on the plot refers to the normalized field parameter and can be adjusted with a slider.

See also: field_curves, percent_distortion, rayfan, spot_diagram.

source