SCREEN 12

CLS

LOCATE 10, 1

PRINT "                               PROGRAM 'DISTORTI'"

PRINT

PRINT

PRINT "            Plots the image of a square reticle affected by third order"

PRINT "            distortion. The reticle must have an even number of lines."

PRINT "            The default values are those of Fig. 4.22 (b)."

PRINT "            To finish put line number = 0."

DO: LOOP WHILE INKEY$ = ""

CLS

l = 5: bv = .5:

DO

LOCATE 1, 1: PRINT "           "

LOCATE 1, 1: PRINT l + 1; "lines (even!)";

INPUT a$: IF a$ <> "" THEN l = VAL(a$) - 1

IF l = -1 THEN END

LOCATE 2, 1: PRINT "           "

LOCATE 2, 1: PRINT "B5 ="; bv;

INPUT a$: IF a$ <> "" THEN bv = VAL(a$)

B5 = bv / 100000

CLS

COLOR 8

LINE (317, 240)-(323, 240)

LINE (320, 237)-(320, 243)

FOR h0 = 90 TO 390 STEP 300 / l

LINE (170, h0)-(470, h0)

NEXT h0

FOR h0 = 170 TO 470 STEP 300 / l

LINE (h0, 90)-(h0, 390)

NEXT h0

COLOR 15

FOR h0 = 90 TO 390 STEP 300 / l

FOR x = -150 TO 150 STEP .5

h = SQR((h0 - 240) ^ 2 + x ^ 2)

xx = x * (1 + B5 * h ^ 2)

yy = h * (1 + B5 * h ^ 2) * SQR(1 - x ^ 2 / h ^ 2)

PSET (xx + 320, yy + 240)

PSET (xx + 320, -yy + 240)

NEXT x

NEXT h0

FOR h0 = 170 TO 470 STEP 300 / l

FOR y = -150 TO 150 STEP .5

h = SQR((h0 - 320) ^ 2 + y ^ 2)

yy = y * (1 + B5 * h ^ 2)

xx = h * (1 + B5 * h ^ 2) * SQR(1 - y ^ 2 / h ^ 2)

PSET (xx + 320, yy + 240)

PSET (-xx + 320, yy + 240)

NEXT y

NEXT h0

DO: LOOP WHILE INKEY$ = ""

LOOP