programming a spiral in basic
programming a spiral in basic
ive had a look on google, this forum and wos forum, etc and cant find anything on how to do this. i can do the basic part, i just need pointing in the right direction as to what equation, i should use. maths is not my strongest point. i would prefer if it was to be done purely with the plot command, so i can manipulate it later. any ideas would be appreciated.
i started programming the spectrum when i was 8 :-
1 plot rnd*255,rnd*175
2 goto 1
1 plot rnd*255,rnd*175
2 goto 1
Re: programming a spiral in basic
I'd probably start by writing routing to plot a circle using SIN / COS, them modify it to increase (or decrease) the radius by a small fraction after each plot. That should create a spiralling effect.
Re: programming a spiral in basic
drawing circles the part i dont get
do you mean like this?
https://pasteboard.co/Jt1LGJn.png
https://gofile.io/d/lmu0gb
this is the best i can do
it works but it doesnt seem very manipulable
i started programming the spectrum when i was 8 :-
1 plot rnd*255,rnd*175
2 goto 1
1 plot rnd*255,rnd*175
2 goto 1
Re: programming a spiral in basic
Simplest way to start with something like this in Speccy BASIC, IMO would be:
Then adjust to suit.
You're welcome
(I appreciate it isn't PLOTed - but PLOTed solutions could get quite a bit slower and more involved)
Code: Select all
10 PLOT 125,85
20 FOR a=1 TO 90
30 DRAW a*COS a,a*SIN a
40 NEXT a
You're welcome
(I appreciate it isn't PLOTed - but PLOTed solutions could get quite a bit slower and more involved)
Last edited by p13z on Mon Sep 28, 2020 12:25 pm, edited 1 time in total.
Re: programming a spiral in basic
Using plots
Code: Select all
10 LET R=80 ; INITIAL RADIUS
20 FOR A=0 TO 8*PI STEP 0.1 ; 8*PI = 4 LOOPS, STEP 0.1 = HOW FREQUENT THE PIXELS ARE
30 PLOT 80-R*SIN A,80-R*COS A ; 80,80 = CENTRE OF SPIRAL
40 LET R=R-0.3 ; DECREASE IN R EACH STEP
50 NEXT A
CLEAR 23855
Re: programming a spiral in basic
Dude.p13z wrote: ↑Mon Sep 28, 2020 12:02 pm Simplest way to start with something like this in Speccy BASIC, IMO would be:
Then adjust to suit.Code: Select all
10 PLOT 125,85 20 FOR a=1 TO 90 30 DRAW a*COS a,a*SIN a 40 NEXT a
You're welcome
(I appreciate it isn't PLOTed - but PLOTed solutions could get quite a bit slower and more involved)
Code: Select all
10 FOR d=.1 TO 3 STEP .001
20 PLOT 400,240
30 FOR a=1 TO 180 step 1/d
40 DRAW a/d*COS a,a/d*SIN a
50 NEXT a
60 WAIT SCREEN
70 CLS
80 NEXT d
Re: programming a spiral in basic
Maths note - if you use SQR(A) for the angle where A is the subject of the FOR..NEXT loop and the growing radius is a multiple of A, then that compensates for the increasing radius/circumference and your dots end up evenly spaced, however large the spiral grows.
A shame then that SQR slows everything right down...
A shame then that SQR slows everything right down...
Re: programming a spiral in basic
theres some really good magazine programs on that site... ty
i started programming the spectrum when i was 8 :-
1 plot rnd*255,rnd*175
2 goto 1
1 plot rnd*255,rnd*175
2 goto 1
Re: programming a spiral in basic
This is a tiny addition to my earlier attempt, easy to tweak, just added the third parameter to DRAW.
Rough, slow, but as simple as you can get - bit like me.
Rough, slow, but as simple as you can get - bit like me.
Code: Select all
10 PLOT 127,83
20 FOR a=1 TO 87
30 DRAW a*COS a,a*SIN a,1.08
40 NEXT a
Re: programming a spiral in basic
this was more the effect i was after, like a galaxy...p13z wrote: ↑Tue Sep 29, 2020 5:49 pm This is a tiny addition to my earlier attempt, easy to tweak, just added the third parameter to DRAW.
Rough, slow, but as simple as you can get - bit like me.Code: Select all
10 PLOT 127,83 20 FOR a=1 TO 87 30 DRAW a*COS a,a*SIN a,1.08 40 NEXT a
https://imgur.com/a/6SIX3w1
Code: Select all
1 BORDER 0: BRIGHT 1: PAPER 0: INK 7: CLS
50 LET s=0
100 FOR a=1 TO 4000
120 LET x=SIN a*PI*s
125 LET y=COS a*PI*s/1.45
126 LET s=s+.01
130 PLOT x+128,y+87
200 NEXT a
i started programming the spectrum when i was 8 :-
1 plot rnd*255,rnd*175
2 goto 1
1 plot rnd*255,rnd*175
2 goto 1