Achimedean spiral

Post Reply
User avatar
Dutchman
Posts: 851
Joined: Mon May 06, 2013 9:21 am
My devices: iMac, iPad Air, iPhone
Location: Netherlands
Flag: Netherlands

Achimedean spiral

Post by Dutchman »

Another subject of Rosetta's tasks:

Code: Select all

'Archimedean spiral, in polar coordinates
'by Dutchman, december 2016
/*
In polar coordinates (r,phi) the spiral can be described 
by the equation r=a+b*phi with real numbers a and b.
Parameter a determines the starting point,
while b controls the distance between successive turnings.
*/
' --- constants
dphi=0.1 ' angular increment
a=0 ' starting point on real axis
b=100' amplitude parameter
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+a,y0
' --- loop
DO
  r=a+b*phi
  z=r*EXP(1i*phi)
  DRAW LINE TO x0+REAL(z),y0-IMAG(z)
  phi+=dphi
UNTIL ABS(z)>size
END
Please post it on Rosetta if you can :P
Archimedean spiral.PNG
Archimedean spiral.PNG (257.26 KiB) Viewed 5396 times
Last edited by Dutchman on Mon Jan 02, 2017 3:49 pm, edited 2 times in total.

User avatar
sarossell
Posts: 195
Joined: Sat Nov 05, 2016 6:31 pm
My devices: iPad Mini 2, iPhone 5, MacBook Air, MacBook Pro
Flag: United States of America
Contact:

Re: Achimedean spiral

Post by sarossell »

You're a coding wild man! Looks great.
smart BASIC Rocks!

- Scott : San Diego, California

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: Achimedean spiral

Post by Mr. Kibernetik »

Yes, looks really great!

User avatar
Dutchman
Posts: 851
Joined: Mon May 06, 2013 9:21 am
My devices: iMac, iPad Air, iPhone
Location: Netherlands
Flag: Netherlands

Re: Achimedean spiral

Post by Dutchman »

I have changed the code to the polar form, which is more in accordance to the task description and it reflects SmartBasic's strength with complex numbers. The screenshot has also been adapted. The spiral turns now counterclockwise as to be expected with polar coordinates.

User avatar
Dutchman
Posts: 851
Joined: Mon May 06, 2013 9:21 am
My devices: iMac, iPad Air, iPhone
Location: Netherlands
Flag: Netherlands

Re: Achimedean spiral

Post by Dutchman »

There is a mistake in Wikipedia on the "Archimedian Spiral'. In the equation r=a+b*phi it states that the parameter 'a' turns the spiral.
That is not correct. Parameter 'a' determines the starting point of the spiral.
I have changed the relevant comment in the code accordingly and made some other (minor) changes.

User avatar
rbytes
Posts: 1338
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: Achimedean spiral

Post by rbytes »

I found this quote in the Wikipedia entry interesting.
Virtually all static spirals appearing in nature are logarithmic spirals, not Archimedean ones.

I'm hoping, Dutchman, that you will also write a version of a logarithmic spiral. :)
The only thing that gets me down is gravity...

User avatar
GeorgeMcGinn
Posts: 435
Joined: Sat Sep 10, 2016 6:37 am
My devices: IPad Pro 10.5in
IMac
Linux i386
Windows 7 & 10
Location: Venice, FL
Flag: United States of America
Contact:

Re: Achimedean spiral

Post by GeorgeMcGinn »

I tried this code out and I only get 1/2 of the first loop.

Is that due to the issue with the a parameter?

How do I fix. (I do have the logarithmic spiral program, but the one pictured below is different.

George.
Dutchman wrote:Another subject of Rosetta's tasks:

Code: Select all

'Archimedean spiral, in polar coordinates
'by Dutchman, december 2016
/*
In polar coordinates (r,phi) the spiral can be described 
by the equation r=a+b*phi with real numbers a and b.
Parameter a determines the starting point,
while b controls the distance between successive turnings.
*/
' --- constants
dphi=0.1 ' angular increment
a=0 ' starting point on real axis
b=100' amplitude parameter
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+a,y0
' --- loop
DO
  r=a+b*phi
  z=r*EXP(1i*phi)
  DRAW LINE TO x0+REAL(z),y0-IMAG(z)
  phi+=dphi
UNTIL ABS(z)>size
END
Please post it on Rosetta if you can :P

Archimedean spiral.PNG
George McGinn
Computer Scientist/Cosmologist/Writer/Photographer
Member: IEEE, IEEE Computer Society
IEEE Sensors Council & IoT Technical Community
American Association for the Advancement of Science (AAAS)

User avatar
rbytes
Posts: 1338
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: Achimedean spiral

Post by rbytes »

Wikipedia shows a clever application of Archimedean spirals to make a compressor. I have attached the animated gif showing a 2D cutaway of the action. One spiral is fixed, and the other rotates on an off-center axis. Imagine these two spirals as 3d shapes sealed inside a cylindrical container. Liquid or gas enters via an inlet outside the spirals. A quantity is trapped against the fixed spiral by the moving spiral on both sides simultaneously, and then pushed to the center, where it exits the container.

There is a lot more information about spirals on W.
Attachments
IMG_9261.GIF
IMG_9261.GIF (54.32 KiB) Viewed 5336 times
The only thing that gets me down is gravity...

User avatar
sarossell
Posts: 195
Joined: Sat Nov 05, 2016 6:31 pm
My devices: iPad Mini 2, iPhone 5, MacBook Air, MacBook Pro
Flag: United States of America
Contact:

Re: Achimedean spiral

Post by sarossell »

Reminds me of a Rankle rotary engine.
e6bdc8faff.jpg
e6bdc8faff.jpg (174.18 KiB) Viewed 5328 times
smart BASIC Rocks!

- Scott : San Diego, California

User avatar
rbytes
Posts: 1338
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: Achimedean spiral

Post by rbytes »

Looks like the offset drive would be similar. They also have in common a lot of surface area that has to be sealed between the moving and stationary parts.
The only thing that gets me down is gravity...

Post Reply