Page 1 of 1

Logarithmic spiral

Posted: Mon Jan 02, 2017 8:49 pm
by Dutchman
A logarithmic spiral, derived from the code for Archimedean spiral viewtopic.php?f=20&t=1696

Code: Select all

'Logarithmic spiral, in polar coordinates
'by Dutchman, january 20
' --- constants
dphi=0.1 ' angular increment
a=0.1
b=0.1
GET SCREEN SIZE sw,sh
x0=sw/2 ! y0=sh/2
size=MIN(x0,y0)
' --- initiate graphics
GRAPHICS
GRAPHICS CLEAR 1,1,0.5
DRAW COLOR 1,0,0
DRAW SIZE 2
' --- initiate 
DRAW TO x0,y0
' --- loop
DO
  r=a*EXP(b*phi)
  z=r*EXP(1i*phi)
  DRAW LINE TO x0+REAL(z),y0-IMAG(z)
  phi+=dphi
UNTIL ABS(z)>size
END
logarithmic spiral.PNG
logarithmic spiral.PNG (87.69 KiB) Viewed 2494 times

Re: Logarithmic spiral

Posted: Mon Jan 02, 2017 9:07 pm
by rbytes
Thanks, Dutchman. 8-)

Re: Logarithmic spiral

Posted: Tue Jan 03, 2017 1:14 am
by Operator
I like this, so an animated version had
to be included... :D

Code: Select all

'Logarithmic spiral, in polar coordinates
'by Dutchman, january 2017
' --- constants
dphi=0.1 ' angular increment
a=0.1
b=0.1
GET SCREEN SIZE sw,sh
x0=sw/2 ! y0=sh/2
SIZE=MIN(x0,y0)

' --- initiate graphics
GRAPHICS
GRAPHICS CLEAR 1,1,0.5
DRAW COLOR 1,0,0
DRAW SIZE 2

SPRITE 1 BEGIN sw,sh
SPRITE 1 END
' --- initiate 
DRAW TO x0,y0
' --- loop
SPRITE 1 BEGIN
DO
  r=a*EXP(b*phi)
  z=r*EXP(1i*phi)
  DRAW LINE TO x0+REAL(z),y0-IMAG(z)
  phi+=dphi
UNTIL ABS(z)>SIZE
SPRITE 1 END
SPRITE 1 SHOW
'END

LOOP:
dang += 0.001
SPRITE 1 AT 0,0 ANGLE dang
GOTO LOOP

Re: Logarithmic spiral

Posted: Tue Jan 03, 2017 2:46 am
by sarossell
I am getting sleepy.......... :shock: