; MISC1 (LISTING 2) MODULE:BYTE st:INT ARRAY jx=[1 1 1 1 1 2 2 2 1 0 0 0 1 1 1 1] ,jy=[1 1 1 1 1 2 0 1 1 2 0 1 1 2 0 1] BYTE ARRAY b=" " PROC Setjxjy(BYTE i) FOR i=0 TO 15 DO jx(i)==-1:jy(i)==-1 OD RETURN PROC Pb(BYTE i):b(0)=i:Print(b):RETURN PROC Wait(CARD w,j) FOR j=0 TO w DO w==+1:w==-1 OD RETURN ; TRIG MODULE:BYTE ARRAY Si(91) PROC SetTrig(BYTE t INT y) FOR t=0 TO 90 DO y=(t*t)/45 y=(y*t)/5:y=100*t-y:y==/45:Si(t)=y OD RETURN INT FUNC sin(INT t,y):t==MOD 360 IF t<91 THEN y=Si(t) ELSEIF t<181 THEN y=Si(180-t) ELSEIF t<271 THEN y=-Si(t-180) ELSE y=-Si(360-t) FI RETURN(y) INT FUNC cos(INT t,y):t==MOD 360 IF t<91 THEN y=Si(90-t) ELSEIF t<181 THEN y=-Si(t-90) ELSEIF t<271 THEN y=-Si(270-t) ELSE y=Si(t-270) FI RETURN(y) ; VECTOR INT FUNC ABS(INT x) IF x<0 THEN x=-x FI RETURN(x) INT FUNC SQR(INT x):INT y IF x=0 THEN RETURN(0) FI:x=ABS(x):y=0 DO y==+1:IF y*y+y>x THEN RETURN(y) FI OD INT FUNC Vdot(INT ARRAY v,w):INT x x=v(0)*w(0):x==+v(1)*w(1) x==+v(2)*w(2):RETURN(x) PROC Vprod(INT ARRAY v,w,u) u(0)=v(1)*w(2):u(0)==-v(2)*w(1) u(1)=v(2)*w(0):u(1)==-v(0)*w(2) u(2)=v(0)*w(1):u(2)==-v(1)*w(0) RETURN PROC Normize(INT ARRAY v):INT i,j,s i=ABS(v(0)) j=ABS(v(1)):IF i<j THEN i=j FI j=ABS(v(2)):IF i<j THEN i=j FI IF i>100 THEN j=1+i/100 FOR i=0 TO 2 DO v(i)==/j OD FI FOR j=0 TO 1 DO s=Vdot(v,v):s=SQR(s) FOR i=0 TO 2 DO v(i)=v(i)*128/s OD OD RETURN
Back to previous page