%%HP: T(3)A(R)F(.);
@ FRESNEL by Nelson W. Wallace
DIR
  MAIN
    \<< -40 CF 1 CF 2
CF 3 CF RCLMENU
'MNU' STO CLLCD
"MAIN N.Wallace 8/27/91

 Fresnel diffraction
from an aperture, an
 obstruction, or an
       edge?"
1 DISP { { APERTURE
} { } { OBSTRUCTION
} { } { } { EDGE }
} MENU -1 WAIT 'KB'
STO CLLCD
      IF 'KB\>=15.1'
      THEN
"edge input:" {
":s1min:
:s1max:" {
1 0 } } INPUT OBJ\->
DTAG SWAP DTAG SWAP
XRNG 's1' INDEP 3
SF
      ELSE
"aperture/obstr input"
{
":\GDv:   
:s0min: 
:s0max: "
{ 1 0 } } INPUT
OBJ\-> DTAG SWAP DTAG
SWAP XRNG DTAG '\GDv'
STO 's0' INDEP
        IF 'KB\<=12.1
'
        THEN 1 SF
        ELSE 2 SF
        END
      END CLLCD
      IF 1 FS?
      THEN
'GENERAL'
      END
      IF 2 FS?
      THEN
'OBSTRUCTION'
      END
      IF 3 FS?
      THEN 'EDGE'
      END DUP \->STR
1 DISP 2 WAIT STEQ
'MNU' RCL MENU {
MNU KB } PURGE -.1
3.3 YRNG ERASE DRAW
1 CF 2 CF 3 CF
    \>>
  GENERAL
    \<<
"Gen Fresnel Diffr."
DROP RAD 's0-\GDv/2'
EVAL 's1' STO 's0+
\GDv/2' EVAL 's2' STO
'C(s2)-C(s1)+i*(S(
s2)-S(s1))' EVAL
ABS SQ
    \>>
  EDGE
    \<<
"Edge Fresnel Diffr."
DROP RAD 'C(s1)+.5+
i*(S(s1)+.5)' EVAL
ABS SQ
    \>>
  OBSTRUCTION
    \<<
"Shadow Gen Fresnel Diffr."
DROP RAD 's0-\GDv/2'
EVAL 's1' STO 's0+
\GDv/2' EVAL 's2' STO
'C(s2)-C(s1)+i*(S(
s2)-S(s1))' EVAL '\v/
2*EXP(i*\pi/4)' EVAL
SWAP - ABS SQ
    \>>
  S
    \<< \-> v '\.S(0,v,
SIN(\pi*t^2/2),t)'
\->NUM
    \>>
  C
    \<< \-> v '\.S(0,v,
COS(\pi*t^2/2),t)'
\->NUM
    \>>
  XiEQN
    \<< 2 \Gl '1_mm'
CONVERT r20 '1_mm'
CONVERT * / \v/ X '1_
mm' CONVERT * 'Xi'
STO "Xi (or s)" Xi
    \>>
  X '.5_mm'
  \Gl '.5_\Gm'
  r20 '10_cm'
  Xi 3.16227766017
  \GDv 10.1
  s0 1.9
  s1 1.14999999974
  s2 11.2499999997
  t .01
  v 8.2
  CST { { APERTURE
} { } { OBSTRUCTION
} { } { } { EDGE }
}
  IERR
5.82143536203E-12
  EQ GENERAL
  PPAR { (0,-.1)
(6.2,3.3) s0 0
(0,0) FUNCTION Y }
END
