# Distortion Focal Length的定義 (ZPL範例)

• 764 views

    Field Curvature/Distortion分析的文字區塊中Distortion Focal Length的定義
    使用Single Ray Trace驗證
    介紹用ZPL中的PLOT、RAYTRACE指令
    用ZPL簡單的驗證Distortion Focal Length的定義

(請注意波長為2)

Zemax編程語言 (Zemax Programming Language)
ZPL是OpticStudio中編程用的語言，可以讀取軟體中大部分的設計數據，並執行各種分析功能，會把分析結果匯出。語言本身也支援矩陣、迴圈、各種數學函數。詳細內容請到Help文件中閱讀。以下我們僅介紹兩個指令。
RAYTRACE

Hx/Hy代表視場位置
Px/Py代表光瞳位置
Wavelength代表波長編號，對應到波長編輯對話框中的編號
PLOT

PLOT NEW

PLOT TITLE, string
PLOT TITLEX, string
PLOT TITLEY, string

PLOT RANGEX, minx, maxx
PLOT RANGEY, miny, maxy

PLOT CHECK, x_increment, y_increment

PLOT TICK, x_increment, y_increment

PLOT FORMATX, format_string
PLOT FORMATY, format_string

PLOT DATA, x_array, y_array, number_of_points, color, style, options

PLOT GO

! This Macro is designed for Double Gauss 28 degree field.zmx sample
! Define array variables to be plotted
DECLARE x_ang, DOUBLE, 1, 400
DECLARE dis_f, DOUBLE, 1, 400
PI = ACOS(-1)
max_field = MAXF()

! Compute array variables
FORMAT 10.10
FOR j, 1, 400, 1
x_ang(j) = j/400*5
RAYTRACE 0, j/400*5/max_field, 0, 0
dis_f(j) = RAYY(NSUR())/TANG(x_ang(j)/180*PI)
PRINT x_ang(j), ", ", dis_f(j)
NEXT j

! Plot results to the screen using PLOT keywords
title\$ = "Checking focal length"
xtitle\$ = "Object Space Angle (theta)"
ytitle\$ = "Yref / TAN(theta) = focal length"
x_chk = 0.0005
y_chk = 0.0005
x_tick = 0.1
y_tick = 0.01
x_form\$ = "%4.2f"
y_form\$ = "%4.4f"

PLOT NEW                # Initialize a new plot
PLOT RANGEY, 99.24, 99.34
PLOT TITLE, title\$            # Place the title on the plot
PLOT TITLEX, xtitle\$            # Place the x-axis title on the plot
PLOT TITLEY, ytitle\$            # Place the y-axis title on the plot
PLOT CHECK, x_chk, y_chk        # Define the plot symbol sizes
PLOT TICK, x_tick, y_tick        # Define the distance between the x- and y-tick marks
PLOT FORMATX, x_form\$            # Define the formatting for the x- and y-axis numbers
PLOT FORMATY, y_form\$
PLOT DATA, x_ang, dis_f, 400, 1, 1, 1        # using all of the points in the array, using pen color 1 (blue), making the curve dashed type 1, and plotting both a line and symbols 1
PLOT GO                    # Generate the plot

! Release memory associated with array variables
RELEASE x_ang
RELEASE dis_f

! End program
PRINT "End of program."

    此Macro使用迴圈掃描5度以內視場對應到的Yref/TAN(theta)計算結果。
    文字視窗中顯示了原始資料點。可以看到0.05度之前，資料都跟系統計算的相同。
    從圖表中可以看到，如我們所預期的，隨著腳度逼近零，計算結果會逼近一個常數。