Kinect Skeleton Tracking Test

I’ve spent the last few weeks working with the Kinect to do some 3D skeleton tracking for an upcoming project. After recording the 3D positions of various body parts using the Kinect, I use the data to create a 3D shape, with its size and structure determined by the positions and movements recorded.

Here are some images and videos of work in progress.

32 L-Systems

I spent the last several weeks exploring 3D l-systems, and you can see the results of this study in the new project, 32 L-systems.

Using Cinder, I wrote a program that could generate 3D l-system fractals given a set of initial rules and parameters. The tricky part of the program was getting the transformation from local coordinates to world coordinates to work correctly. It took me several days of frustration before I realized I just had to use matrix transformations (It’s been almost 4 years since I’ve done any matrix multiplication).

The complete set of videos showing all the fractals being generated can be found here.

Source code

L-System

L-System, or Lindenmayer System, is a mathematical formalism originally developed by the biologist Aristid Lindenmayer to describe the growth of simple multicellular organisms. While Lindenmayer initially studied algae and fungi, the L-System was eventually applied to plants and other more complicated structures.

L-Systems can also be used to generate fractal patterns. While I had done something very similar in earlier studies of branching patterns, this time around I actually wanted to see the pattern being drawn. As such, I had to create a simple turtle object that takes the position, angle, and length as the initial parameters and draws a line accordingly.

From there, it was just a matter of creating an iterative structure in the software and setting the rules as to when branches should form, at what angle, and what size. Of course, when writing iterative programs, it’s important to set a breakpoint so that it stops at some point, and doesn’t continue indefinitely. In my studies, I set it so that if the length of a branch is less than 10 pixels in length, it no longer reproduces.

Below are a few images generated by the program:

Videos showing fractals being drawn using the L-System:

Source code

Sierpinski Tetrahedron

After using the chaos game to generate the sierpinski triangle in the last post, I wanted to see if the same iterative process worked in 3D to create the Sierpinski Tetrahedron (aka Tetrix) seen below:

As it turns out, the iterative process is exactly the same, except instead of 3 markers, you now use 4 markers, each positioned at one of the vertices of a tetrahedron. Here’s a video of the fractal being drawn:

Source code

The Chaos Game and the Sierpinski Triangle

We usually imagine images that are randomly generated to appear fairly arbitrary, without any noticeable patterns whatsoever. As it turns out, however, randomness can generate structures and patterns with some very interesting characteristics.

There’s a very interesting class of games known as the chaos games, which involve randomness. I won’t go too deeply into the topic here, but I’ll introduce a simple version.

Imagine you have an equilateral triangle, and at each vertex of the triangle, you place a marker. Now, pick a point anywhere on the plane of the triangle. It can be inside the triangle or outside the triangle, doesn’t matter. Then randomly choose one of the 3 markers, and draw a point midway between the marker and the point you picked. Move to the midpoint, and randomly choose one of the markers again and draw the new midpoint. Repeat this process.

 So what happens after several thousand iterations? As it turns out, the Sierpinski Triangle is generated. This is a pretty surprising result, but below is the image after 5000 iterations, from a program I wrote that runs the chaos game iteration:

Here’s a video of the dots being drawn:

Source code

Sphereflake

Created a sphereflake, which is a 3D version of the Koch snowflake, using spheres. It was originally developed by Eric Haines.

As I could only find photographs of the sphereflake, but not descriptions of the actual iteration, I had to do some trial and error to place the next-level iterated spheres in the right locations. I’m still not sure if this is the exact same one as Haines developed, but it looks pretty close.

There are nine spheres created in each iteration. Six of them are placed 10 degrees below the equator of the orignal sphere, spaced 60 degrees apart from one another. The other three are positioned by finding the midpoint between two of these six spheres, for every other sphere, and then moving upwards 60 degrees. It’s probably a lot clearer to just look at the code.

Source code

Chaos and Fractals, Koch Curve, and Koch Snowflake

I finished reading Chaos and Fractals a few days ago. If you’re looking for a good introductory book on fractals and chaos that doesn’t shy away from mathematics, I highly recommend it. I read the book straight through from cover to cover, and while there are still quite a lot of topics I don’t understand and will be referencing the text quite a bit in the next while, it was good to get an overall view of the field.

Koch Curve

I started to write a few programs to explore the topics covered in the book. One of the earliest fractals described is the Koch curve, named after the Swedish mathematician Helge von Koch.

The curve has many interesting properties, one of which being that its length is infinite. Additionally, while it is continuous everywhere, it is differentiable nowhere.

I wrote a quick sketch in Cinder to create the Koch curve. Of course, being a mere representation, it’s not a real fractal, but it at least gives you an idea of what the curve looks like and the program does use iterations to generate the shape.

Source code

Koch Snowflake

Combining three Koch curves, one can create the Koch snowflake, shown below.

Source code

The programs are pretty simple, and I wrote them mainly just to get the structure of the iterations down. I’m be exploring variations of the Koch snowflake the next few days, and finding ways to add color to the shape. I’ll also be exploring 3D structures that follow the same properties.