Recursive Pentagons

john's Avatar

john

27 Mar, 2015 07:58 PM

edv closed his/her discussion on Recursion, but it was too interesting of a challenge to pass up.

Attached is a simple network that creates the top example in the golden ratio chart edv supplied. It is somewhat recursive in the sense that each copy of the "newChild" subnetwork takes a parent pentagon and spits out a child pentagon that is sized down using the golden ratio and positioned to align with its parent. To create an arbitrarily deep chain of pentagons you just feed the first child into the second, the second into the third, etc.

The attached Pentagons.png screenshot displays the result for five pentagons and shows how simple the network is. The "newChild" network is also fairly simple with just a dozen nodes. It does a lookup on the length of the parent pentagon path and divides by a constant to determine the parent's radius. This is divided again by the golden ratio to create the child pentagon and also used to calculate the child's position.

You can resize the parent pentagon and all its descendants will follow along. The view in the screenshot shows a parent pentagon with a radius of 144, chid radius of 89, grandchild radius of 55, etc. just like the chart example.

Enjoy!

John

  1. 1 Posted by Rory on 31 Mar, 2015 09:49 AM

    Rory's Avatar

    Very nice!

  2. 2 Posted by Garrett Milliro... on 02 Apr, 2015 12:01 AM

    Garrett Milliron's Avatar

    You were able to create a network that performed the recursive operation, and then copy the network node 4 times and combine their outputs.

    However, the original question was regarding recursion support. Is there plans to create a node which you could attach the network node and select 4 recursions in order to create the same output?

    This would be very handy.

  3. Support Staff 3 Posted by john on 15 Aug, 2015 06:46 AM

    john's Avatar

    Dear NodeBox staff,

    Garrett makes a good point here. As far as I can tell, there is no way to do true recursion with NodeBox nodes (aside from calling Python procedures). True?

    This seems like a strange omission. NodeBox claims to be a functional language yet the premise of other functional languages is that they use recursion in place of loops.

    Have you guys ever thought about a way to allow recursive nodes? It's not immediately clear to me how to do this within the NodeBox paradigm, but there must be a way.

    Maybe you could have a "Parent" node that could only be used inside a subnetwork. The parent node would take the same inputs as the subnetwork it resided in and, if activated, would execute that subnetwork.

    To make a recursive factorial subnetwork you would compare the input to 0 and tie that boolean output to a rendered switch node. If true (1) the switch would return a 1; if false (0) it would return n * parent(n-1) - which you would construct out of multiply node, a subtract node, and a parent node.

    If that wouldn't work, perhaps you could come up some other way of allowing recursion. I sure wish I had something like this for the project I'm working on at the moment.

    Any thouughts?

    John

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Already uploaded files

  • Recursive_Pentagons.ndbx 14 KB
  • Pentagons.png 95.5 KB

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

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

Recent Discussions

29 May, 2024 05:47 AM
29 May, 2024 05:15 AM
29 May, 2024 05:12 AM
28 May, 2024 07:37 PM
25 May, 2024 11:52 AM

 

24 May, 2024 07:39 AM
16 May, 2024 02:11 AM
14 May, 2024 01:29 AM
12 May, 2024 07:46 PM
05 May, 2024 04:38 PM
03 May, 2024 06:50 AM