OpTaliX 宏语言
OpTaliX包含宏语言,允许自定义分析和计算。宏语言包括以下领域:
在任何需要数字输入项的地方使用算术表达式。
可以检索程序的内部数据库和能被重复使用的算术表达式,有权访问广泛范围的透镜参数和性能数据。
访问最常用的数学函数(sin, tan, cos, sinh, cosh, cosh, tanh, asin, acos, atan, sqrt, exp, log, log10, logn, besj0, besj1, besjn, abs, min, max, aint, anint)
用户定义的变量和函数。
将参数传递给宏。
在其他宏文件中包含宏,并从基本宏或命令构建复杂任务。
循环结构:DO - ENDDO和WHILE - ENDWHILE
条件结构:IF - ELSE - ELSEIF - ENDIF
文件和数据处理:打开,关闭,读,写/打印。
在OpTaliX中,宏是一个序列,在文件中它是一个算术表达式,可以对数据库项目进行存储。在整个程序中,宏功能都可使用。例如,在命令行中,优化函数的定义和自定义的图像。从指令或者GUI模式中运行宏。
Examples
下面的示例显示了一些宏功能,从上到下不断增加复杂性。名为"mymacro.mac" 的宏被如下命令行执行:
run mymacro.mac 3 0.546
在上面的示例命令中,有两个参数被传递给宏。宏也可以从菜单中执行(运行)。下面是一个宏文件中的一些注释示例条目:
! Example macro | The character ! indicates a comment. This line is not executed. |
$x = 15 |
Defines a user-defined variable and assigns a value. User-defined variables always begin with the $-character. |
@xxx = sqrt($x)+[efl] | Defines a user-defined function. User-defined functions always begin with the @-character. |
res c:\temp\demo.otx | Restores an optical system |
lis ; vie; fan | Multiple commands/expressions can be entered in a single line, separated by semicolons. |
sca sa 2*pi | Use previously defined constants in expressions. This command scales all surfaces (sa) by 2p. |
wl w%1 %2 | Use parameters (%1, %2), which have been passed to the macro from the command line. From the parameters given above, the command translates to: wl w3 0.546 |
print 'Radius of surface 2 is:' [rdy s2] | Retrieve lens parameter or performance parameter and use it in other expressions. Here rdy s2 is the radius on surface 2. |
thi s3 sqrt(2)*[thi s2] | Use lens database items in more complex expressions and assign it to other lens parameter. |
print 'Square root of 2: ' 2*sqrt( & 2) |
Span expressions over several lines. Continuation is defined by the & character. |
do $x = 1,9,2 print $x sqrt($x) enddo |
DO-loop construct. Nesting depth is 20. |
if ($a > 3) then print '$ a is greater than 3' else print '$ a is less than or equal to 3' endif |
IF construct. Nesting depth is 20. |
内部函数
OpTaliX也存在一个广泛的内在函数集,可以在命令行中使用,在宏中,在定义优化约束或指定镜头描述参数:
sin(r) | sine of angle in radians |
cos(r) | cosine of angle in radians |
tan(r) | tangent of angle in radians |
exp(x) | ex |
log(x) | natural logarithm |
log10(x) | common logarithm |
logn(n,x) | logarithm base n |
sqrt(x) | square root |
acos(r) | arccosine |
asin(r) | arcsine |
atan(r) | arctangent |
cosh(r) | hyperbolic cosine |
sinh(r) | hyperbolic sine |
tanh(r) | hyperbolic tangent |
besj0(r) | Bessel function 1st kind, order 0 |
besj1(r) | Bessel function 1st kind, order 1 |
besjn(n,x) | Bessel function 1st kind, order n |
aint(x) | truncate to a whole number |
anint(x) | real representation of the nearest whole number |
abs(x) | absolute value |
min(a,b) | minimum value |
max(a,b) | maximum value |
相关技术文章:
如果您需要了解更多 OpTaliX 软件相关信息,请点击文末“阅读原文”咨询。