Complete Reference

This page contains what should be a complete list of all docstrings in the OpticSim module, and its submodule.

Index

OpticSim

OpticSim.AbstractSpectrumType

Each AbstractSpectrum type defines a spectrumSample function which returns a uniformly sampled point from the spectrum of the light source and the power at that wavelength.

source
OpticSim.BSplineCurveType
BSplineCurve{P,S,N,M} <: Spline{P,S,N,M}

N is the spatial dimension of the curve. M is the curve order, i.e., the highest power of the parameterizing variable, u. All curve segments are assumed to be of the same order.

BSplineCurve{P,S,N,M}(knots::KnotVector{S}, controlpoints::AbstractArray{MVector{N,S},1})
source
OpticSim.BezierCurveType
BezierCurve{P,S,N,M} <: Spline{P,S,N,M}

N is the dimension of the curve, M is the curve order

BezierCurve{P,S,N,M}(controlpoints::AbstractArray{<:AbstractArray{S,1},1})
source
OpticSim.PrimitiveType
Primitive{T<:Real}

T is the number type used to represent the primitive, e.g., Float64. Primitives are the basic elements which can be stored in bounding volume hierarchies and include surfaces and CSG objects

Must implement the following:

boundingbox(a::Primitive{T})::BoundingBox{T}
centroid(a::Primitive{T})::SVector{3,T}
source
OpticSim.RayStateType

stores the state of ray generation. Keeps track of ray number so you can have a PointOrigin which emits multiple rays. This can be used in the future to do phase summations on the image plane, since only point sources are perfectly spatially coherent.

source
OpticSim.SourceType

Create an emitter by choosing a type for the spectral distribution, ray origin distribution, ray direction distribution, and angular light power distribution. For example, to create an emitter with uniform spectrum, rays originating on a regular grid, ray directions distributed around a vector v up to a maximum angle θmax, with Lambertian power distribution call the Source construction with these types and arguments:

a = Source{UniformSpectrum,GridOrigin, ConeDistribution, Lambertian}(UniformSpectrum(),GridOrigin(),ConeDistribution(θmax),Lambertian())

source
OpticSim.SplineType
Spline{P<:CurveType,S<:Number,N,M}

M is the curve order, i.e., the highest power of the parameterizing variable, u. P determines the CurveType.

All Spline types must implement:

point(curve,u)

and have field controlpolygon

source
OpticSim.SplineSurfaceType
SplineSurface{P,S,N,M} <: ParametricSurface{S,N}

Curve order, M, is the same in the u and v direction and fixed over all spans. P determines the CurveType.

source
OpticSim.AnnulusMethod
Annulus(innerradius::T, outerradius::T, surfacenormal::SVector{3,T}, centrepoint::SVector{3,T})

Creates a circular aperture in a circle i.e. FiniteStop{T,CircularStopShape,CircularStopShape}.

source
OpticSim.ArizonaEyeMethod
ArizonaEye(::Type{T} = Float64; accommodation::T = 0.0)

The popular Arizona eye model taken from this definition. The accommodation of the eye can be varied in this model. Returns a DataFrame specifying the prescription of the eye model.

source
OpticSim.AsphericLensMethod
AsphericLens(insidematerial, frontvertex, frontradius, frontconic, frontaspherics, backradius, backconic, backaspherics, thickness, semidiameter;  lastmaterial = OpticSim.GlassCat.Air, nextmaterial = OpticSim.GlassCat.Air, frontsurfacereflectance = 0.0, backsurfacereflectance = 0.0, frontdecenter = (0, 0), backdecenter = (0, 0))

Cosntructs a simple cylindrical lens with front and back surfaces with a radius, conic and apsheric terms. The side walls of the lens are absorbing.

source
OpticSim.BoundedCylinderMethod
BoundedCylinder(radius::T, height::T; interface::NullOrFresnel{T} = nullinterface(T)) -> CSGGenerator{T}

Create a cylinder with planar caps on both ends centred at (0, 0, 0) with axis (0, 0, 1).

source
OpticSim.CircleMethod
Circle(radius, [surfacenormal, centrepoint]; interface = nullinterface(T))

Shortcut method to create a circle. The minimal case returns a circle centred at the origin with normal = [0, 0, 1].

source
OpticSim.CircularApertureMethod
CircularAperture(radius::T, surfacenormal::SVector{3,T}, centrepoint::SVector{3,T})

Creates a circular aperture in a plane i.e. InfiniteStop{T,CircularStopShape}.

source
OpticSim.CircularApertureMethod
CircularAperture(radius::T, outerhalfsizeu::T, outerhalfsizev::T, surfacenormal::SVector{3,T}, centrepoint::SVector{3,T}; rotationvec::SVector{3,T} = [0.0, 1.0, 0.0])

Creates a circular aperture in a rectangle i.e. FiniteStop{T,CircularStopShape,RectangularStopShape}. The rotation of the rectangle around its normal is defined by rotationvec. rotationvec×surfacenormal is taken as the vector along the u axis.

source
OpticSim.ConicLensMethod
ConicLens(insidematerial, frontvertex, frontradius, frontconic, backradius, backconic, thickness, semidiameter;  lastmaterial = OpticSim.GlassCat.Air, nextmaterial = OpticSim.GlassCat.Air, frontsurfacereflectance = 0.0, backsurfacereflectance = 0.0, frontdecenter = (0, 0), backdecenter = (0, 0))

Constructs a simple cylindrical lens with front and back surfaces with a radius and conic term. The side walls of the lens are absorbing.

source
OpticSim.CuboidMethod
Cuboid(halfsizex::T, halfsizey::T, halfsizez::T; interface::NullOrFresnel{T} = nullinterface(T)) -> CSGGenerator{T}

Create a cuboid centred at (0, 0, 0).

source
OpticSim.FresnelLensMethod
FresnelLens(insidematerial, frontvertex, radius, thickness, semidiameter, groovedepth; conic = 0.0, aspherics = nothing, outsidematerial = OpticSim.GlassCat.Air)

Create a Fresnel lens as a CSG object, can be concave or convex. Groove positions are found iteratively based on groovedepth. For negative radii the vertex on the central surface is at frontvertex, so the total thickness of the lens is thickness + groovedepth. Aspherics currently not supported.

source
OpticSim.GridFieldMethod
GridField(sys::AxisymmetricOpticalSystem; collimated = true, samples = 20, wavelength = 0.55, sourcepos = (0.0, 0.0, 3.0), sourceangle = 0.0, sourcenum = 0)

Distributes rays over the entrance pupil of the system in a rectangular grid pattern.

source
OpticSim.GridFieldMethod
GridField(semidiameter, pupilpos; collimated = true, samples = 20, wavelength = 0.55, sourcepos = (0.0, 0.0, 3.0), sourceangle = 0.0, sourcenum = 0)

Distributes rays over a circular pupil with half-diameter defined by semidiameter, centred at pupilpos in a rectangular grid pattern. samples is the number of rays on each side of the grid, so there are samples×samples rays in total.

source
OpticSim.HexagonalPrismMethod
HexagonalPrism(side_length::T, visheight::T = 2.0; interface::NullOrFresnel{T} = nullinterface(T)) -> CSGGenerator{T}

Create an infinitely tall hexagonal prism with axis (0, 0, 1), the longer hexagon diameter is along the x axis. For visualization visheight is used, note that this does not fully represent the surface.

source
OpticSim.HexapolarFieldMethod
HexapolarField(sys::AxisymmetricOpticalSystem; collimated = true, samples = 8, wavelength = 0.55, sourcepos = (0.0, 0.0, 3.0), sourceangle = 0.0, sourcenum = 0)

Distributes rays over the entrance pupil of the system in a hexapolar pattern.

source
OpticSim.HexapolarFieldMethod
HexapolarField(semidiameter, pupilpos; collimated = true, samples = 8, wavelength = 0.55, sourcepos = (0.0, 0.0, 3.0), sourceangle = 0.0, sourcenum = 0)

Distributes rays over a circular pupil with half-diameter defined by semidiameter, centred at pupilpos in a hexapolar pattern. samples is the number of rings in the hexapolar pattern, so the number of rays in total is samples * (samples + 1) / 2) * 6 + 1.

source
OpticSim.ModelEyeMethod
ModelEye(assembly::LensAssembly{T}, nsamples::Int = 17; pupil_radius::T = 3.0, detpixels::Int = 1000, transform::RigidBodyTransform{T} = identitytransform(T))

Geometrically accurate model of the human eye focussed at infinity with variable pupil_radius. The eye is added to the provided assembly to create a CSGOpticalSystem with the retina of the eye as the detector.

The eye can be positioned in the scene using the transform argument and the resolution of the detector specified with detpixels. By default the eye is directed along the positive z-axis with the vertex of the cornea at the origin.

nsamples determines the resolution at which accelerated surfaces within the eye are triangulated.

source
OpticSim.RectangularApertureMethod
RectangularAperture(aphalfsizeu::T, aphalfsizev::T, surfacenormal::SVector{3,T}, centrepoint::SVector{3,T}; rotationvec::SVector{3,T} = [0.0, 1.0, 0.0])

Creates a rectangular aperture in a plane i.e. InfiniteStop{T,RectangularStopShape}. The rotation of the rectangle around its normal is defined by rotationvec. rotationvec×surfacenormal is taken as the vector along the u axis.

source
OpticSim.RectangularApertureMethod
RectangularAperture(innerhalfsizeu::T, innerhalfsizev::T, outerhalfsizeu::T, outerhalfsizev::T, surfacenormal::SVector{3,T}, centrepoint::SVector{3,T}; rotationvec::SVector{3,T} = [0.0, 1.0, 0.0])

Creates a rectangular aperture in a rectangle i.e. FiniteStop{T,RectangularStopShape,RectangularStopShape}. The rotation of the rectangle around its normal is defined by rotationvec. rotationvec×surfacenormal is taken as the vector along the u axis.

source
OpticSim.RectangularPrismMethod
RectangularPrism(halfsizex::T, halfsizey::T, visheight::T=2.0; interface::NullOrFresnel{T} = nullinterface(T)) -> CSGGenerator{T}

Create an infinitely tall rectangular prism with axis (0, 0, 1). For visualization visheight is used, note that this does not fully represent the surface.

source
OpticSim.SphericalLensMethod
SphericalLens(insidematerial, frontvertex, frontradius, backradius, thickness, semidiameter;  lastmaterial = OpticSim.GlassCat.Air, nextmaterial = OpticSim.GlassCat.Air, frontsurfacereflectance = 0.0, backsurfacereflectance = 0.0, frontdecenter = (0, 0), backdecenter = (0, 0))

Constructs a simple cylindrical lens with spherical front and back surfaces. The side walls of the lens are absorbing.

source
OpticSim.SpiderMethod
Spider(narms::Int, armwidth::T, radius::T, origin::SVector{3,T} = SVector{3,T}(0.0, 0.0, 0.0), normal::SVector{3,T} = SVector{3,T}(0.0, 0.0, 1.0)) -> Vector{Rectangle{T}}

Creates a 'spider' obscuration with narms rectangular arms evenly spaced around a circle defined by origin and normal. Each arm is a rectangle armwidth×radius.

e.g. for 3 and 4 arms we get:

   |         _|_
  / \         |
source
OpticSim.TriangularPrismMethod
TriangularPrism(side_length::T, visheight::T = 2.0; interface::NullOrFresnel{T} = nullinterface(T)) -> CSGGenerator{T}

Create an infinitely tall triangular prism with axis (0, 0, 1). For visualization visheight is used, note that this does not fully represent the surface.

source
OpticSim.closestintersectionFunction
closestintersection(a::Union{EmptyInterval{T},Interval{T},DisjointUnion{T}}, ignorenull::Bool = true) -> Union{Nothing,Intersection{T,3}}

Returns the closest Intersection from an Interval or DisjointUnion. Ignores intersection with null interfaces if ignorenull is true. Will return nothing if there is no valid intersection.

source
OpticSim.csgdifferenceMethod
csgdifference(a::CSGGenerator{T}, b::CSGGenerator{T}, transform::RigidBodyTransform{T} = identitytransform(T)) -> CSGGenerator{T}

Create a binary node in the CSG tree representing the difference of a and b, essentially a - b. A shortcut method for a and b as ParametricSurfaces is also available.

Difference Image

source
OpticSim.csgintersectionMethod
csgintersection(a::CSGGenerator{T} b::CSGGenerator{T}, transform::RigidBodyTransform{T} = identitytransform(T)) -> CSGGenerator{T}

Create a binary node in the CSG tree representing an intersection between a and b. A shortcut method for a and b as ParametricSurfaces is also available.

Intersect Image

source
OpticSim.csgunionMethod
csgunion(a::CSGGenerator{T}, b::CSGGenerator{T}, transform::RigidBodyTransform{T} = identitytransform(T)) -> CSGGenerator{T}

Create a binary node in the CSG tree representing a union between a and b. A shortcut method for a and b as ParametricSurfaces is also available.

Union Image

source
OpticSim.curvedimensionMethod

spatial dimension of curve represented as an array of coefficients x[i] = ∑Bj(θ)*x[i,j] where Bj(θ) is the curve basis

source
OpticSim.curveorderMethod

highest polynomial power of the curve represented as an array of coefficients x[i] = ∑Bj(θ)*x[i,j] where Bj(θ) is the curve basis

source
OpticSim.detectorimageMethod
detectorimage(system::OpticalSystem{T}) -> HierarchicalImage{D}

Get the detector image of system. D is the datatype of the detector image and is not necessarily the same as the datatype of the system T.

source
OpticSim.directionMethod

Generates a unit vector pointing somewhere within the cone with half angle θmax around direction which is the normal to the emitter surface.

source
OpticSim.distanceMethod
distance(r::Ray{T,N}, point::SVector{N,T}) -> Union{T,Nothing}

Returns distance to the position on the ray closest to point. If t < 0 returns nothing.

source
OpticSim.evaluatecurveMethod

Evaluates a curve defined in the power basis. Curves and moving lines accessed like this: [xi,ci] where xi is the dimension index, and ci is the coefficient index.

source
OpticSim.fresnelMethod
fresnel(nᵢ::T, nₜ::T, sinθᵢ::T, sinθₜ::T) -> Tuple{T,T}

Returns reflectance and tranmission power coefficients according to the Fresnel equations. For geometric ray tracing this coefficient can be used directly to compute intensity on the detector plane. For Huygens phase optics need to take the square root to compute the amplitude. The power of the transmitted and refracted rays may not sum to one because of the area correction applied to the transmitted component. The intensity per area can increase or decrease depending on the indices of refraction.

nᵢ is the RI of the material which the incident ray travels in, nₜ is the RI of the material the transmitted ray travels in. sinθᵢ and sinθₜ are the sin of the angles of incidence and transmission respectively.

source
OpticSim.gendirectionMethod
gendirection(o::GeometricRayGenerator{T}, n::Int) -> SVector{3,T}

Generate directions for rays based on the type of the generator, e.g., randomly within a cone or collimated. n is the index of the point being generated, starting from 0. This has little meaning for random generators, but is important for GridSource.

source
OpticSim.generaterayMethod
generateray(a::PixelSource{T}, n::Int) -> OpticalRay{T,3}

Generates optical rays from all subpixels in the pixel. One ray is generated from each subpixel sequentially before looping back to the start.

source
OpticSim.generaterayMethod
generateray(o::GeometricRayGenerator{T}, n::Int) -> Ray{T,3}

Generate geometric rays distributed according to the type of the generator. n is the index of the point being generated, starting from 0. This has little meaning for random generators, but is important for GridSource, for example.

source
OpticSim.generaterayMethod
generateray(a::BasicDisplayPanel{T}, n::Int) -> OpticalRay{T,3}

Generates optical rays from all pixels in the display. One ray is generated from each pixel sequentially before looping back to the start of the display.

source
OpticSim.generaterayMethod
generateray(o::OpticalRayGenerator{T}, n::Int) -> OpticalRay{T,3}

Generate optical rays distributed according to the type of the generator. n is the index of the point being generated, starting from 0. This has little meaning for random generators, but is important for generators using GridSource or GridRectOriginPoints, for example.

source
OpticSim.generaterayMethod
generateray(a::OpticalSourceArray{T}, n::Int) -> OpticalRay{T,3}

Generates optical rays from all generators in the array. One ray is generated from each element sequentially before looping back to the start of the array.

source
OpticSim.generaterayMethod
generateray(a::OpticalSourceGroup{T}, n::Int) -> OpticalRay{T,3}

Generate optical rays for each source in the group. All rays are generated for the first source, then all for the second source and so on as n increases.

source
OpticSim.genoriginMethod
genorigin(o::RayOriginGenerator{T}, n::Int) -> SVector{3,T}

Generate origin positions for rays based on the type of the generator, e.g., randomly within a rectangle or ellipse. n is the index of the point being generated, starting from 0. This has little meaning for random generators, but is important for HexapolarOriginPoints and GridRectOriginPoints.

source
OpticSim.intersectionsMethod

returns an array of intersection points. Each element in the array is ([x,y,...],alpha,theta) where [x,y,...] is the n-dimensional intersection point, alpha is the line parameter value at the intersection point, and theta is the curve parameter value at the intersection point

source
OpticSim.jacobianMethod
jacobian(surf::ParametricSurface{T,N}, u::T, v::T, P1::SVector{M,T}, P2::SVector{M,T})

Computes Jacobian of f(t,u,v) = ( dot(P1,[surf(u,v),1],P2,[surf(u,v),1]) ). P1, P2 are orthogonal planes that pass through the ray. J = [ ∂f1/∂u ∂f1/∂v ; ∂f2/∂u ∂f2/∂v]

source
OpticSim.leafMethod
leaf(surf::CSGGenerator{T}, transform::RigidBodyTransform{T} = identitytransform(T)) -> CSGGenerator{T}

Create a (pseudo) leaf node from another CSGGenerator, this is useful if you want multiple copies of a premade CSG structure with different transforms, for example in an MLA.

source
OpticSim.leafMethod
leaf(surf::ParametricSurface{T}, transform::RigidBodyTransform{T} = identitytransform(T)) -> CSGGenerator{T}

Create a leaf node from a parametric surface with a given transform.

source
OpticSim.linedimensionMethod

spatial dimension of the moving line represented as an array of coefficients g[i] = ∑Bl(θ)*gl[i,j] where Bl(θ) is the polynomial basis

source
OpticSim.matricesforeigenMethod

movinglines[:,i] is the ith moving line. For li = movinglines[:,i] (dimension+1,lineorder) = size(li). rline[:,1] = pt1 and rline[:,2] = pt2. The line equation is pt1 + alpha*pt2.

source
OpticSim.newtonMethod
newton(surf::ParametricSurface{T,N}, r::AbstractRay{T,N}, startingpoint::SVector{2,T})

Newton iteration to find the precise intersection of a parametric surface with a ray given a starting point (in uv space) on the surface.

source
OpticSim.normalMethod
normal(surf::ParametricSurface{T}, u::T, v::T) -> SVector{3,T}
normal(surf::ParametricSurface{T}, uv::SVector{2,T}) -> SVector{3,T}

Returns the normal to surf at the given uv coordinate.

source
OpticSim.orthogonalitymatrixMethod

returns a matrix expressing the relationship [x(θ) 1]⋅g(θ) = 0. The vectors in the right nullspace of this matrix contain the coefficients of the moving lines gᵢ(θ).

source
OpticSim.pointMethod
point(ray::AbstractRay{T,N}, alpha::T) -> SVector{T, N}

Returns a point on the ray at origin + alpha * direction. Alpha must be >= 0.

source
OpticSim.processintersectionMethod
processintersection(opticalinterface::OpticalInterface{T}, point::SVector{N,T}, normal::SVector{N,T}, incidentray::OpticalRay{T,N}, temperature::T, pressure::T, ::Bool, firstray::Bool = false) -> Tuple{SVector{N,T}, T, T}

Processes an intersection of an OpticalRay with an OpticalInterface, distinct behaviors must be implemented for each subclass of OpticalInterface.

point is the 3D intersection point in global space, normal is the surface normal at the intersection point.

If test is true then the behavior of the ray should be deterministic. firstray indicates that this ray is the first segment of the trace and therefore the origin is not offset.

The values returned are the normalized direction of the ray after the intersection, the instantaneous power of the ray after the intersection and the optical path length of the ray up to the intersection.

nothing is returned if the ray should stop here, in order to obtain the correct intensity on the detector through monte carlo integration nothing should be returned proportionally to create the correct power distribution. i.e. If the interface should modulate power to 76% then 24% of calls to this function should return nothing.

source
OpticSim.randinsolidangleMethod
randinsolidangle(direction::SVector{3,T}, uvec::SVector{3,T}, vvec::SVector{3,T}, θmax::T)

Generates a unit vector pointing somewhere within the cone with half angle θmax around direction. uvec and vvec should be orthogonal to each other and direction.

source
OpticSim.raysampleMethod

raysample is the function that can couple origin and direction generation if necessary. The default function couples them in a simple way but more complex coupling should be possible. For each origin numsamples(a.raydirection) direction samples are taken with identical origin. Then the origin number is incremented. This repeats till all rays have been generated. The origin and direction functions receive an integer indicating the origin or direction number so regular patterns such as rectangular and hexapolar grids can be generated properly.

source
OpticSim.reset!Method
reset!(a::HierarchicalImage{T})

Resets the pixels in the image to zero(T). Do this rather than image .= zero(T) because that will cause every pixel to be accessed, and therefore allocated. For large images this can cause huge memory traffic.

source
OpticSim.rotationMethod
rotation([S::Type], θ::T, ϕ::T, ψ::T) -> RigidBodyTransform{S}

Returns the RigidBodyTransform of type S (default Float64) representing the rotation by θ, ϕ and ψ around the x, y and z axes respectively in radians.

source
OpticSim.rotationdMethod
rotationd([S::Type], θ::T, ϕ::T, ψ::T) -> RigidBodyTransform{S}

Returns the RigidBodyTransform of type S (default Float64) representing the rotation by θ, ϕ and ψ around the x, y and z axes respectively in degrees.

source
OpticSim.rotmatMethod
rotmat([S::Type], θ::T, ϕ::T, ψ::T) -> SMatrix{3,3,S}

Returns the rotation matrix of type S (default Float64) representing the rotation by θ, ϕ and ψ around the x, y and z axes respectively in radians.

source
OpticSim.rotmatbetweenMethod
rotmatbetween([S::Type], a::SVector{3,T}, b::SVector{3,T}) -> SMatrix{3,3,S}

Returns the rotation matrix of type S (default Float64) representing the rotation between vetors a and b.

source
OpticSim.rotmatdMethod
rotmatd([S::Type], θ::T, ϕ::T, ψ::T) -> SMatrix{3,3,S}

Returns the rotation matrix of type S (default Float64) representing the rotation by θ, ϕ and ψ around the x, y and z axes respectively in degrees.

source
OpticSim.samplesurfaceMethod
samplesurface(surf::ParametricSurface{T,N}, samplefunction::Function, numsamples::Int = 30)

Sample a parametric surface on an even numsamples×numsamples grid in UV space with provided function

source
OpticSim.semidiameterMethod
semidiameter(system::AxisymmetricOpticalSystem{T}) -> T

Get the semidiameter of system, that is the semidiameter of the entrance pupil (i.e. first surface) of the system.

source
OpticSim.snellMethod
snell(surfacenormal::AbstractVector{T}, raydirection::AbstractVector{T}, nᵢ::T, nₜ::T) -> Tuple{T,T}

nᵢ is the index of refraction on the incidence side of the interface. nₜ is the index of refraction on the transmission side.

Returns sinθᵢ and sinθₜ according to Snell's law.

source
OpticSim.sum!Method
sum!(a::HierarchicalImage{T}, b::HierarchicalImage{T})

Add the contents of b to a in an efficient way.

source
OpticSim.traceMethod
trace(system::OpticalSystem{T}, ray::OpticalRay{T}; trackrays = nothing, test = false)

Traces system with ray, if test is enabled then fresnel reflections are disabled and the power distribution will not be correct. Returns either a LensTrace if the ray hits the detector or nothing otherwise.

trackrays can be passed an empty vector to accumulate the LensTrace objects at each intersection of ray with a surface in the system.

source
OpticSim.traceMethod
trace(assembly::LensAssembly{T}, r::OpticalRay{T}, temperature::T = 20.0, pressure::T = 1.0; trackrays = nothing, test = false)

Returns the ray as it exits the assembly in the form of a LensTrace object if it hits any element in the assembly, otherwise nothing. Recursive rays are offset by a small amount (RAY_OFFSET) to prevent it from immediately reintersecting the same lens element.

trackrays can be passed an empty vector to accumulate the LensTrace objects at each intersection of ray with a surface in the assembly.

source
OpticSim.traceMethod
trace(system::OpticalSystem{T}, raygenerator::OpticalRayGenerator{T}; printprog = true, test = false)

Traces system with rays generated by raygenerator on a single thread. Optionally the progress can be printed to the REPL. If test is enabled then fresnel reflections are disabled and the power distribution will not be correct. If outpath is specified then the result will be saved to this path.

Returns the detector image of the system.

source
OpticSim.traceMTMethod
traceMT(system::OpticalSystem{T}, raygenerator::OpticalRayGenerator{T}; printprog = true, test = false)

Traces system with rays generated by raygenerator using as many threads as possible. Optionally the progress can be printed to the REPL. If test is enabled then fresnel reflections are disabled and the power distribution will not be correct. If outpath is specified then the result will be saved to this path.

Returns the accumulated detector image from all threads.

source
OpticSim.tracehitsMethod
tracehits(system::OpticalSystem{T}, raygenerator::OpticalRayGenerator{T}; printprog = true, test = false)

Traces system with rays generated by raygenerator on a single thread. Optionally the progress can be printed to the REPL. If test is enabled then fresnel reflections are disabled and the power distribution will not be correct.

Returns a list of LensTraces which hit the detector.

source
OpticSim.tracehitsMTMethod
tracehitsMT(system::OpticalSystem{T}, raygenerator::OpticalRayGenerator{T}; printprog = true, test = false)

Traces system with rays generated by raygenerator using as many threads as possible. Optionally the progress can be printed to the REPL. If test is enabled then fresnel reflections are disabled and the power distribution will not be correct.

Returns a list of LensTraces which hit the detector, accumulated from all threads.

source
OpticSim.triangulateMethod
triangulate(surf::ParametricSurface{S,N}, quads_per_row::Int, extensionu::Bool = false, extensionv::Bool = false, radialu::Bool = false, radialv::Bool = false)

Create an array of triangles representing the parametric surface where vertices are sampled on an even grid in UV space. The surface can be extended by 1% in u and v separately, and specifying either u or v as being radial - i.e. detemining the radius on the surface e.g. rho for zernike - will result in that dimension being sampled using sqwrt so that area of triangles is uniform. The extension will also only apply to the maximum in this case.

source
OpticSim.uvMethod
uv(surf::ParametricSurface{T}, p::SVector{3,T}) -> SVector{2,T}
uv(surf::ParametricSurface{T}, x::T, y::T, z::T) -> SVector{2,T}

Returns the uv coordinate on surf of a point, p, in 3D space. If onsurface(surf, p) is false then the behavior is undefined, it may return an inorrect uv, an invalid uv, NaN or crash.

source
OpticSim.uvrangeMethod
uvrange(s::ParametricSurface)
uvrange(::Type{S}) where {S<:ParametricSurface}

Returns a tuple of the form: ((umin, umax), (vmin, vmax)) specifying the limits of the parameterisation for this surface type. Also implemented for some Surfaces which are not ParametricSurfaces (e.g. Rectangle).

source
OpticSim.uvtopixMethod
uvtopix(surf::Surface{T}, uv::SVector{2,T}, imsize::Tuple{Int,Int}) -> Tuple{Int,Int}

Converts a uvcoordinate on surf to an integer index to a pixel in an image of size imsize. Not implemented on all Surface objects. Used to determine where in the detector image a ray has hit when in intersects the detector surface of an OpticalSystem.

source
OpticSim.αMethod
α(ray::AbstractRay{T,N}, point::SVector{N,T}) -> T

Computes the alpha corresponding to the closest position on the ray to point

source

Zernike

OpticSim.Zernike.OSAtoNMMethod
OSAtoNM(j::Int) -> Tuple{Int, Int}

Convert OSA zernike index j to (N,M) form according to formula J = N * (N + 2) + M.

source
OpticSim.Zernike.δζMethod
δζ(N::Int, M::Int, ρ::T, ϕ::T) -> Tuple{T,T}

Evaluate partial derivatives of Zernike polynomial term $Z_{n}^{m}(\rho, \phi)$.

source
OpticSim.Zernike.ζMethod
ζ(N::Int, M::Int, ρ::T, ϕ::T) -> Tuple{T,T}

Evaluate Zernike polynomial term $Z_{n}^{m}(\rho, \phi)$.

source

QType

OpticSim.QType.SMethod
S(coeffs::SVector{NP1,T}, m::Int x::T) -> T

Evaluates $\sum_{n=0}^{N}c_n^mQ_n^m(x)$ where $c_n^m$ is either an $\alpha$ or $\beta$ QType coefficient and $m \gt 0$.

source
OpticSim.QType.S0Method
S0(coeffs::SVector{NP1,T}, x::T) -> T

Evaluates $\sum_{n=0}^{N}\alpha_n^0Q_n^0(x)$.

source
OpticSim.QType.dS0dxMethod
dS0dx(coeffs::SVector{NP1,T}, x::T) -> T

Evaluates $\frac{\partial}{\partial x}\sum_{n=0}^{N}\alpha_n^0Q_n^0(x)$.

source
OpticSim.QType.dSdxMethod
dSdx(coeffs::SVector{NP1,T}, x::T) -> T

Evaluates $\frac{\partial}{\partial x}\sum_{n=0}^{N}c_n^mQ_n^m(x)$ where $c_n^m$ is either an $\alpha$ or $\beta$ QType coefficient and $m \gt 0$.

source

Chebyshev

OpticSim.Chebyshev.TMethod
T(n::Int, q::R, fast::Bool = true) -> R

Evaluate Chebyshev polynomial of the first kind $T_n(q)$.

fast will use trigonometric definition, rather than the recursive definition which is much faster but slightly less precise.

source
OpticSim.Chebyshev.UMethod
U(n::Int, q::R, fast::Bool = true) -> R

Evaluate Chebyshev polynomial of the second kind $U_n(q)$.

fast will use trigonometric definition, rather than the recursive definition which is much faster but slightly less precise.

source
OpticSim.Chebyshev.dTdqMethod
dTdq(n::Int, q::R, fast::Bool = true) -> R

Evaluate derivative of Chebyshev polynomial of the first kind $\frac{dT_n}{dq}(q)$.

fast will use trigonometric definition, rather than the recursive definition which is much faster but slightly less precise.

source

Examples