View Single Post
  #2  
Old September 17th 05 posted to sci.physics.relativity
Ken S. Tucker
external usenet poster
 
Posts: 7,364
Default Androcles, see some tight code.


Ken S. Tucker wrote:
Hey Andro,
Try running this little program, far below.
If it works I have another better one.
Ken
PS: maybe this will keep the kids from breaking
your windows!

+++++++++++++++++++++++++++++++++

Newsgroups: alt.sci.planetary
From: (David Williams) - Find messages by
this author
Date: Sat, 20 Dec 2003 23:16:12 -0600
Local: Sat, Dec 20 2003 10:16 pm
Subject: cratering program
Reply to Author | Forward | Print | Individual Message | Show original
| Report Abuse

Ken Tucker (who often posts here) has asked me to post the following
little BASIC program that he wrote with his son, Travis, some 15 years
ago. It was written in some old dialect of BASIC, with line numbers,
but works okay in QBasic, and probably others. What it does is to draw
an image of a sphere floating in a starry sky, and then show the sphere
being bombarded with meteors, producing craters. After a while, the
image does look passably like the moon, or some similar body.

If nothing else, it is pretty, and is far more interesting to watch
than most screen-savers.

Please direct any questions to Ken. I'm just the messenger, as far as
this is concerned.

dow

-------------------------------------------------------

5 ' Craters. Ken and Travis Tucker. Approx 1988.
10 CLEAR : SCREEN 7, 0, 0, 0: KEY OFF: CLS
12 PCOPY 0, 1: PCOPY 0, 2: PCOPY 0, 3: VIEW PRINT 1 TO 25
21 C = 1: GOSUB 22: C = 9: GOSUB 22: GOTO 25
22 FOR A = 1 TO 100: X = RND * 320: Y = RND * 200
23 PSET (X, Y), C: NEXT A: RETURN
25 DR = 3.141592 / 180: R = 10
30 RANDOMIZE TIMER
35 DIM X(500), Y(500)
40 CIRCLE (160, 100), 90, 8
45 PAINT (160, 100), 4, 8: PAINT (160, 100), 8, 8
100 R = INT(RND * RND * RND * RND * 20) + 1: LO = RND * 170 - 85
105 LA = RND * 140 - 70: C = 8
110 X0 = 90 * SIN(DR * LO) * COS(DR * LA) + 160
112 Y0 = 76 * SIN(LA * DR) + 100
115 GOSUB 300: IF R = 1 THEN PSET (X0, Y0), 14: GOTO 100
120 C = 12: GOSUB 130: PAINT (X0, Y0), 4, 12: GOSUB 600:
125 PAINT (X0, Y0), 7, 12: GOSUB 400: GOSUB 500: GOTO 180
130 N = 0: S = 36 / R: FOR A = 1 TO 360 STEP S: N = N + 1
140 U = R * SIN(A * DR) + LO: V = R * COS(A * DR) + LA
150 X = 90 * SIN(DR * U) * COS(DR * V) + B: Y = 76 * SIN(V * DR)
155 X(N) = X: Y(N) = Y
160 PSET (X + 160, Y + 100), C
170 NEXT A: RETURN
180 PSET (X0, Y0), 15
200 GOTO 100
300 PCOPY 0, 1: DX = X0 - 160: DY = Y0 - 100
305 LINE (DX * 10, DY * 10)-(X0, Y0), 14: GOSUB 600: PCOPY 1, 0
310 FOR A = 1 TO R * 4: X1 = X0 + RND * 4 * R - 2 * R
315 Y1 = Y0 + 4 * RND * R - 2 * R
320 LINE (X0, Y0)-(X1, Y1), 4: NEXT A: GOSUB 600: PCOPY 1, 0: RETURN
400 FOR A = 1 TO N: X = X(A): Y = Y(A)
410 IF X = 0 OR Y = 0 THEN 420
412 PSET (X + 160 + X / ABS(X), Y + 100 + Y / ABS(Y)), 0
420 NEXT A: RETURN
500 FOR A = 1 TO N: X = X(A): Y = Y(A)
510 PSET (X + 160, Y + 100), 14
520 NEXT A: RETURN
600 FOR DE = 1 TO 5: T = TIMER: WHILE TIMER = T: WEND: NEXT: RETURN

----------


++++++++++++++++++++++

Hi again Andro.
I doubt there's a mathematician alive who can
see how the above equations render a lunar
surface. So what I've been tryin to do is
create a vision in the thought experiments I
demo. I was wondering about putting them into a
dynamic graphical program with sub-titles, to
explain the thought process.

You seem to have an edge on programming, so I
was hoping you might...well critisize,

TIA
Ken

Ads
 

Mortgage - Fast Loans - Remortgage - New York Hotels - Modded Xbox