# L-Systems

## Recommended Posts

I've thought of an interesting project for myself that involves use of L-Systems but since this is my first dive in to the subgect I feel that I'll have meny questions for days ahead. So I've desided that it would be a good idea to keep'em all in one place rather than scattered all over the board.

Let's start.

What's a Tropism Vector?

What are the {} there for? I mean, I know that one of them start and the other end polygon but isn't polygons allready there if you choose Tube on the Geometry page?

##### Share on other sites

you should have posted in my thread...my ambition is to make it the longest thread in the world...LOL

anyway...

from the geometry.pdf:

GRAVITY

This parameter determines the amount of gravity applied to the geometry via the T

(tropism vector) turtle operator. Tropism is when a plant bends or curves in response

to an external stimulus. L-systems employ a tropism vector to simulate this behaviour.

The bending is characterised by the fact that the thicker or shorter parts bend

less than the longer or thinner parts.

as for {}, I don't really know...I've yet to try using them...and I haven't seen any examples so...

##### Share on other sites

you should have posted in my thread...my ambition is to make it the longest thread in the world...LOL

I didn't know, But if you can get admins to move these three posts to your thread I will gladely contribute to your noble undertaking and post all my questions there

Here is one more, not really spesific question this time.

I have a Curve and an L-System made of one, long stem which I want to sorta bind to a curve that lies inside L-System.

I want to be able to edit the curvature of the stem by moving vertices in Curve SOP.

Any suggestions?

Thank you!

##### Share on other sites

I've been working on something alot like that but haven't figured it out yet....

so far all I can think of is to use a creep...

I had an idea yesterday to use bones....it would be like a 'follow curve' but instead of bones following the curve it would be an l-system...haven't tried it yet...plus I think it might just be to heavy....

another idea I had is to use many small l-systems copied onto a curve...but I can't figure out how to get the orientation of each copy to follow the curve...was going to try it today but haven't had any time...doing some Maya stuff for work

##### Share on other sites

Ok.

There is this \$turtle operator used in conjanction with(x0,y0,z0) operator override to point a turtle in to spesific location.

Like this \$(x0,y0,z0)

Well, I tried putting it this way...

```Premise: A
Rule #1: A=\$(x0,y0,z0)\$(x0,y0.1,z0)\$(x0,y0.3,z0)```

...and no geometry was generated

Can anyone tell me how to point a turtle in to desired location with this override?

Thanks.

##### Share on other sites

The \$ operator makes your turtle look to that specified point. It doesn't move to that position. What you want to reach could be done like this:

```
Step-size: 1
Premise: A
Rule1: A=\$(0,1,0)FB(1,0,0)
Rule2: B(i,j,k)=\$(i,j,k)F(((i-x)^2+(j-y)^2+(k-z)^2)^0.5)```

This L-System goes up one unit. The in rule 2 the turtle is orientet to look at the point (i,j,k) and the long F-statement determines the distance, the turtle has to walk to this point. Using rule B you can walk with the turtle to any position in space.

To you question about the {}. I haven't used them, but there is a nice preset in Houdini, which might be usefull to you. In the presets-menu of the parameter-pane select "load...". Go to the "lsystem"-directory and select "propellor.preset".

Hope this helps.

Frank

##### Share on other sites

Excerpt from Geometry.pdf

Note that the variables in the predecessor can also be referenced by the condition or

probability portions of the rule. For example, the rule:

A(i):i<5 = A(i+1) A(i+1)

will double each A a maximum of five times (assuming a premise of A(0)).

I've tried inputting it like this:

```Premise: A(0)
Rule #1: A(i):i&lt;5 = A(i+1) A(i+1)```

...and nothing happend.

What's wrong? Should there be some value assigned to i or does it have some static value, much like \$F for example.

##### Share on other sites

what are the other rules?

if that is all you have then it won't do anything

I think the premise A(0) assings i = 0

##### Share on other sites

It's just an example from L-System SOP help document. Just this one string.

I suspected that there is more to it than this but wasn't shure.

I don't understand what is going on in this rule. Is the part of the rule before equatation symbol some sort of an if statement?

##### Share on other sites

Yes the part between the : and = is a condition (or implicit if-statement), which determines, if the rule can be applied to the current token of the string.

A better example would have been:

premise: A(0)

rule1: A(i):i<5=F+A(i+1)

This system stops to grow after 5 generations, because then then the derived string would be

F+F+F+F+F+A(5)

The F and + are terminal symbols. The token A(5) doesn't fit to any rule, because the rule1 only applies for i<5. This means, that there is no derivative to this string. The "plant" stops growing.

If you add a rule like:

rule2: A(i):i>=5=F-A(i+1)

then the "plant" will turn the direction after 5 generations.

Remember: Always check the derived string by middle-clicking on the LSystem-SOP.

##### Share on other sites

Ok

So what does this ----> : thing do and what is that part of the rule before it?

I'm confused by this type of rule! I mean it looks almost like it's being exequted from middle(part between : and =) and in two directions. To the right and to the left(support for Arabic languages )

Another thing is...how can it be that you can have two rules with the same name at the same time and use them both at the same time?

Thank you!

##### Share on other sites

```A Houdini L-system rule is specified as:
[lc&lt;] pred [&gt;rc] [:cond]=succ [:prob]
where:
lc Optional left context
pred predecessor symbol to be replaced
rc Optional right context
cond Condition expression (optional)
succ Replacement string
prob Probability of rule execution (optional)```

so the " : " is just a seperator for the optional condition

as for having two rules with the same name and using them at the same time...I don't think you can

the eg in the docs have two rules :

A =

A =

but there are conditions for both of them:

A(i) : i<5 = F (i+1)

A(i) : i>5 = FF

so the rules aren't the same because they are only evaluated if the condition is true...

or something like that

##### Share on other sites

Yes the : is just a separator, so that Houdini knows, where to find the symbol to replace, the condition and the successor of the rule. When it comes to context-sensitive rules (that means you tell Houdini to replace symbols only, if they are standing next to another specified symbol in the derived string), you also have the separators < and > for the left and right context. For stochastic rules there is a second : separator to specify the probability to apply the rule. Using stochastic L-systems are another case, where specifying the same rule multiple times can be handy. For example:

premise: A

rule1 A=+FA:0.5

rule2 A=-FA:0.5

You must make sure, that the probabilities sum up to 1. While evaluating this L-system, Houdini determines every generation, which rule to use, by randomly picking rule 1 or 2 (obeying the specified probabilities). For example, if you adjust the probabilities of rule1 to 0.7 and rule2 to 0.3, the line will bend more likely to the right, than to the left. Another advantage of stochastic L-systems is, that you can get different looking instances of it by simply moving the "Random Seed" slider on the geometry-tab of the SOP.

##### Share on other sites

Big thanks for the input guys!!!

##### Share on other sites

```Premise   A(0)
Rule1      A:in(x,y,z)=B
Rule2      B(i):i&lt;5=F(0.01,0.01)[+B(i,0)][-C(i,0)]B
Rule3      C(i):i&lt;5=F(0.01,0.01)-(5)C
Rule4      D(i):i&lt;5=F(0.01,0.01)+(5)D```

Can anyone tell me please, why L-System generated by these rules still grows outside of metaball?

Thank you!

##### Share on other sites

hrm...

well for one thing you're not telling the l-system what to do when A is not within the meta-test object..

but I just tried to use:

A: ! in(x,y,z) = A%

like in the docs...but something still isn't working...

##### Share on other sites

Stremik, you test only 1 time, if your L-System is inside the metaball. Namely at the first generation, where A is going to be replaced with B. Then there will never be an A in the string and no testing of being inside the bounding-volume is done after the 2nd generation anymore. To test in every step, you can modify the conditions of your other rules to i<5&in(x,y,z). The & is a logical "and"-operation and is true, if the both sub-conditions, the one to the left (i<5) and the one to the right (in(x,y,z)), are true simultaneously. If only one or none of them is true, then the whole condition is false.

What your L-system does in fact, is testing the start-point to lie in the metaball and if this is true, then it grows unconstrained.

Also you don't need to write a rule for the case, that a token is not within the metaball. If there is no rule, then the symbol won't be replaced. This is most often the same as thinking of the plant to stop growing.

##### Share on other sites

AHHHH....

yes, I see now....

I wasn't sure about the & ...

and didn't know you didn't have to state a rule for the case of it not being within the meta-test object...

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×