Rem ************************************************************************** Rem * Rem * Cosplot2 by Dan Rhea - Converted from a Microsoft basic demo I did for Rem * The Atari 8-Bit machine. Basicly is shows some Rem * 3D graphics, hidden line removal and most important! Speed, this program Rem * takes nearly 40 min to run on an 80XL. Rem * Rem ************************************************************************** Rem * Rem ** Declare data and alert boxes Rem * A$="Cosplot2-ST by Dan Rhea|========================|Press both mouse buttons| to stop the program" B$=" Select resolution " Cx=639 Cy=399 Rh=60 D=1800 Th=0.4 S1=Sin(Th) C1=Cos(Th) Ph=1.25 S2=Sin(Ph) C2=Cos(Ph) Ar=640 Dim Yn(Ar) Dim Yx(Ar) Rem * Rem ** Open us a full window and get a contrasting color Rem * Openw 0,0,0 Fullw 0 Color 1 Defline 1,1,0,0 Rem * Rem ** Init the display arrays Rem * For I=1 To Ar-1 Yn(I)=Cx Yx(I)=Cx Next I Rem * Rem ** Pick the formula and resolution Rem * B1=0 Alert 0,A$,1,"Form 1|Form 2|Quit",B1 If B1=3 Then End Endif Alert 0,B$,1,"High|Med|Nope!",B2 If B2=3 Then End Endif If B2=1 Then St=-1 Else St=-0.5 Cy=199 Endif Rem * Rem ** Hide the mouse and start drawing Rem * Hidem For X=8 To -95 Step St Fl=0 For Y=-75 To 4 If B1=1 Then Gosub Cosfu1(0.06) Else Gosub Cosfu2(0.06) Endif Z=Num Rem * Rem ** See if they want to quit Rem * B=Mousek If B=3 Then Showm Stop Hidem Endif Gosub Findhide(0) Next Y Next X Rem * Rem ** Wait here till we are told to quit Rem Showm Here: B=Mousek If B=3 Then End Endif Goto Here Rem * Rem ** Handle the sacaling, slope and hidden line removal of the plot Rem * Procedure Findhide(Dum1) Rem * Rem ** Simulate the 3D effect and use Cosine coordinates Rem * Xe=-X*S1+Y*C1 Ye=-X*C1*C2-Y*S1*C2+Z*S2 Ze=-X*S2*C1-Y*S2*S1-Z*C2+Rh Sx=D*(Xe/Ze)+Cx Sy=-D*(Ye/Ze)+Cy If Fl=0 Then Fl=1 F=0 Else Dx=Ox-Sx If Dx=0 Then Dx=1 Endif Sl=(Oy-Sy)/Dx Yp=Oy For Xp=Int(Ox)+1 To Sx Fg=1 Yp=Yp+Sl Rem * Rem ** Most of the following is for hidden line removal Rem * If Xp<0 Or Xp>Cx Then Fg=0 F=0 Goto Merge Endif If Yp<0 Or Yp>Cy Then Fg=0 F=0 Endif Rem * Rem ** Go for the appropriate plot routine Rem * If Yp<=Yn(Xp) Then Gosub Makeit1(0) If Yp=Yx(Xp) Then Gosub Makeit2(0) Goto Merge Endif F=0 Endif Merge: Next Xp Endif Ox=Sx Oy=Sy Return Rem * Rem ** Normal draw routine Rem * Procedure Makeit1(Dum2) Yn(Xp)=Yp If Fg<>0 Then If F=0 Then Plot Xp,Yp F=1 Endif Draw Xp,Yp Endif Return Rem * Rem ** Special routine for the edges Rem * Procedure Makeit2(Dum3) Yx(Xp)=Yp If Fg<>0 Then If F=0 Then Plot Xp,Yp F=1 Endif Draw Xp,Yp Endif Return Rem * Rem ** Distant Plot formula Rem * Procedure Cosfu1(Ival) Num=Sqr((Cos(Ival*(X*X+Y*Y)))*(Cos(Ival*(X*X+Y*Y)))) Return Rem * Rem ** Closeup plot formula Rem * Procedure Cosfu2(Ival) Num=Cos(Ival*(X*X+Y*Y)) Return End