Arun Waves

November 26, 2011

Sierpinski triangle

Filed under: code,Processing,sketch — Arun @ 12:21 am
Tags: , ,

Note: It would help to know a little bit about fractals to appreciate this post.

Ever wanted to create a fractal? For those who are not aware of fractals think of it as a special figure that retains its form no matter how much zoomed in you are, a property known as self-similarity. Don’t believe me, check out this and this.

Quite mind boggling in itself, now if someone told you that this can be generated by a random algorithm!! I had to check it out for myself, so I used the familiar and easy to use Processing programming language to test it. You can read about the algorithm here, it basically involves a moving point whose direction is determined by rolling a dice. The point moves half distance towards one of the three vertices of a triangle When the dice has been rolled a sufficient number of times, you can see the Sierpinski Triangle. In this case the main triangle can be broken into 3 triangles which look like the original triangle and sub-triangle can be broken into 3 more similar triangles. See for yourself ……………..

Here are some screen shots;

June 19, 2010

Building a Boid system with Processing sketch

Filed under: Boid,code,Object Oriented Programming,Processing,sketch — Arun @ 5:38 pm

Recently I discovered a wonderful open source software, Processing, which is simple to use and great for visualization applications. My first Processing sketch 🙂

Click on the above link, it will open a browser (you would need Java in your machine). Once the app starts running, move your mouse pointer within the white square box and try to stay away from the red and the blue balls; for interesting response move your mouse pointer in circles of varying radii. I always wanted to say this……. “You take the blue pill, the story ends. You take the red pill, you stay in wonderland”.

This is my first step towards a Boid code. I wrote this code to learn PVector, vector manipulation and OOP (Class). This sketch creates a system with two elements (balls) that try to catch up to the mouse pointer. These elements bounce off the walls and have different accelerations. Red ball’s acceleration is twice that of the blue ball. To begin with the balls start at random locations and also have a maximum speed limitation.

Screen shot 1

Screen shot 2

Next step would be to make these elements interact with each other while chasing the target, which would make it a Boid code.

Took help from PVector and Objects tutorial @
Have fun with the animation. Feel free to comment.

PS: If you want the code then go here.

Create a free website or blog at