Showing posts with label Fractals. Show all posts
Showing posts with label Fractals. Show all posts

Tuesday, October 25, 2011

Koch Snowflake - Reloaded

As stated in my last post I played around a bit with Koch Snowflakes and a variation of it.

After figuring out a way to calculate the triangle-count of the next iteration based on the current count it was possible to prevent program crashes due to vertex-/index-buffer overflows.

Another thing made possible is to "merge" the two generation algorithms, i.e. use one method for iteration x and the other for iteration x+1.

The "classic" Koch snowflake algorithm should look something like this:

  1. Start with a triangle (or a tetrahedron made of 4 triangles) and divide every edge in half.
  2. The 3 new points form 4 smaller triangles with half the size.
  3. The triangle in the middle is the base of a new tetrahedron.
  4. Do steps 1 and 3 for every triangle until desired complexity is reached (which is pretty fast).

"Classic" Koch Snowflake subdivision

The variation I (and some others on the web) used nearly does the same, except the smaller tetrahedron is turned that the edges of the smaller base triangle are parallel with the bigger one:


Now I can combine the two different methods to create interesting new patterns. For example:

  1. Start with the initial tetrahedron, then use classic algorithm (C)
  2. Then use variation (V)
  3. Repeat alternations to create the pattern CVCVC
The pattern CVCVC
And some more...
The pattern VCVCV
The pattern CCVVC
The pattern VVCCV
Many more patterns are possible, I was too lazy generating them all. Maybe on personal request...?

Thursday, October 20, 2011

Winter? - Snowflakes!

As the weather suggests it's pretty much winter here. And what's winter without snow?

So I decided yesterday that it would be fun to bring the Koch Snowflake into the third dimension using the XNA Framework and some libraries I'm working on.

Since the result was a bit too regular (see the images on Wikipedia) and I found a nice video on YouTube with something similar but better looking, I changed my code a bit. And voila: Here it is! My version (of many) 3d Koch Snowflakes...

Be prepared, there is (maybe) more to come...

Initial state
After one iteration
After six iterations
If you are interested in the code, feel free to email me at: f(dot)heinz(at)gmx(dot)net

EDIT:
As my girlfriend stated correctly yesterday, this does not look like like a snowflake since I started from a single triangle. So I changed it to a four faced pyramid. This is the result:
After six iterations