We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexDiscussionExhibition › Parametric L-System
Page Index Toggle Pages: 1
Parametric L-System (Read 3139 times)
Parametric L-System
Mar 15th, 2010, 7:00pm
 
Thanks to PhiLho for pointing out I can use JavaScript inside Processing, and to John Snyders @ www.hardlikesoftware.com for giving me some ideas (which I didn't use at all, but ideas keep brainjuice pumping).

What I do here is string substitution (is there a more efficient way to do that Processing doesn't seem to have a strsubs() function or similar), and uses JS to evaluate strings as math and logic.

Still needs some work. Currently, it can't process strings with more than one "syllabe" (an atom plus its parameters), and if the rule doesn't match, it will become null (it should test the next rules, and if all fail it should leave the string as-is).

Do you have any suggestions I'm worried about efficiency when the number of rules and the size of the string start to increase. Specially about repeatedly using regexp to explode the string being tested. Perhaps I should pre-process it into syllabes, then test each syllabe against each rule Code is pretty straightforward to check if the rle applies, it just takes longer to process the result in case it does.

http://openprocessing.org/visuals/?visualID=8255

(code just outputs text to the console, unfortunately. Tomorrow I may use text to write it on the applet, but for now you should download it to see it working. Any keypress will iterate the LSystem one generation)
Re: Parametric L-System
Reply #1 - Mar 16th, 2010, 3:18am
 

Hello,

you might be interested in this thread,
especially this post:

http://processing.org/discourse/yabb2/num_1231188421.html#13

Also for replacing within a string:

http://processing.org/discourse/yabb2/num_1267651569_3.html#3


Greetings, Chrisir   Wink


Re: Parametric L-System
Reply #2 - Mar 16th, 2010, 5:23am
 
If you are interested in the source code for a pure Java based implementation of context-free L-systems using ANTLR have a look at this page:

web.archive.org/web/20080203202325/http://www.lindenmayer.innercitylife.net/

Unfortunately it's down, but you might still be able to contact Frank.
And in case you know some German - the accompanying paper can be found here:

www.iti.cs.tu-bs.de/~waetjen/Studienarbeiten/Boehmer.pdf
Re: Parametric L-System
Reply #3 - Mar 16th, 2010, 6:15am
 
Another approach to consider might be to use javascript directly within processing.js http://processingjs.org/reference/articles/best-pratice, developing your own parser tool could be a real pain (the idea of using ANTLR has some appeal, may'be as some kind of pre-processor). I suppose it depends what drives you, I think there are easier ways to deal with parameters in LSystems. You might also be interested in having look at the context free source which is written in C++, they use lex/yacc/bison parser tools.
Re: Parametric L-System
Reply #4 - Mar 16th, 2010, 7:23am
 
Thanks for the replies, guys.

@ Chrisir: I know about turtle drawing, but I'm planning on representing the system differently (think of http://www.michael-hansmeyer.com/projects/project3w.html Hansmeyer's L-Systems, but 2D and way less complex), so for now I'm not implementing graphics until I get a hold of the engine behind the system. And then it will be more hard work getting the graphic engine to work ;) And for replacing a string, unfortunately that was on a different context: they had the index for the character to be replaced, where I want to replace occurences of a string for a different string.

@bit.craft: Well, I know some german, but not enough for a scientific paper! Well, maybe, for luckily math is universal, and I'm quite good at that.

@martin_p: I also think there are easier ways to deal with Parametric L Systems, unfortunately none that I think of is suitable for Processing, at least not without consuming a whole lot of memory on objects and function stacks and stuff. But then, my approach has a fairly large function stack, so I might try something different. The thing is I really want to keep this in Processing, for it is just the missing piece on a larger project.

Do you suppose having "syllabes" as objects makes things easier while not wasting much memory My main concern is in creating rules. You see, on my code, it's as simple as
Code:
 Rule ruleA = new Rule("F(t):(t>1)->F(t-1)");  


and JS processes the string as code. If I could do something similar purely on Processing, I'd be glad ^_^
Re: Parametric L-System
Reply #5 - Mar 16th, 2010, 10:39pm
 
That Hansmyer stuff looks fantastic, have you looked at the Anar+ processing library http://anar.ch/ of Guillaume Labelle, or tried StructureSynth If you are going to stick with 2D and haven't tried playing with contextfree, I recommend you give it a go, it is a lot of fun, like doing visual Sudoko.
I think you will find (quite quickly) that things like the Sierpinski gasket are a special case. You will probably need to consider things like order of rendition (otherwise you end up with just a blob of overprinted shapes), transparency and the Z depth function can give you some control. The Sierpinski is also an interesting case in that the terminals (triangle, square or circle) are largely irrelevant as the end result is the much the same at higher resolutions.  As you say the stack gets pretty big, which they control by writing out intermediate results to temporary files.  Cheesy
By the way they (the mountain view Mark and John) couldn't resist it and are producing a 3D version in the near future, however with the sort of stuff kipling and pakin produce with the existing software you would think they had it already Smiley
Re: Parametric L-System
Reply #6 - Mar 17th, 2010, 9:34am
 
I've read about StructureSynth, but I never got around trying it, or even seeing what it can do. As for contextfree, I think someone mentioned it here on the forums on some other topic, but I haven't pursued it.

Now this anar+ seems pretty awesome. The first thing that pops up in the demo video is the external editor with javadoc-like help, highlighting of declared variables, etc. Is it part of the anar+ package, or is it independant

martin_p wrote on Mar 16th, 2010, 10:39pm:
You will probably need to consider things like order of rendition (otherwise you end up with just a blob of overprinted shapes), transparency and the Z depth function can give you some control.

Yeah, I know. That's one of the reasons I haven't tried doing it yet!

martin_p wrote on Mar 16th, 2010, 10:39pm:
The Sierpinski is also an interesting case in that the terminals (triangle, square or circle) are largely irrelevant as the end result is the much the same at higher resolutions.

You know, that's usually true for Iterated Function Fractals, tho that's not what I'm aiming for (tho most IFFs can be written as LSystems, usually of the simple kind)

In any case, I'll check ouy what anar+ and structuresynth can do for me. I'll post again when something new happens, thanks.
Re: Parametric L-System
Reply #7 - Mar 17th, 2010, 12:14pm
 
Looks as though its the Eclipse IDE to me, there's even a tutorial on using Anar+ in eclipse included at the site. I've translated a couple of the examples to run under ruby-processing, and found some comments about lack of ProMidi libraries which I mentioned on my ruby-processing blog. Guillaume left me the comment that the ProMidi library isn't for sound, as you might expect having watched the video, but for the possible control of the sliders through Midi (when both the library and a midi input is found).
Page Index Toggle Pages: 1