Wednesday, February 13, 2013

Shared Program (4)


Another shared program from Richard Duncan - works for iPad in Portrait.

1 SCREEN 1:CLS
2 DIM C1(200)
3 GOSUB 900
5 ZD=0
10 YD=0
15 XD=90
20 XD= XD* 3.14159 / 180
25 YD= YD* 3.14159 / 180
30 ZD= ZD* 3.14159 / 180
35 R = 220
36 SR= 80
37 T=0
40 FOR A = 0 TO 350 STEP 10
45 A2 = A + 10
50 A1 = A
55 A12 = A + 5
60 A1 = A1 * 3.14159 / 180
65 A2 = A2 * 3.14159 / 180
70 A12 = A12 * 3.14159 / 180
72 J=0
73 T=T+1
75 FOR AA = 0 TO 340 STEP 20
80 A3 = AA: A4 = AA + 20
85 A34 = AA + 10
86 J=J+1
90 IF A3 >= 360 THEN A3 = A3 - 360
95 IF A4 >= 360 THEN A4 = A4 - 360
100 A3 = A3 * 3.14159 / 180
105 A4 = A4 * 3.14159 / 180
110 A34 = A34 * 3.14159 / 180
115 X = R * COS(A1) + COS(A1) * SR * COS(A3)
116 Z= R * SIN(A1) + SIN(A1) * SR * COS(A3)
117 REM END
120 Y = SR * SIN(A3)
125 GOSUB 500
130 X1 = X: Y1 = Y: Z1 = Z
135 X = R * COS(A1) + COS(A1) * SR * COS(A4)
136 Z= R * SIN(A1) + SIN(A1) * SR * COS(A4)
140 Y = SR * SIN(A4)
145 GOSUB 500
150 X2 = X: Y2 = Y: Z2 = Z
155 X = R * COS(A2) + COS(A2) * SR* COS(A4)
156 Z= R * SIN(A2) + SIN(A2) * SR* COS(A4)
160 Y = SR* SIN(A4)
165 GOSUB 500
170 X3 = X: Y3 = Y: Z3 = Z
175 X = R * COS(A2) + COS(A2) * SR* COS(A3)
176 Z= R * SIN(A2) + SIN(A2) * SR* COS(A3)
180 Y = SR* SIN(A3)
181 GOSUB 500
183 X4 = X: Y4 = Y: Z4 = Z
184 MX=X1:IF MX>X2 THEN MX=X2:IF MX>X3 THEN MX=X3
185 IF MX>X4 THEN MX=X4
188 MY=Y1:IF MY>Y2 THEN MY=Y2:IF MY>Y3 THEN MY=Y3
189 IF MY>Y4 THEN MY=Y4
190 AX=X1:IF AX<X2 THEN AX=X2:IF AX<X3 THEN AX=X3
191 IF AX<X4 THEN AX=X4
192 AY=Y1:IF AY<Y2 THEN AY=Y2:IF AY<Y3 THEN AY=Y3
193 IF AY<Y4 THEN AY=Y4
194 IF T=1 THEN SX=MX:IF T=1 THEN SY=MY
195 IF T=1 THEN LX=AX:IF T=1 THEN LY=AY
197 IF T>1 AND SX>MX THEN SX=MX
199 IF T>1 AND SY>MY THEN SY=MY
201 IF T>1 AND LX<AX THEN LX=AX
203 IF T>1 AND LY<AY THEN LY=AY
205 NEXT AA
210 NEXT A
211 REM PRINT SX;LX;SY;LY
212 J=0
240 FOR A = 0 TO 350 STEP 10
245 A2 = A + 10
250 A1 = A
260 A1 = A1 * 3.14159 / 180
265 A2 = A2 * 3.14159 / 180
272 J=J+1
275 FOR AA = 0 TO 340 STEP 20
280 A3 = AA
281 A4=AA+20
287 REM PRINT "aa=";AA
296 REM PRINT "a3=";A3
300 A3 = A3 * 3.14159 / 180
305 A4 = A4 * 3.14159 / 180
315 X = R * COS(A1) + COS(A1) * SR * COS(A3)
316 Z= R * SIN(A1) + SIN(A1) * SR * COS(A3)
320 Y = SR * SIN(A3)
321 REM PRINT "x=";X;A1;A3
325 GOSUB 500
330 X1 = X
331 Y1=Y
332 Z1=Z
335 X = R * COS(A1) + COS(A1) * SR * COS(A4)
336 Z= R * SIN(A1) + SIN(A1) * SR * COS(A4)
340 Y = SR * SIN(A4)
345 GOSUB 500
350 X2 = X
351 Y2=Y
352 Z2=Z
355 X = R * COS(A2) + COS(A2) * SR * COS(A4)
356 Z= R * SIN(A2) + SIN(A2) * SR * COS(A4)
360 Y = SR* SIN(A4)
365 GOSUB 500
370 X3 = X
371 Y3=Y
372 Z3=Z
375 X = R * COS(A2) + COS(A2) * SR* COS(A3)
376 Z= R * SIN(A2) + SIN(A2) * SR* COS(A3)
377 Y = SR* SIN(A3)
378 GOSUB 500
379 X4 = X
380 Y4=Y
381 Z4=Z
382 DX1=ABS(LX-SX)
383 DY1=ABS(LY-SY)
384 REM PRINT "dx=";DX;"dy=";DY
385 REM PRINT "x1before=";X1
386 YT=900
387 DF=34
388 DX=700/DX1
389 DY=700/DY1
392 X1=ABS(X1-SX)*DX+DF
393 X2=ABS(X2-SX)*DX+DF
394 X3=ABS(X3-SX)*DX+DF
395 X4=ABS(X4-SX)*DX+DF
404 Y1=YT-ABS(Y1-SY)*DY
405 Y2=YT-ABS(Y2-SY)*DY
406 Y3=YT-ABS(Y3-SY)*DY
407 Y4=YT-ABS(Y4-SY)*DY
408 REM PRINT X1;Y1;X2;Y2
409 REM PRINT X3;Y3;X4;Y4
410 TRIANGLE X1,Y1,X2,Y2,X3,Y3,C1(J),1
411 TRIANGLE X1,Y1,X4,Y4,X3,Y3,C1(J),1
412 LINE X1,Y1,X2,Y2,12
413 LINE X2,Y2,X3,Y3,4
414 LINE X3,Y3,X4,Y4,4
415 LINE X1,Y1,X4,Y4,4
421 NEXT AA
423 NEXT A
424 REM END
425 GOTO 425
500 XN = X * COS(YD)+ Z * SIN(YD)
510 ZN = -X * SIN(YD) + Z * COS(YD)
520 X = XN
521 Z = ZN
525 YN = -Z * SIN(XD) + Y * COS(XD)
530 ZN = Z * COS(XD) + Y * SIN(XD)
535 Y = YN
536 Z = ZN
540 XN = X * COS(ZD) + Y * SIN(ZD)
545 YN = -X * SIN(ZD)+ Y * COS(ZD)
550 X = XN
551 Y = YN
560 RETURN
900 CN=15
901 DIM RD(200),GR(200),BL(200)
903 FOR I=1 TO 200
904 CN=CN+1:RED=RND(0)*255:GREEN=RND(0)*255:BLUE=RND(0)*255
905 RED=INT(RED):GREEN=INT(GREEN):BLUE=INT(BLUE)
906 CSET CN,RED,GREEN,BLUE,255
907 RD(I)=RED:GR(I)=GREEN:BL(I)=BLUE
910 REM PRINT CN,RED,GREEN,BLUE
914 C1(I)=CN
916 NEXT I
920 RETURN


No comments:

Post a Comment