DECLARE SUB cartel (ni!,
nt!)
DECLARE SUB grilla (ni!,
nt!)
DECLARE SUB curva (ni,
nt, cod$)
COLOR 15
ni = 1: nt = 1.52
CLS
LOCATE 7, 1
PRINT "
PROGRAM 'FRESNELF'"
PRINT
PRINT
PRINT "Plots the reflectivity"; : COLOR 14: PRINT " TE
"; : COLOR 15
PRINT "and"; : COLOR 11: PRINT " TM "; : COLOR 15:
PRINT "of an interfase between two media of indices"
PRINT "ni and nt with light coming in one and opposite direction
from 0 to 90 degrees."
PRINT "There are shown the Brewster angle ab, the critical angle ac
and the"
PRINT "reflectivity in normal incidence Rn. The default values are
those of Fig. 1.7."
PRINT "To finish put ni or nt = 0."
DO: LOOP WHILE INKEY$ = ""
SCREEN 12
DO
CLS
PRINT "ni=";
ni;
INPUT a$: IF a$ <> "" THEN ni = VAL(a$)
IF ni = 0 THEN END
PRINT "nt="; nt;
INPUT a$: IF a$ <> "" THEN nt = VAL(a$)
IF nt = 0 THEN END
CLS
CALL cartel(ni, nt)
CALL grilla(ni, nt)
cod$ = "te"
CALL curva(ni, nt, cod$)
cod$ = "tm"
CALL curva(ni, nt, cod$)
DO: LOOP WHILE INKEY$ = ""
SWAP ni, nt
CLS
CALL cartel(ni, nt)
CALL grilla(ni, nt)
cod$ = "te"
CALL curva(ni, nt, cod$)
cod$ = "tm"
CALL curva(ni, nt, cod$)
DO: LOOP WHILE INKEY$ = ""
LOOP
SUB cartel (ni, nt)
pi = 4 * ATN(1)
LOCATE 2, 2: PRINT
"ni ="; ni
LOCATE 3, 2: PRINT "nt ="; nt
Rn = ((ni - nt) / (ni +
nt)) ^ 2
LOCATE 4, 2
PRINT "Rn ="; INT(100000 * Rn + .5) / 1000; "%"
x = nt / ni
abr = ATN(x)
abg = abr * 180 / pi
LOCATE 5, 2
PRINT "ab ="; INT(100 * abg + .5) / 100
xl = 640 * abg / 90
LINE (xl, 432)-(xl, 479)
IF x < 1 THEN
acr = ATN((x / SQR(1 - x ^ 2)))
acg = acr * 180 / pi
LOCATE 6, 2
PRINT "ac ="; INT(100 * acg + .5) / 100
END IF
END SUB
SUB curva (ni, nt, cod$)
pi = 4 * ATN(1)
FOR i = 0 TO pi / 2 STEP pi / 640
seni = SIN(i)
cosi = COS(i)
z = (ni * seni / nt) ^ 2
cost = SQR(ABS(1 - z))
IF z >= 1 THEN cost = 0
SELECT CASE cod$
CASE "tm"
r = ((nt * cosi - ni * cost) / (nt * cosi + ni * cost)) ^ 2
col = 11
CASE "te"
r = ((ni * cosi - nt * cost) / (ni * cosi + nt * cost)) ^ 2
col = 14
END SELECT
x = 1280 * i / pi
y = 479 * (1 - r)
IF i = 0 THEN PSET (x, y)
LINE -(x, y), col
NEXT i
END SUB
SUB grilla (ni, nt)
FOR y = 0 TO 479 STEP 48
LINE (0, y)-(640, y), 8
NEXT y
FOR y = 0 TO 479 STEP 4.8
LINE (0, y)-(5, y), 8
LINE (634, y)-(639, y),
8
NEXT y
LINE (0, 479)-(639, 479), 8
FOR x = 0 TO 639 STEP 71
LINE (x, 0)-(x, 479), 8
NEXT x
FOR x = 0 TO 639 STEP 7.1
LINE (x, 0)-(x, 5), 8
LINE (x, 474)-(x, 479), 8
NEXT x
END SUB