[OpenSCAD] Barnsley Fern recursive

doug moen doug at moens.org
Wed Sep 12 12:49:52 EDT 2018


Ronaldo said: " Anyway, as this fractal may be generated without recursion
that would
be a preferable path to go."

Yes, but how do you code it without recursion in OpenSCAD?
The Barnsley Fern is an Iterated Function System, where the result at
iteration i+1
depends on the result of iteration i.

The only language feature that supports this kind of iteration, without
using recursion,
is the C-style for loop, which is only available in list comprehensions,
not in modules.
For this, you need a development snapshot with the "C-style for" option
enabled
in Preferences.

So, I would try generating all of the coordinates into a list, using a
C-style for loop
inside a list comprehension. And I'd use a simpler polygon for each point,
to further
reduce resource consumption: like a triangle, square, or hexagon.

On 12 September 2018 at 11:42, Ronaldo <rcmpersiano at gmail.com> wrote:

> Eric,
>
> The probabilities in your code does not agree with the definition found in
> Wikipedia <https://en.wikipedia.org/wiki/Barnsley_fern>  . Besides, a full
> recursion stop rule is missing in the recursive module so regardless the
> memory allocation size you will always get a stack overflow with
> probability
> one. Anyway, as this fractal may be generated without recursion that would
> be a preferable path to go. Finally, you would need a very large number of
> circles to get a reasonable picture of the fractal and this may surpass the
> limits of the OpenSCAD node tree.
>
>
>
> --
> Sent from: http://forum.openscad.org/
>
> _______________________________________________
> OpenSCAD mailing list
> Discuss at lists.openscad.org
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscad.org/pipermail/discuss_lists.openscad.org/attachments/20180912/981069ac/attachment.html>


More information about the Discuss mailing list