22 August 2010

Sierpinski triangles IN SPACE

To conclude the madness, here's the third and final Sierpinski triangle program my twisted mind has forced me to code:

C-C-C-C-CHAOS GAME

This version uses what Wikipedia cheerfully refers to as a http://en.wikipedia.org/wiki/Chaos_game to very slowly and painstakingly conjure a Sierpinski triangle out of a set of slightly randomised points.

The process results in an end result somewhat like this:

Out of chaos, order.

I apologise in advance for the state of the code - especially the fact that I've left a remnant of the iterative version's triangle-drawing code in as part of the method to start the chaos game. Also, the program deliberately ignores the first 6 points, as the first points have a tendency not to lie in the Sierpinski triangle.

I promise that this is the last you'll ever hear of the damned things for quite a while.

No comments: