The new NodeBox forum is live! Everything from support.nodebox.net moved here: sign in with the same email to pick up your old posts. Something not working? Write to forum-support@nodebox.net.
Where you can feed it an integer for #generations of using a resample node subdividing points on a polygon (triangle) node.
Each generation effectively subdividing each line with a new point which then becomes coordinates for a new polygon (triangle)...
I failed.
Any advice greatly appreciated!
Nodebox file attached... (sad)
Thanks for this fun challenge and for having the courage to post your valiant attempt.
The reason you had so much trouble is that Nodebox doesn't do recursion. It's an odd and frustrating lapse we have to live with. But in software, where there's a will there's almost always a way.
You can do recursion manually by creating a subnetwork that takes in one triangle and spits out three subtriangles. You can then simply chain together as many of these as you want. See attached screenshot and demo file.
The demo goes nine levels deep by simply chaining together nine Sierpinkski nodes. The result is a Sierpinski triangle with 19,683 subtriangles. If you want to go deeper, just add more Sierpinski nodes.
If you really want a parameter driven solution that lets you simply set a depth you can do that too, though it's a bit of hack. You need to chain together enough Sierpinski nodes to achieve a maximum depth - which will have to be fairly low (as you get north of about 100,000 subtriangles, NodeBox will slow to a crawl). You can then feed lines from each possible depth into some switch nodes, use a depth parameter to choose the depth, and wrap the whole thing in a bigger subnetwork.
You could do that, but I doubt it would be worth the bother. It's quite easy to chain these subnetworks together by hand (just copy paste to get more).
And here, just for fun, is what happens if you colorize those 19,683 subtriangles in hues ranging from red to violet. This shows the order in which the subtriangles get drawn.
Pretty!
John
JG
JGJulian Gosper
Fantastic John! That explains it!
BTW - could you share that cool colour nodebox???
JO
JOjohn
And here, for even more fun, is the triangle animated.
Incidentally, to do this animation I did end up making a parameterized version of the Sierpinski node. Code available upon request.
John
JO
JOjohn
Hey Julian,
Just saw your note above. I guess you did request the code. So here it is (attached).
Perhaps you could take this basic concept and attack some other cool fractals.