Please help an absolute novice with some simple(ish) programming.
I'm very, very rusty at BASIC. I'm using BASin, for my GCSE Astronomy coursework
Well, I've downloaded this book from the Archive
http://www.worldofspectrum.org/infoseekid.cgi?id=2000437
and started from Chapter 5, and I copied this in from the book;
How do you draw ellipses?
Do you think it would be easy to incorporate ellipses into this program?
How do I remove the trails of "planets", when it plots a planet, and then plots it again, how do I remove the old one, and still have the circle here?
Use a spreadsheet and/or a graphing package, or write a computer program which simulates the scaled orbits of either at least four planets around the Sun, or the major satellites of a named planet
Well, I've downloaded this book from the Archive
http://www.worldofspectrum.org/infoseekid.cgi?id=2000437
and started from Chapter 5, and I copied this in from the book;
1 REM
10 PRINT "ORERRY"
11 REM
25 DATA 19,36,50,76,3,13,24,48,75
30 BRIGHT 1: DIM b$(24)
40 LET h=83: LET g=171
50 DIM a(9): FOR f=1 TO 9: READ a(f): NEXT f: RESTORE
59 REM
60 PRINT "Jupiter - Neptune=5"
70 PRINT "mERCURY - Mars=1"
71 REM
80 INPUT "select 1 OR 5",b: IF b<>1 AND b<>5 THEN GO TO 80
90 PRINT AT b/5+1,0;b$
100 PRINT AT 10,0;"1st point"'"OF ARIES <";TAB 21;"*"
110 PLOT g-5,h: DRAW -90,0
120 FOR n=1*b TO b+4
130 CIRCLE g,h,a(n): NEXT n
140 PRINT AT 12,21;("s m v e m" AND b=1)+("ej s u n" AND b=5)
144 REM
145 REM PLOT PLANES IN ORBIT
146 REM
150 FOR d=1 TO 400 STEP 50/b
170 PRINT FLASH 1;AT 8,0;"week ";INT (1+d/50*B^2.7)
180 FOR n=1*b TO b+4
190 LET v=1/a(n)^1.4*100
200 LET e=d/400*v*PI
210 LET c=g+a(n)*COS e
220 LET s=h+a(n)*SIN e
230 CIRCLE INT c,INT s,1.5
240 NEXT n: NEXT d: STOP
9900 REM
How do you draw ellipses?
Do you think it would be easy to incorporate ellipses into this program?
How do I remove the trails of "planets", when it plots a planet, and then plots it again, how do I remove the old one, and still have the circle here?
Post edited by thx1138 on
Comments
There's no ellipse command in Sinclair BASIC. You can approximate a very crude ellipse using the DRAW command to build one up out of a series of curves, or alternatively PLOT all the individual points to get a more accurate one. It'll take some time though, so I guess it depends on how patient you are.
You could just issue the same commands after an OVER 1. The first time you do it they'll draw as normal, but the second time will erase what was drawn. Things will look a bit funny if you've got overlapping objects on screen though as they may partly blank each other out.
Or you can do it in assembler but it's not for beginners.
I don't know anything about your math knowledge, so I will assume it is basic.
An elipse has a center (x,y) just like a circle, but it doesn't have a radius like circle. Instead it is described with two parameters called axis. We have horizontal axis and vertical axis.
IF horizontal axis> vertical axis the elipse look like laying egg.
Otherwise it will look like standing egg.
We can write a FOR..NEXT loop where the variable in loop will change from 0 to 2*PI (that is approximately 6.28 ) radians. Radians are units used to measure angles, just like degrees. 360 degress=6.28 radians.
If we have an angle changing from 0 to 360 degrees (6.28 radians) we can use trygonometric functions to draw both circle and elipse. We will be using the center and radius (circle case) or two axis (ellipse case)
CIRCLE:
ELIPSE:
My maths knowledge is pretty poor, in fact I am planning to do GCSE maths next year, and I will struggle. :( Like, I can read through the programs up there and understand them, but get a bit hazy with the SIN and COS etc.
It's good enough for the level of Astronomy I'm doing though.
My arithmetic has always been good enough to get through life, but I figure I need to improve my maths, before I tackle any science based As-levels.
Perhaps you could compile this using something like MCODER 2 (though I can't remember if it supports SIN / COS) - should be nice and fast then!