SCREEN 12

CLS

LOCATE 10, 1

PRINT "                          PROGRAMA 'DISTORSI'"

PRINT

PRINT

PRINT "Grafica la imagen de una reticula cuadrada afectada de distorsion de"

PRINT "tercer orden. La reticula debe tener un numero par de lineas."

PRINT "Los valores predeterminados corresponden a la fig. 4.22 (b)."

PRINT "Para terminar poner el numero de lineas = 0."

DO: LOOP WHILE INKEY$ = ""

CLS

l = 5: bv = .5:

DO

LOCATE 1, 1: PRINT "           "

LOCATE 1, 1: PRINT l + 1; "lineas (par!)";

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