Chaos Game

Raconteur's picture

Hi all,

As a learning exercise I decided to put together a QC version of Michael Barnsley's Chaos Game.

The game is simple. Take an equilateral triangle with each vertex colored differently. I used red for the apex, green for the lower left, and blue for the lower right. Then specify a random point. From that point, choose a random vertex and plot the point half-way from the starting point to the vertex. Choose another random vertex, and plot the point half-way between the last point and the new vertex. Repeat across n iterations.

Usually the guess of what this will produce is either "a mess" or "a triangle", but, as Michael Barnsley discovered, it creates a beautiful fractal known as the Sierpinski Triangle, which is a fractalization of equilateral triangles.

Here is the comp. MUCH THANKS to cybero, smokris, gtoledo3, jersmi, and everyone else who chimed in, and stuck with me through a painful learning curve.

I'd love to hear any comments, enhancements, optimizations, etc. that anyone has to offer.

One thing I tried to do, since the QC work I am doing at work involves creation of componentry, was to create macros, and reusable bits. Please feel free to cannibalize this thing and use whatever you'd like in your own work.

Cheers,

Chris

PreviewAttachmentSize
ChaosGame2.qtz27.06 KB

cybero's picture
Re: Chaos Game

thoughtful composition, Raconteur.

Raconteur's picture
Re: Chaos Game

Cheers, cybero.

Is there anything obvious that could/should have been done differently/better that you see?

cybero's picture
Re: Chaos Game

Try lowering the initial number of iterations; saying that I am on 10.6.2, which has been reported to have a little bug with iterations, so this might be more of an issue for 10.6.2 users than other QC / OS X users

Raconteur's picture
Re: Chaos Game

It does indeed run faster with 500 or so iterations, however, the shape does not fill in very clearly.

This thing does not strike me as a process-hog... simple caluclations, and plotting of points. What does is slog so badly with i > 5000?

cybero's picture
Re: Chaos Game

Raconteur, I can't help but wonder about how to improve this, seeing as how you've asked.

I'm sure there must be some way to begin to approach the speed of operation and level of iterative complexity shown in this Java applet --> http://curvebank.calstatela.edu/sierpinski/sierpinski.htm , but using JS & maybe GLSL.

See the Julia example, for instance, in the Developer examples that came bundled with Leopard originally.

Raconteur's picture
Re: Chaos Game

I will certainly delve into those examples more thoroughly now that I have done this on my own. I mostly just wanted something concrete that I could focus on, in order to gain better understanding of QC. But now that I have it done, I am wondering about optimizations and such.

You do not see anything glaringly bad in my approach?

Also, I don't want to pollute this thread with an OT discussion, but if you have a moment, I am posting a question regarding QC and Keynote that I'd love to hear your input on.

Cheers,

Chris