Spiral Art

The basic idea behind a spiral is to parametrize like this.......

x=rcosθy=rsinθx = r \cos \theta \\ y = r \sin \theta

....and then gradually decrease the radius as the angle increases. To make things more interesting, you can put sinusoidal variation in the radius too, with different harmonics thrown in to create different effects. The harmonics are added so that their magnitudes are inversely proportional to their frequency, relative to the base frequency. For example, a sinusoidal term with a frequency three times that of the base term has a magnitude one third that of the base term.

I have posted two spirals: one with even harmonics and one with odd harmonics. The code to generate these is also attached. Click the images to enlarge them.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import math

r = 20.0
theta = 0.0

dr = 0.005
dtheta = 2.0*math.pi/400.0

choose = 0

while theta <= 20.0*math.pi:

    if choose == 0:

        # Even harmonic spiral 
        x = r*(1.0 + 0.2*math.sin(20.0*theta) + 0.1*math.sin(40.0*theta) + 0.05*math.sin(80.0*theta))*math.cos(theta)
        y = r*(1.0 + 0.2*math.sin(20.0*theta) + 0.1*math.sin(40.0*theta) + 0.05*math.sin(80.0*theta))*math.sin(theta)

    if choose == 1:

        # Odd harmonic spiral
        x = r*(1.0 + 0.2*math.sin(20.0*theta) + 0.0667*math.sin(60.0*theta) + 0.04*math.sin(100.0*theta))*math.cos(theta)
        y = r*(1.0 + 0.2*math.sin(20.0*theta) + 0.0667*math.sin(60.0*theta) + 0.04*math.sin(100.0*theta))*math.sin(theta)

    print x,y

    r = r - dr
    theta = theta + dtheta

Note by Steven Chase
3 months, 3 weeks ago

No vote yet
1 vote

  Easy Math Editor

This discussion board is a place to discuss our Daily Challenges and the math and science related to those challenges. Explanations are more than just a solution — they should explain the steps and thinking strategies that you used to obtain the solution. Comments should further the discussion of math and science.

When posting on Brilliant:

  • Use the emojis to react to an explanation, whether you're congratulating a job well done , or just really confused .
  • Ask specific questions about the challenge or the steps in somebody's explanation. Well-posed questions can add a lot to the discussion, but posting "I don't understand!" doesn't help anyone.
  • Try to contribute something new to the discussion, whether it is an extension, generalization or other idea related to the challenge.
  • Stay on topic — we're all here to learn more about math and science, not to hear about your favorite get-rich-quick scheme or current world events.

MarkdownAppears as
*italics* or _italics_ italics
**bold** or __bold__ bold

- bulleted
- list

  • bulleted
  • list

1. numbered
2. list

  1. numbered
  2. list
Note: you must add a full line of space before and after lists for them to show up correctly
paragraph 1

paragraph 2

paragraph 1

paragraph 2

[example link](https://brilliant.org)example link
> This is a quote
This is a quote
    # I indented these lines
    # 4 spaces, and now they show
    # up as a code block.

    print "hello world"
# I indented these lines
# 4 spaces, and now they show
# up as a code block.

print "hello world"
MathAppears as
Remember to wrap math in \( ... \) or \[ ... \] to ensure proper formatting.
2 \times 3 2×3 2 \times 3
2^{34} 234 2^{34}
a_{i-1} ai1 a_{i-1}
\frac{2}{3} 23 \frac{2}{3}
\sqrt{2} 2 \sqrt{2}
\sum_{i=1}^3 i=13 \sum_{i=1}^3
\sin \theta sinθ \sin \theta
\boxed{123} 123 \boxed{123}

Comments

Sort by:

Top Newest

@Neeraj Anand Badgujar Per your request

@Karan Chatrath In case you are interested

Steven Chase - 3 months, 3 weeks ago

Log in to reply

@Steven Chase Sir .Thanks Yeah it's also awesome. But I like your profile images more than this. They were more crazy according to my opinion.

A Former Brilliant Member - 3 months, 3 weeks ago

Log in to reply

Creating the profile pic must have been much harder, due to the wireframe and the 3d aspect of it, that too on python.

Krishna Karthik - 3 months, 3 weeks ago

Log in to reply

@Krishna Karthik Yeah, the helix was a much bigger undertaking

Steven Chase - 3 months, 3 weeks ago

Log in to reply

Yeah and the rendering time without GPU wow...

Krishna Karthik - 3 months, 3 weeks ago

Log in to reply

@Steven Chase when I copied this code and run in my computer and plotted in excel I get this image

A Former Brilliant Member - 1 month, 2 weeks ago

Log in to reply

Hmmm... that's interesting... what do you think the error might be?

Krishna Karthik - 1 month, 2 weeks ago

Log in to reply

@Krishna Karthik Bro I don't know, can you run in your computer and reply me what you are getting. Thanks in advance

A Former Brilliant Member - 1 month, 2 weeks ago

Log in to reply

@A Former Brilliant Member Of course! cheers.

Krishna Karthik - 1 month, 2 weeks ago

Log in to reply

@Krishna Karthik @Krishna Karthik bro i am waiting for your comment .what are you getting while running the above code ??
thanks in advance.

A Former Brilliant Member - 1 month, 2 weeks ago

Log in to reply

@A Former Brilliant Member I get the same thing as Steven did. I think you have copied the code wrong.

Krishna Karthik - 1 month, 2 weeks ago

Log in to reply

@Krishna Karthik @Krishna Karthik ok bro let me try again. thanks

btw if you don't mind ,please call him as Steven sir .they are older than us.

A Former Brilliant Member - 1 month, 2 weeks ago

Log in to reply

@A Former Brilliant Member Bro, this is the internet. People are called informally on the internet. Unless they specifically say against that, I am going to just call them by first name.

I think it's some sort of an Indian custom to suffix with sir for someone older. Maybe I'll refer to him as sir if I directly address them.

Krishna Karthik - 1 month, 2 weeks ago

Log in to reply

@Krishna Karthik @Krishna Karthik as you wish bro.it is your choice .

He has helped me so much in physics and maths ,so its my respect for him

A Former Brilliant Member - 1 month, 2 weeks ago

Log in to reply

@A Former Brilliant Member Very true. He has pointed me to so many resources, really great person. He helped me with classical mechanics and inspired me to learn numerical technique. I do respect him a lot. I will address him as sir when I speak to him. Thanks bro, cheers! :)

Krishna Karthik - 1 month, 2 weeks ago

Log in to reply

@A Former Brilliant Member Oh, I think I noticed the error and why the graph is not showing the correct thing. Have you perhaps only chosen one of the columns? Make sure you select both and look at the line, not the line with dots (as it will clutter).

Krishna Karthik - 1 month, 2 weeks ago

Log in to reply

Ha that's really cool! I really like python. Try to paint a Mandelbrot Set!

Krishna Karthik - 3 months, 3 weeks ago

Log in to reply

Here you go

https://brilliant.org/discussions/thread/plotting-the-mandelbrot-set-roughly/

Steven Chase - 3 months, 3 weeks ago

Log in to reply

I think the second spiral looks the best. I really love how it spirals inward.

Krishna Karthik - 3 months, 3 weeks ago

Log in to reply

@Steven Chase sir the code which you have provided above.
i run this code and when plotted in excel and was not giving the figure which is above .
as obvious Thanks in advance

A Former Brilliant Member - 1 month, 2 weeks ago

Log in to reply

Highlight both columns and then plot as a scatter with smooth lines

Steven Chase - 1 month, 2 weeks ago

Log in to reply

precicely, sir. That's what I think the error is too. Scattering with dots will create clutter too.

Krishna Karthik - 1 month, 2 weeks ago

Log in to reply

Yup, buddy, I think you haven't underlined both columns. Plot with smooth lines too.

Krishna Karthik - 1 month, 2 weeks ago

Log in to reply

@Steven Chase sir i have highlighted both columns many times
I am getting this only

A Former Brilliant Member - 1 month, 2 weeks ago

Log in to reply

Nope, it still only shows one column.

Krishna Karthik - 1 month, 2 weeks ago

Log in to reply

put a variable (x) on the x column, yy on the yy column ABOVE the columns; click on xx, hold, and drag it all the way down to the end and click on the smooth line chart.

Krishna Karthik - 1 month, 2 weeks ago

Log in to reply

You should have names above each column. The column on the left will automatically be identified as the independent variable, and the right the dependent.

Krishna Karthik - 1 month, 2 weeks ago

Log in to reply

Click on the left column's name and drag it down, highlighting both columns.

Krishna Karthik - 1 month, 2 weeks ago

Log in to reply

@Krishna Karthik thanks sir but why image above is more clear than my pC image

A Former Brilliant Member - 1 month, 2 weeks ago

Log in to reply

@A Former Brilliant Member You can re-size the plot and make the lines thinner

Steven Chase - 1 month, 2 weeks ago

Log in to reply

@Steven Chase Ah, I was having the same problem too with thick lines. Thanks sir!

Krishna Karthik - 1 month, 2 weeks ago

Log in to reply

@Steven Chase @Steven Chase sir which option should i choose to make it thin

A Former Brilliant Member - 1 month, 2 weeks ago

Log in to reply

Hey, do you use Windows 7 or 10?

Krishna Karthik - 1 month, 2 weeks ago

Log in to reply

@Krishna Karthik 7

A Former Brilliant Member - 1 month, 2 weeks ago

Log in to reply

@A Former Brilliant Member Yeah, I thought so. Is that a Dell laptop?

Krishna Karthik - 1 month, 2 weeks ago

Log in to reply

@A Former Brilliant Member You should upgrade it. I kinda miss Windows 7 though lol now that I upgraded my PC... =..(

Krishna Karthik - 1 month, 2 weeks ago

Log in to reply

@Krishna Karthik @Krishna Karthik windows 10 have more features than 7?
if yes how can i upgrade

A Former Brilliant Member - 1 month, 2 weeks ago

Log in to reply

@A Former Brilliant Member Windows 7 is really outdated now; but Windows 10 is expensive. It's not extremely worth it or anything, but next time you get a PC you will automatically have Windows 10 with it =)

Krishna Karthik - 1 month, 2 weeks ago

Log in to reply

@Steven Chase yeah now it is coming

A Former Brilliant Member - 1 month, 2 weeks ago

Log in to reply

Perfect! Good stuff mate.

Krishna Karthik - 1 month, 2 weeks ago

Log in to reply

Yeah, the reason we are seeing the visible damping in x and y is because of the spiral.

Krishna Karthik - 1 month, 2 weeks ago

Log in to reply

@Steven Chase sir how do you export that image ???

A Former Brilliant Member - 1 month, 2 weeks ago

Log in to reply

Hit the print screen button and then paste it into MS Paint. Then you can crop out the stuff you don't want

Steven Chase - 1 month, 2 weeks ago

Log in to reply

Ah, that is much better than taking a cropped screenshot. It gets so low res for me when I take a cropped screenshot. Thanks for suggesting me the better alternative. Will use MS paint.

Krishna Karthik - 1 month, 2 weeks ago

Log in to reply

Yeah, that's what I was wondering as well. I just take screenshots.

Krishna Karthik - 1 month, 2 weeks ago

Log in to reply

@Krishna Karthik taking screenshot loses the quality if image

A Former Brilliant Member - 1 month, 2 weeks ago

Log in to reply

You can put it onto MS Paint and crop out the rubbish. That's a better way. No losing of res.

Krishna Karthik - 1 month, 2 weeks ago

Log in to reply

×

Problem Loading...

Note Loading...

Set Loading...