Recursive Tree Animation
This realistic, leafy, swaying 3D tree is actually a VERY simple 2D recursive tree graph. I came across the formula in a recent book by David Auerbach, Bitwise. Translated from Logo the algorithm goes something like this:
define tree ( level, size, scale, angle):
if level > 0:
draw left branch
tree (level-2, size*scale, scale, angle)
draw right branch
tree (level-1, size*scale, scale, angle)
end if
end tree
Sadly, NodeBox doesn't do recursion. But you can come close by making a subnetwork that can take itself as an input and string together as many as you need to reach a desired recursion depth. After seven levels (over 8700 line segments) NodeBox starts to bog down, but that is enough for a nice rendering. Add a little color, attach a frame and wave node to the angle parameter, and you have a beautiful bouncing baby tree.
Screenshot, zipped NodeBox file, and animated GIF attached. Enjoy!
John
-
tree_screenshot.png 1.45 MB
- recursive_tree.zip 3.97 KB
-
tree.gif 2.22 MB
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by Frederik De Ble... on 10 Sep, 2018 07:13 PM
Very cool! I often use L-systems for this type of animations.
The ultimate book about this is "The Algorithmic Beauty of Plants" (PDF) by Aristid Lindenmayer himself. My colleague Stefan translated these algorithms to NodeBox Live — I'll ask him for a link.
Support Staff 2 Posted by john on 10 Sep, 2018 10:34 PM
Frederik,
Thanks for the book reference - this looks *very* interesting. I look forward to getting Stefan's link.
There has been some discussion about L-systems before in the NodeBox forum. In fact you created a GitHub issue to track it back in 2013: https://github.com/nodebox/nodebox/issues/332
But my understanding is that NodeBox 3 still does not play well with L-systems due its lack of recursion and state. So when you say you often use L-systems for this type of animation, did you mean using Stefan's NodeBox Live code? Or some other tool?
As you know, I would very much like to see support for L-systems, fractals, and recursion in general within NodeBox 3. I gather you had something in Nodebox 2. Any chance of porting it to 3?
Thanks!
John
Support Staff 3 Posted by Stefan Gabriels on 11 Sep, 2018 08:23 AM
The L-systems demo of NodeBox Live lives here:
https://nodebox.live/demo/lsystem
But the recursion happens within the LSystem code/node itself and not on the network level. This is something we can't do yet. In NodeBox Live we have a stateLoad and stateSave node though and with those we can reuse the output of nodes between animation frames. For example this way we can implement something like a counter in a recursive way, but this only works when using it with successive frames.