home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
RBBS in a Box Volume 1 #3.1
/
RBBSIABOX31.cdr
/
pool
/
plot_3d.bas
< prev
next >
Wrap
BASIC Source File
|
1984-06-23
|
2KB
|
47 lines
260 REM CREATIVE COMPUTING APRIL 1982, P.166
270 REM MODIFIED BY HAL VARIAN
280 KEY OFF
290 CLS:PRINT TAB(14);"3-D PLOTS":PRINT
300 REM INPUT PARAMETERS
310 PRINT : INPUT "GRID WIDTH: 10"; A$: IF A$="" THEN GW=10:GOTO 330
320 GW = VAL(A$)
330 INPUT "ACCURACY(1-FINE,10-POOR): 10";A$:IF A$="" THEN AC=10: GOTO 350
340 AC=VAL(A$)
350 C=SQR(2)/2:GOSUB 470: OX=120: OY=32
360 CLS:SCREEN 1
370 REM BEGIN ITERATIONS
380 FOR X=XU TO XL STEP -GW*XM:GOSUB 610
390 FOR Y=YL TO YU STEP AC*YM:GOSUB 640:GOSUB 700:NEXT:Y=YU:GOSUB 640:GOSUB 700:NEXT
400 X=XL:GOSUB 610: FOR Y=YL TO YU STEP AC*YM:GOSUB 640:GOSUB 700:NEXT
410 FOR Y=YL TO YU STEP GW*YM: GOSUB 620
420 FOR X=XL TO XU STEP AC*XM:K=(X+TX)/XM*C
430 GOSUB 640:GOSUB 700:NEXT:K=(XU+TX)/XM*C:GOSUB 640:GOSUB 700:NEXT
440 Y=YU:GOSUB 620: FOR X=XL TO XU STEP AC*XM:K=(X+TX)/XM*C:GOSUB 640:GOSUB 700:NEXT
450 STOP
460 REM INPUT PARAMETERS
470 INPUT "X MIN:-4";A$: IF A$="" THEN XL=-4: GOTO 490
480 XL=VAL(A$)
490 INPUT "Y MIN:-4";A$: IF A$="" THEN YL=-4: GOTO 510
500 YL=VAL(A$)
510 INPUT "X MAX: 4";A$:IF A$="" THEN XU=4: GOTO 530
520 XU=VAL(A$)
530 INPUT "Y MAX: 4";A$: IF A$ = "" THEN YU=4 :GOTO 550
540 YU=VAL(A$)
550 INPUT "Z MAX: 2";A$: IF A$="" THEN ZU= 2: GOTO 570
560 ZU=VAL(A$)
570 INPUT "Z MIN:-2";A$:IF A$="" THEN ZL=-(2): GOTO 590
580 ZL=VAL(A$)
590 ZM=(ZU-ZL)/140:XM=(XU-XL)/200: YM=(YU-YL)/200
600 TX=0-XL:TY=0-YL:TZ= -80*ZM - ZL: RETURN
610 K=(X+TX)/XM*C:Y=YL:GOSUB 640:U=I:V=J: RETURN
620 X=XL:K=(X+TX)/XM*C:GOSUB 640:U=I:V=J:RETURN
630 REM STATEMENT 640 CONTAINS THE FUNCTION TO BE PLOTTED
640 Z=SIN(X) + SIN(Y)
650 I=OX+(Y+TY)/YM - K:J=OY-(Z+TZ)/ZM+K: IF I< 0 THEN I=0
660 IF I > 279 THEN I=279
670 IF J > 191 THEN J=191
680 IF J< 0 THEN J=0
690 RETURN
700 IF (U=0 AND I=0) OR (U=279 AND I=279) OR (V=0 AND J=0) OR (J=191 AND V=191) THEN U=I:V=J: RETURN
710 LINE (U,V)-(I,J):U=I:V=J:RETURN