Description Decomposes a wavefront into Zernike polynomials.
Syntax DecomposeWavefrontToZernikes CoordSys, Ana, Wavefront, X0, Y0, Z0, ASemiAp, BSemiAp, MaxTermNum, Coeffs
Parameters CoordSys As Long Node number of the entity in whose coordinate system the Wavefront was calculated.
Ana As T_ANALYSIS T_ANALYSIS structure, expressed in CoordSys. If the LoadAnalysis command is used, the T_ANALYSIS structure is expressed in the Global Coordinate System (specified as -1). In this case, CoordSys should have a value of -1.
Wavefront() As Double This array must have the same dimensions as the number of samples in the T_ANALYSIS structure and contains the wavefront data in units of waves. This array will generally be the result of the Wavefront script command.
X0 As Double x-coordinate of the origin about which the Zernikes are calculated. This value is specified in the coordinate system of CoordSys.
Y0 As Double y-coordinate of origin about which the Zernikes are calculated. This value is specified in the coordinate system of CoordSys.
Z0 As Double z-coordinate of origin about which the Zernikes are calculated. This value is specified in the coordinate system of CoordSys and projected along the normal of the T_ANALYSIS grid to the T_ANALYSIS plane.
ASemiAp As Double Semi-aperture along the A-axis of the T_ANALYSIS structure over which Zernikes are calculated.
BSemiAp (Double) Semi-aperture along the B-axis of the T_ANALYSIS structure over which Zernikes are calculated.
MaxTermNum (Long) Maximum Zernike term number.
Coeffs (Double Array) Array holding Zernike coefficients.
Example The example below demonstrates how to use DecomposeWavefrontToZernikes after populating an array of wavefront data. The resulting coefficients of the decomposition are then reported to the output window.
Sub Main
Dim ana As Long, det As Long ana = FindFullName( "Analysis Surface(s).Wavefront Detector" ) det = FindFullName( "Geometry.Detector.Surface" )
'Populate the analysis grid structure Dim tAna As T_ANALYSIS LoadAnalysis( ana, tAna )
'Retreive the complex field data Dim reals() As Double, imags() As Double ScalarField( det, -1, tAna, reals(), imags() )
'Unwrap the wavefront data Dim wf() As Double Wavefront( reals(), imags(), wf() )
'Wavefront analysis and decomposition Dim maxCoef As Long, curCoef As Long Dim coefs() As Double, xcen As Double, ycen As Double, zcen As Double Dim xsemi As Double, ysemi As Double Dim isWaves As Boolean Dim zstring As String isWaves = True maxCoef = 15 xsemi = 10 ysemi = 10 DecomposeWavefrontToZernikes( -1, tAna, wf(), xcen, ycen, zcen, xsemi, ysemi, maxCoef, coefs() )
'Report the zernike coefficients Print "" Print "Zernike decomposition result:" 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
End Sub
See Also
|