Description This subroutine performs a Geometric OPD Map analysis with user-supplied reference sphere curvature and tilt values. Summary information regarding the ray counts and ray path lengths is automatically printed to the output window. Refer to the Geometric OPD Map analysis Help topic for additional information about the calculation. If multiple wavelengths are included in the analysis then the resulting ARN will be multi-slice, with one slice corresponding to the OPD Map result for each unique ray wavelength.
Syntax CalcOPDMapsCurve( anaNode, influence, xcen, ycen, xsemi, ysemi, curv, dx, dy, dz, opdarn )
Parameters anaNode As Long Node number of the analysis surface being used for the Geometric OPD Map calculation.
influence As Double Specified as a fraction of the analysis surface width, this parameter sets a radius value over which adjacent cells can influence each other and has the effect of smoothing or filling-in cells which contain no ray data. The recommended value is 0.04.
xcen As Double Reference aperture center position in X specified in the local coordinate system of anaNode.
ycen As Double Reference aperture center position in Y specified in the local coordinate system of anaNode.
xsemi As Double Reference aperture semi-width in the X axis.
ysemi As Double Reference aperture semi-width in the Y axis.
curv As Double Specifies the reference sphere curvature (1/RadiusOfCurvature).
dx As Double Specifies the x-component of the tilt vector that connects the center of the OPD reference aperture with the center of the reference sphere. The direction vector {dx,dy,dz} is defined in the global coordinate system and does not have to be unit length.
dy As Double Specifies the y-component of the tilt vector that connects the center of the center of the OPD reference aperture with the center of the reference sphere. The direction vector {dx,dy,dz} is defined in the global coordinate system and does not have to be unit length
dz As Double Specifies the z-component of the tilt vector that connects the center of the center of the OPD reference aperture with the center of the reference sphere. The direction vector {dx,dy,dz} is defined in the global coordinate system and does not have to be unit length
opdarn As Long After the subroutine executes, this variable indicates the node number of the ARN where the Geometric OPD Map results are stored. If multiple ray wavelengths were included in the calculation then the resulting ARN will be multi-slice, with one slice corresponding to the OPD Map result for each unique ray wavelength.
Example The example below performs a raytrace followed by a Geometric OPD Map analysis with a reference sphere specified as curvature and tilt. The source is polychromatic and therefore the OPD Map result is stored in a multi-slice ARN. After the OPD Map calculation is performed, the script loops over each slice of the multi-slice ARN, performs a Zernike decomposition on the current monochromatic OPD map, and then prints the decomposition results to the output window.
In this specific example, the OPD map is being calculated in the exit pupil of an imaging lens. The reference sphere curvature and tilt vector can be found by calculating the image centroid (or chief ray intercept) position in the coordinate system of the analysis surface (with the Best Focus analysis) and then extracting the curvature and tilt vector from the best focus position. The length of the position vector defines the reference sphere radius of curvature. Converting the normalized position vector from the coordinate system of the analysis surface into global coordinates gives the tilt vector (if the reference aperture center is offset from the analysis surface origin, this offset needs to be accounted for as well). If the rayset is polychromatic, then the image centroid should be computed for rays of the desired reference wavelength. This procedure can be automated in scripting but is not included in the example below for simplification.
Sub Main
DeleteRays() ARNDeleteAllNodes() TraceCreate()
Dim anaNode As Long anaNode = FindFullName( "Analysis Surface(s).Exit Pupil" )
Dim influence As Double, xcen As Double, ycen As Double Dim xsemi As Double, ysemi As Double, curv As Double Dim dx As Double, dy As Double, dz As Double Dim opdarn As Long influence = 0.04 'Adjacent cell influence as a fraction of analysis surface width xcen = 0 ycen = 0 xsemi = 3.4 ysemi = 3.4 curv = 1/(13.78075062959) 'Tilt vector in global coordinates dx = -0.148434218794242 dy = -0.634755127074867 dz = 0.758322630114065 CalcOPDMapsCurve( anaNode, influence, xcen, ycen, xsemi, ysemi, curv, dx, dy, dz, opdarn )
'Iterate over slices of the OPDmap ARN and decompose Dim nSlices As Long, curSlice As Long, maxCoef As Long, curCoef As Long Dim coefs() As Double Dim isWaves As Boolean Dim zstring As String isWaves = False maxCoef = 15 nSlices = ARNGetSliceCount( opdarn ) For curSlice = 0 To nSlices-1
ARNSetActiveSlice( opdarn, curSlice ) ARNDecomposeToZernikes( opdarn, xcen, ycen, xsemi, ysemi, maxCoef, isWaves, coefs() )
Print "" Print "Zernike decomposition result:" Print "Active slice: " & ARNGetTitle( opdarn ) Print "" & Chr(9) & "Term" & Chr(9) & "Coef (" & If(isWaves,"waves",GetUnits()) & ")" & Chr(9) & "Form" For curCoef = 0 To UBound(coefs) Print Chr(9); Print curCoef; Print coefs(curCoef); Print GetZernikeSurfIthTermText( curCoef ) Next
Next
End Sub
See Also
|