Skip to content

Commit e76ec0e

Browse files
authored
Updating README
Still need to add some explanations in the Tutorials section
1 parent c2dd976 commit e76ec0e

File tree

1 file changed

+110
-16
lines changed

1 file changed

+110
-16
lines changed

README.rst

Lines changed: 110 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ Table of Contents
1414
-----------------
1515

1616
- `Installation <#installation>`__
17+
- `Tutorials <#tutorials>`__
1718
- `Usage <#usage>`__
1819
- `Features <#features>`__
19-
- `Gallery <#gallery>`__
20+
- `Contributing <#contributing>`__
21+
- `License <#license>`__
2022
- `Contact <#contact>`__
21-
- `Support <#support>`__
22-
- `Citations <#citations>`__
23+
- `Acknowledgments <#acknowledgments>`__
2324

2425
Documentation
2526
-------------
@@ -66,27 +67,120 @@ To install TreeSim_Lpy, follow these steps (adapted from the `L-Py documentation
6667
6768
lpy
6869
69-
6. **Install TreeSim_Lpy**:
7070
71-
With the conda environment for L-Py set, next we need to clone the TreeSim_Lpy repository. To do that run
71+
Tutorials
72+
---------
7273

73-
.. code-block:: sh
74+
There are many things you may want to modify as you grow your own trees. Here are some tutorials for some of the more common changes:
75+
76+
1. **Changing Apple Geometry:**
77+
78+
The call production of the apples happens in the ``grow_object(o)`` section:
79+
80+
.. code-block:: python
81+
82+
elif 'Apple' in o.name:
83+
produce [S(.1/2, .09/15)f(.1)&(180)A(.1, .09)]
84+
85+
86+
87+
The apple's base is generated with the ``A(bh, r)`` production rule seen below.
88+
89+
.. code-block:: python
90+
91+
A(bh, r):
92+
curves = make_apple_curve()
93+
base_curve = curves[0]
94+
top_curve = curves[1]
95+
nproduce SetColor(230,0,0) SectionResolution(60)
96+
produce nF(bh, .01, r, base_curve) ^(180) nF(bh/5, .1, r, top_curve)^(180)#S(bh/2,r/15)
97+
98+
The parameters represent the base height of the apple and the radius of the apple. If you wanted to create a completely new apple geometry, just replace the code in this A section. However, if you simply want to edit the existing shape of the apple, that can be done in the ``make_apple_curve()`` section.
99+
100+
The apple is made with two curves: a curve that marks the base of the apple, and a curve that marks the indentation on top of the apple. These curves are generated as different Curve2D objects, then turned into QuantisedFunction objects. This is necessary because of the way the apple is produced ``nF``. ``nF`` has an optional parameter ``radiusvariation`` which must be a quantized function. ``nF`` produces a cylinder in n steps, and these curves work by specifying how large the radius for the cylinder should be at each step.
101+
102+
Currently, the stem is produced separately from the apple base. The stem is created in a slightly different way than the apple. A NurbsCurve2D object is returned from the ``make_stem_curve()`` function. This curve is used in ``SetGuide`` to mark how the stem will be generated. ``nF`` is used to follow the guide while generating a cylinder, and there is no ``radiusvariation`` this time.
103+
104+
.. code-block:: python
105+
106+
S(sh,r):
107+
stem_curve = make_stem_curve()
108+
nproduce SetColor(100,65,23)
109+
produce SetGuide(stem_curve, sh) _(r)nF(sh, .1, r)
110+
111+
112+
2. **Changing Leaf Geometry:**
113+
114+
.. code-block:: python
115+
116+
L(l):
117+
nproduce SetColor(0,225,0)
118+
119+
curves = make_leaf_guide()
120+
curve1 = curves[0]
121+
curve2 = curves[1]
122+
123+
produce _(.0025) F(l/10){[SetGuide(curve1, l) _(.001).nF(l, .01)][SetGuide(curve2, l)_(.001).nF(l, .01)]}
74124
75-
git clone https://github.com/OSUrobotics/treesim_lpy.git
76125
77-
Usage
78-
-----
126+
3. **Changing Bud Geometry:**
127+
128+
.. code-block:: python
79129
80-
Here is a basic usage example to get you started:
130+
spiked_bud(r):
131+
base_height = r * 2
132+
top_height = r * 2
133+
num_sect = 20
134+
produce @g(Cylinder(r,base_height,1,num_sect))f(base_height)@g(Cone(r,top_height,0,num_sect))
81135
82-
- **Loading a Tree Model:**
136+
4. **Changing Branch Profile Curve:**
83137

84138
.. code-block:: python
85139
86-
Do some lpy things
87-
More lpy code
88-
produce something?
140+
# From grow_object(o)
141+
if 'Trunk' in o.name or 'Branch' in o.name:
142+
nproduce SetContour(o.contour)
143+
else:
144+
# set the contour back to a usual circle
145+
reset_contour()
146+
147+
5. **Changing Tertiary Branch Curves:**
148+
149+
.. code-block:: python
89150
151+
# From bud(t)
152+
if 'NonTrunk' in new_object.name:
153+
import time
154+
curve = create_bezier_curve(seed_val=time.time())
155+
nproduce [SetGuide(curve, new_object.max_length)
156+
157+
6. **Changing color ID system:**
158+
159+
.. code-block:: python
160+
161+
# From grow_object(o)
162+
r, g, b = o.color
163+
nproduce SetColor(r, g, b)
164+
165+
smallest_color = [r, g, b].index(min([r, g, b]))
166+
o.color[smallest_color] += 1
167+
168+
7. **Changing Apple and Leaf ratio:**
169+
170+
.. code-block:: python
171+
172+
# From Spur class
173+
def create_branch(self):
174+
if self.num_leaves < self.max_leaves:
175+
self.num_leaves += 1
176+
if rd.random()<0.9:
177+
new_ob = Leaf(copy_from = self.prototype_dict['leaf'])
178+
else:
179+
new_ob = Apple(copy_from = self.prototype_dict['apple'])
180+
else:
181+
new_ob = None
182+
183+
return new_ob
90184
91185
92186
Features
@@ -101,7 +195,7 @@ Gallery
101195
========
102196
.. figure:: media/envy_model.png
103197
:width: 500
104-
:height: 300
198+
:height: 500
105199
106200
Example of a labelled, pruned and tied envy tree system using TreeSim_Lpy
107201
@@ -120,7 +214,7 @@ Contact
120214
For any questions or issues, please contact us through **GitHub Issues**.
121215
122216
123-
Support
217+
Help and Support
124218
----------------
125219
126220
Please open an **Issue** if you need support or you run into any error (Installation, Runtime, etc.).

0 commit comments

Comments
 (0)