Last night while I was supposed to be doing calculus, I got distracted by watching some of Vi Hart's videos. In particular, I was fascinated by her series on fractals.







Using the power of recursion, I made a small python script to draw the dragon curve, Koch curve, and Sierpinski triangle to an arbitrary depth. It uses the turtle library to make displaying stuff easy.

Here's a link to the gist: https://gist.github.com/Ivoah/7fc4173940eca415e352
That looks great! I'll have to watch those videos in more detail when I have time, as it looks like they make what can be a complex concept more approachable. Do you have any screenshots of your output you can share? What's the runtime like? For your Python, I strongly recommend more descriptive variable names. I assume one of those variables is a maximum depth, for example, but it's tough to tell which one (l?).
KermMartian wrote:
Do you have any screenshots of your output you can share?



KermMartian wrote:
What's the runtime like?

It took ~1 minute and 32 seconds to make the picture above. I could speed it up by not using a recursive algorithm, but I won't, because I made this specifically to do recursion.

KermMartian wrote:
For your Python, I strongly recommend more descriptive variable names. I assume one of those variables is a maximum depth, for example, but it's tough to tell which one (l?).

Haha yeah, I really ought to. Keep in mind that this was written at 12 at night, so descriptive names weren't high on my list of priorities. I'll probably go back and fix it up a bit at some point.
Fun next step: port your code to PostScript, dig up an old PostScript printer, and send your program over. Stopwatch how long it takes to print one page at various recursion depths.
elfprince13 wrote:
Fun next step: port your code to PostScript, dig up an old PostScript printer, and send your program over. Stopwatch how long it takes to print one page at various recursion depths.
Oh, that is genius. I would definitely love to see that in action.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement