nortikin / sverchok

Sverchok
http://nortikin.github.io/sverchok/
GNU General Public License v3.0
2.21k stars 234 forks source link

Full 2d and 3d L-Systems Node #333

Closed zeffii closed 9 years ago

zeffii commented 10 years ago

In the past i've implemented this in Javascript in d3.js (live demo here) but it's only 2d. There are various ways to implement L-systems and i've wanted to do a 3d L-system for some time now.

http://algorithmicbotany.org/papers/abop/abop.pdf second time reading this now. this time slower :)

enzyme69 commented 10 years ago

L-Tree, something that I never got to master. Even there is this node in Houdini, this single node is so complex and required a class of itself.

Would like to see what you come up with.

The recursive and fractal business is often a headache for me.

nortikin commented 10 years ago

coool

zeffii commented 10 years ago

image read all the code comments...and the only place you have to modify code is those two lines..

nortikin commented 10 years ago

a!!!

nortikin commented 10 years ago

i changed many parameters. never read instructions ))

nortikin commented 10 years ago
// variables
var bend = 2*(-35.5),                    // angle to twist (degrees)
    i_max = 8,                              // limit, warning 10 is probably an upperlimit
    i_user = Math.abs(Math.floor(7)),       // scrub between 1 and upperlimit for recursion levels
    iterations = Math.min(i_max, i_user),   // number of rewrites (recursion levels in grammar)
    F = 5890/(Math.pow(2.4,iterations)),    // arm distance
    angle_offset = to_rad(bend),            // angle as radian
    angle_rad = 0,                          // the current angle for drawing
    x_start = 351,                          // drawing start x
    y_start = 398,                          // drawing start y
    x_current = x_start,                    // current cursor position x
    y_current = y_start,                    // current cursor position y
    rules = {},                             // a map of the rules
    commands = {};                          // a map of the commands
zeffii commented 10 years ago

image

zeffii commented 10 years ago

image

already quite powerful, almost a direct port from the 2d .js code written by Jeff Steward and myself. ( https://groups.google.com/d/msg/tributary/9kI-CGVVQb4/J6joc8q6VhwJ ) https://github.com/nortikin/sverchok/blob/master/node_scripts/templates/zeffii/L-system_initial.py

zeffii commented 10 years ago

Next is pen up / pen down / store location / restore last stored location

zeffii commented 10 years ago

updated the SN script to have more meaningful inputs. https://www.dropbox.com/s/qiydtv162aoz6ny/fast_rerwier_lsystem2bender.blend modify the bend factor, you'll see some interesting shapes.

zeffii commented 10 years ago

Plans for the 3d implementation

It helps to think of the L-system as being 3d pen drawing with something akin to a 3d cursor to determine the point in 3d space.

because simple - and + are only good for 2d drawing, a different single character convention will have to work to place the pen at a new 3d vector, rotated relative to the last vector. Thinking in sparse

..still not fully settled on this

ly29 commented 10 years ago

I'm looking forward to playing with this a lot.

zeffii commented 9 years ago

close for now. It's not super important anyway.

zeffii commented 7 years ago

https://cis700-procedural-graphics.github.io/files/lsystems_1_31_17.pdf

enzyme69 commented 6 years ago

@zeffii Animation Nodes is having L-System node, I have not tested your node either. But awesome implementation from artistic and design perspective.

nortikin commented 6 years ago

@elfnor lsystem is GA_node.py That is it. use it, please

nortikin commented 6 years ago

pushing example json to master in shapes. Slao there is Elfnor's Generative art node, that represent kind of L-systems as i understand.