<p>First, I'll note that <code>cpfg</code>, the plant-modeling software used in the creation of &quot;The Algorithmic Beauty of Plants&quot;, has recently been open-sourced at <a href="https://github.com/AlgorithmicBotany/vlab" rel="nofollow noreferrer">https://github.com/AlgorithmicBotany/vlab</a> so you can look it up yourself!</p>
<p>Briefly, though, you're right that plant axes are just cylinders swept along a polyline. There was no effort made into making these models watertight; the cylinder swept by lateral branches intersect the main branch geometry. In general, it's a hard problem to nicely skin branch intersections. There was some published work on it at that lab, <a href="http://algorithmicbotany.org/papers/macmurchy.th2004.html" rel="nofollow noreferrer">The Use of Subdivision Surfaces in the Modeling of Plants</a>, which tried to solve the problem by using low-poly branch templates; they still had difficulties for axes with many close branch points, if I recall.</p>

CC BY-SA 4.0
2023-02-09T09:01:45.540Z
2023-02-09T09:01:45.540Z
gilgamec
<p>A popular method of generating the mesh from an L system is called a &quot;Turtle Graphics&quot; system.</p>
<p>In a turtle graphics system we imagine a turtle which starts at the root of the system reads a symbol from the L system and walks in a specific direction based on the symbol. The symbol itself is associated with a polygon and the entire system is seeded with a polygon from the root symbol.</p>
<p>The polygons themselves can be generated algorithmically by the system and then modified for each generation of the plant or predefined such as a simple N sided circle.</p>
<p>As the turtle marches through the L system each symbol gives it instructions on direction and how many steps to take. For example, a turtle may be instructed to move 3 steps in the up direction.</p>
<p>The turtle starts at the seeded polygon, reads the symbol, takes a step and places the polygon for that symbol. Taking a step usually includes a &quot;turn&quot; this translates into a rotation matrix for the polygon being placed where the turtle represents the origin for the coordinate frame used to do the rotation and the turtles position becomes the translation. Then the two polygon's are connected. A simple and effective way to connect two polygons is: find the two nearest vertices, n and m, the generate vertex attributes in the order n,m,n+1 mod t,m+1 mod t...n+t mod t,m+t mod t where t is the total number of vertices. When t is not equal in the two polygons a combination of splitting the longest edge,  and connecting multiple vertices in n to a single vertex in m (or vica versa depending on the vertex count) can be used.</p>
<p>Some simple checks should be run for each pair of polygons. 1) Make sure the polygons are planer. 2) Make sure the polygons are wound consistently 3) At connection time make sure all vertices in the
polygon being placed are on the same side of the connecting polygon's plane. Vertices that pass through the plane will need to be adjusted so they are slightly above the plane of the other polygon.</p>
<p>Normally there is one main &quot;trunk&quot; for the turtle to follow, each branch is reinterpreted as a new turtle with a new seed polygon. Branch's can be integrated into the main structure by clipping each branch against the triangles of the main trunk. Some systems will allow branch's to intersect, others will do collision checking. Here again the can be special symbols that define the transition between the main structure and a branch, this allows for smooth transitions of UV coordinates.</p>
<p>Leaves can be single symbols represented as a single polygon, or an entire L system with its own turtles which is slow to generate but the results are stunning. Yet another approach is to generate a handful of leaves and the L system associates a symbol with each leaf.</p>
<p>Done correctly this results in a well defined structure. The root node can be closed off to make the polyhedron water tight.</p>

CC BY-SA 4.0
2023-02-13T13:44:32.450Z
2023-03-07T12:08:24.887Z
2023-03-07T12:08:24.887Z
pmw1234
<p>I read the Algorithmic Beauty of plants.The resource goes in depth as to how to generate plant topology, but it does not talk about how to make the geometry except for the leaves.</p>
<p>I tried looking into packages such as <a href="https://github.com/openalea/plantgl" rel="nofollow noreferrer">plantgl</a> bbut I am still not entirely sure how they are making it.</p>
<p>I understand they use sweep surfaces, but are they putting any effort into ensuring their models are manifold? Or are they just piece wise parametrizing each 1D section and not bothering to guarantee watertighntnes?</p>
<p>Is there a way to grab a plant topology and parametrize it into a watertight mesh?</p>

CC BY-SA 4.0
2023-02-09T13:06:44.683Z
look up L systems for generating plants, the book mentioned in the answer also goes into it nicely.
pmw1234
CC BY-SA 4.0
2023-02-09T23:57:41.973Z
That generates plant topology, not geometry. Which is exactly what i am saying. I know how to generate plant topology I don;t know how to generate the trunk and branch geometry. I.e. get  a 2 manifold mesh.
Makogan
CC BY-SA 4.0
2023-02-10T12:01:17.047Z
Well that's the allusion here. After an L system has generated the topology which is represented by symbols each symbol in turn has a corresponding mesh. Replace the symbols with the mesh make sure everything is connected, tesselate, weather, texture, animate.
pmw1234
CC BY-SA 4.0
2023-02-10T13:04:39.083Z
Just to be clear, it is not a 1 to 1 replacement (look up turtle system's) when generating the final mesh.
pmw1234
CC BY-SA 4.0
2023-02-13T13:45:03.017Z
Based on your feedback I decided to write an answer.
pmw1234
<computational-geometry><geometry><parametrization>
How do algorithmic botany algorithms generate their plant geometry from a skeleton?
Makogan
# How do algorithmic botany algorithms generate their plant geometry from a skeleton?

(Asked by: username_0 on 2023-02-09)

I read the Algorithmic Beauty of plants.The resource goes in depth as to how to generate plant topology, but it does not talk about how to make the geometry except for the leaves.

I tried looking into packages such as [plantgl](https://github.com/openalea/plantgl) bbut I am still not entirely sure how they are making it.

I understand they use sweep surfaces, but are they putting any effort into ensuring their models are manifold? Or are they just piece wise parametrizing each 1D section and not bothering to guarantee watertighntnes?

Is there a way to grab a plant topology and parametrize it into a watertight mesh?

**Tags:** computational-geometry, geometry, parametrization

> **Comments:**
> **username_1**: look up L systems for generating plants, the book mentioned in the answer also goes into it nicely.  
> **username_0**: That generates plant topology, not geometry. Which is exactly what i am saying. I know how to generate plant topology I don;t know how to generate the trunk and branch geometry. I.e. get  a 2 manifold mesh.  
> **username_1**: Well that's the allusion here. After an L system has generated the topology which is represented by symbols each symbol in turn has a corresponding mesh. Replace the symbols with the mesh make sure everything is connected, tesselate, weather, texture, animate.  
> **username_1**: Just to be clear, it is not a 1 to 1 replacement (look up turtle system's) when generating the final mesh.  
> **username_1**: Based on your feedback I decided to write an answer.  

---

## 2 answers

### Answer by username_2 on 2023-02-09. Score: 3 | Accepted answer

First, I'll note that `cpfg`, the plant-modeling software used in the creation of "The Algorithmic Beauty of Plants", has recently been open-sourced at <https://github.com/AlgorithmicBotany/vlab> so you can look it up yourself!

Briefly, though, you're right that plant axes are just cylinders swept along a polyline. There was no effort made into making these models watertight; the cylinder swept by lateral branches intersect the main branch geometry. In general, it's a hard problem to nicely skin branch intersections. There was some published work on it at that lab, [The Use of Subdivision Surfaces in the Modeling of Plants](http://algorithmicbotany.org/papers/macmurchy.th2004.html), which tried to solve the problem by using low-poly branch templates; they still had difficulties for axes with many close branch points, if I recall.


---

### Answer by username_1 on 2023-02-13. Score: 1

A popular method of generating the mesh from an L system is called a "Turtle Graphics" system.

In a turtle graphics system we imagine a turtle which starts at the root of the system reads a symbol from the L system and walks in a specific direction based on the symbol. The symbol itself is associated with a polygon and the entire system is seeded with a polygon from the root symbol.

The polygons themselves can be generated algorithmically by the system and then modified for each generation of the plant or predefined such as a simple N sided circle.

As the turtle marches through the L system each symbol gives it instructions on direction and how many steps to take. For example, a turtle may be instructed to move 3 steps in the up direction.

The turtle starts at the seeded polygon, reads the symbol, takes a step and places the polygon for that symbol. Taking a step usually includes a "turn" this translates into a rotation matrix for the polygon being placed where the turtle represents the origin for the coordinate frame used to do the rotation and the turtles position becomes the translation. Then the two polygon's are connected. A simple and effective way to connect two polygons is: find the two nearest vertices, n and m, the generate vertex attributes in the order n,m,n+1 mod t,m+1 mod t...n+t mod t,m+t mod t where t is the total number of vertices. When t is not equal in the two polygons a combination of splitting the longest edge, and connecting multiple vertices in n to a single vertex in m (or vica versa depending on the vertex count) can be used.

Some simple checks should be run for each pair of polygons. 1) Make sure the polygons are planer. 2) Make sure the polygons are wound consistently 3) At connection time make sure all vertices in the
polygon being placed are on the same side of the connecting polygon's plane. Vertices that pass through the plane will need to be adjusted so they are slightly above the plane of the other polygon.

Normally there is one main "trunk" for the turtle to follow, each branch is reinterpreted as a new turtle with a new seed polygon. Branch's can be integrated into the main structure by clipping each branch against the triangles of the main trunk. Some systems will allow branch's to intersect, others will do collision checking. Here again the can be special symbols that define the transition between the main structure and a branch, this allows for smooth transitions of UV coordinates.

Leaves can be single symbols represented as a single polygon, or an entire L system with its own turtles which is slow to generate but the results are stunning. Yet another approach is to generate a handful of leaves and the L system associates a symbol with each leaf.

Done correctly this results in a well defined structure. The root node can be closed off to make the polyhedron water tight.


---

