Sunday, August 15, 2010

What's in a name (or a tree)?

I think this might be a record for my blogging frequency!  Only just yesterday I gave you a lengthy update and here I am back at it again...  =)  too much good stuff to say, I guess.

Since I decided to not work on work over the rest of the weekend, I decided that maybe I'd see if I could make some progress on tree modeling (another back-burner project that's been cookin' for awhile now).  I have been reading about fractals and their recursive nature, and I was inspired that trees seem to show this same nature in the structure as well.  Since it has long been a goal of mine to mathematically model a tree, a logical place to start is to generate the static structure or skeleton of a tree automatically (this takes forever to do by hand).

Today was my first shot at trying to actually implement some code to do this in MATLAB, but low and behold, it worked out alright.  This is only a 2-dimensional version, but you'll get the idea.  It can be easily extended into 3D.  After some trial and tribulation, here is a tree to chew on...  this tree has 3 branches per level and is 4 levels deep.
by changing a couple of numbers, I can very quickly generate a new tree with very different structure...

I am of course still working on the details, so these are only rough-draft trees, but it is exciting to get some visual results so quickly.  Part of why these trees don't look familiar (Beyond the fact that they are perfectly generated and perfectly symmetrical) is that a real tree has gravity acting on it which pull weaker branches down and makes it look a little less upright.  this algorithm is really generating trees that you might think of as having grown upside-down!   of course, it would also help to have thicker lines for the bigger branches, etc.  but all in good time.

 Just a few more variables to throw in their for me to get pictures that will look more like the trees we are trying to model, but this is a good start for today.

I hope y'all have a great week!  G-out

No comments:

Post a Comment