home *** CD-ROM | disk | FTP | other *** search
- 1 REM STELLATION
- 2 REM BY RICHARD RYLANDER
- 3 REM ORIGINALLY APPEARED IN
- 4 REM DR. DOBB'S JOURNAL, MAY 1985
- 5 REM MODIFIED FOR EVSBASIC
- 6 REM BY ANTON TREUENFELS
- 7 :
- 100 (null)0:(null)14,1:(null)0
- 105 PRINT"[147] ********************************"
- 110 PRINT" * SMALL STELLATED DODECAHEDRON *"
- 115 PRINT" ********************************"
- 120 :
- 130 PRINT" READING VERTEX DATA"
- 135 VN=32:DIMP%(VN-1,2),P(VN-1,2)
- 140 FORN=0TOVN-1
- 145 READP%(N,0),P%(N,1),P%(N,2)
- 150 NEXT
- 155 :
- 160 PRINT" READING CONNECTION DATA"
- 165 FA=60
- 170 DIMF%(FA,2),F(FA,2),SH(FA),Z(FA),K(FA)
- 175 FORN=1TOFA
- 180 READF%(N,0),F%(N,1),F%(N,2)
- 185 NEXT
- 190 :
- 200 PRINT" A SMALL STELLATED DODECAHEDRON IS"
- 205 PRINT" ROTATED AND DRAWN IN 3-D. (TRY"
- 210 PRINT" ROTATION VALUE 10,10,10 OR 10,20,30)"
- 220 PRINT" AFTER THE FIGURE IS DRAWN PRESS"
- 225 PRINT" <RETURN> TO QUIT THE PROGRAM, OR ANY"
- 230 PRINT" OTHER KEY TO ENTER A NEW ROTATION"
- 235 PRINT" VALUE."
- 240 :
- 245 PRINT" PRESS ANY KEY TO START."
- 250 :
- 255 A$=(null)(1)
- 260 :
- 300 PRINT"[147] ENTER X,Y, AND Z ROTATION VALUES"
- 305 A$="X":GOSUB900:X=A
- 310 A$="Y":GOSUB900:Y=A
- 315 A$="Z":GOSUB900:Z=A
- 320 :
- 325 PRINT" PERFORMING ROTATION"
- 330 J=3.14159265/180
- 335 A=SIN(X*J):B=COS(X*J):C=SIN(Y*J):D=COS(Y*J):E=SIN(Z*J):F=COS(Z*J)
- 340 X0=D*F-A*C*E:X1=D*E+A*C*F:X2=-B*C
- 345 Y0=-B*E:Y1=B*F:Y2=A
- 350 Z0=C*F+A*D*E:Z1=C*E-A*D*F:Z2=B*D
- 355 :
- 360 FORN=0TOVN-1
- 365 X=P%(N,0):Y=P%(N,1):Z=P%(N,2)
- 370 P(N,0)=X0*X+X1*Y+X2*Z
- 375 P(N,1)=Y0*X+Y1*Y+Y2*Z
- 380 P(N,2)=Z0*X+Z1*Y+Z2*Z
- 385 NEXT
- 390 :
- 400 REM USE NORMAL VECTORS FOR VISIBLE
- 405 PRINT" FINDING VISIBLE FACETS"
- 410 VF=-1
- 415 FORN=1TOFA
- 420 VF=VF+1
- 425 A=F%(N,0):D=F%(N,1):G=F%(N,2)
- 430 F(VF,0)=A:F(VF,1)=D:F(VF,2)=G
- 435 C=P(A,2):B=P(A,1):A=P(A,0)
- 440 F=P(D,2):E=P(D,1):D=P(D,0)
- 445 I=P(G,2):H=P(G,1):G=P(G,0)
- 450 Z=(G-D)*(B-E)-(A-D)*(H-E)
- 455 IFZ<=0THENVF=VF-1:GOTO485
- 460 X=(H-E)*(C-F)-(B-E)*(I-F)
- 465 Y=(I-F)*(A-D)-(C-F)*(G-D)
- 470 NC=SQR(X*X+Y*Y+Z*Z)
- 475 J=(26*(2*Z+X+Y)/NC)+64
- 480 SH(VF)=(J*J)/256
- 485 NEXT
- 490 :
- 500 PRINT" SCALING TO DISPLAY SIZE"
- 505 A=0
- 510 FORN=0TOVN-1
- 515 IFABS(P(N,1))>ATHENA=ABS(P(N,1))
- 520 NEXT
- 525 A=119/A
- 530 FORN=0TOVN-1
- 535 P(N,0)=A*P(N,0):P(N,1)=A*P(N,1)
- 540 NEXT
- 545 :
- 550 PRINT" FINDING AVERAGE 'Z'"
- 555 FORN=0TOVF
- 560 K(N)=N:Z(N)=P(F(N,0),2)+P(F(N,1),2)+P(F(N,2),2)/3
- 565 NEXT
- 570 :
- 600 PRINT" SORTING ACCORDING TO 'Z'"
- 605 A=VF
- 610 (null)
- 615 A=INT(A/2)
- 620 IFA=0THEN(null)
- 625 B=VF-A
- 630 FORN=0TOB
- 635 C=N
- 640 (null)
- 645 D=C+A
- 650 IFZ(C)<=Z(D)THEN(null)
- 655 (null)K(C),K(D):(null)Z(C),Z(D)
- 660 C=C-A
- 665 (null)(null)C>0
- 670 NEXT
- 675 (null)
- 680 :
- 700 (null)4:(null)14,1:(null)0,6,15
- 705 (null)320,-240,160,-120
- 710 FORN=0TOVF
- 715 A=K(N)
- 720 X0=P(F(A,0),0):Y0=P(F(A,0),1)
- 725 X1=P(F(A,1),0):Y1=P(F(A,1),1)
- 730 X2=P(F(A,2),0):Y2=P(F(A,2),1)
- 735 (null)2:(null)X0,Y0:(null)X1,Y1TOX2,Y2TOX0,Y0
- 740 B=(X2+(X0+X1)/2)/2
- 745 C=(Y2+(Y0+Y1)/2)/2
- 750 (null)B,C:(null)3:(null)SH(A),2
- 755 (null)1:(null)X0,Y0:(null)X1,Y1TOX2,Y2TOX0,Y0
- 760 NEXT
- 765 :
- 800 A$=(null)(1)
- 805 (null)0:(null)14,1:(null)0:(null)
- 810 IFA$<>CHR$(13)THEN300
- 815 END
- 820 :
- 900 PRINT" ";A$;"= ";
- 905 A$="":B$=""
- 910 PRINTA$;" [146][157]";
- 915 A$=(null)(1)
- 920 A=LEN(B$)
- 925 IFA$="-"ANDA=0THENB$=A$:GOTO910
- 930 IFA$>="0"ANDA$<="9"ANDA<10THENB$=B$+A$:GOTO910
- 935 IFA$=CHR$(20)ANDA>0THENB$=LEFT$(B$,A-1):GOTO910
- 940 IFA$<>CHR$(13)ORA=0THEN915
- 945 PRINT" "
- 950 A=VAL(B$)
- 955 RETURN
- 960 :
- 1000 REM *VERTEX DATA
- 1005 DATA 1000,618,0,1000,-618,0
- 1010 DATA -1000,618,0,-1000,-618,0
- 1015 DATA 0,1000,618,0,1000,-618
- 1020 DATA 0,-1000,618,0,-1000,-618
- 1025 DATA 618,0,1000,-618,0,1000
- 1030 DATA 618,0,-1000,-618,0,-1000
- 1035 DATA 618,0,236,618,0,-236
- 1040 DATA -618,0,236,-618,0,-236
- 1045 DATA 236,618,0,-236,618,0
- 1050 DATA 236,-618,0,-236,-618,0
- 1055 DATA 0,236,618,0,-236,618
- 1060 DATA 0,236,-618,0,-236,-618
- 1065 DATA 382,382,382,382,382,-382
- 1070 DATA 382,-382,382,382,-382,-382
- 1075 DATA -382,382,382,-382,382,-382
- 1080 DATA -382,-382,382,-382,-382,-382
- 1085 :
- 1100 REM *CONNECTION DATA
- 1105 DATA 0,12,13,0,13,25,0,25,16,0,16,24,0,24,12
- 1110 DATA 1,12,26,1,26,18,1,18,27,1,27,13,1,13,12
- 1115 DATA 2,15,14,2,14,28,2,28,17,2,17,29,2,29,15
- 1120 DATA 3,14,15,3,15,31,3,31,19,3,19,30,3,30,14
- 1125 DATA 4,16,17,4,17,28,4,28,20,4,20,24,4,24,16
- 1130 DATA 5,17,16,5,16,25,5,25,22,5,22,29,5,29,17
- 1135 DATA 6,19,18,6,18,26,6,26,21,6,21,30,6,30,19
- 1140 DATA 7,18,19,7,19,31,7,31,23,7,23,27,7,27,18
- 1145 DATA 8,20,21,8,21,26,8,26,12,8,12,24,8,24,20
- 1150 DATA 9,21,20,9,20,28,9,28,14,9,14,30,9,30,21
- 1155 DATA 10,23,22,10,22,25,10,25,13,10,13,27,10,27,23
- 1160 DATA 11,22,23,11,23,31,11,31,15,11,15,29,11,29,22
-