User Tools

Site Tools


workshops:sdau_course

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
workshops:sdau_course [2025/11/12 12:18] ksmolenworkshops:sdau_course [2025/11/14 11:42] (current) ksmolen
Line 1: Line 1:
 +**Improving leaf shape in the simple tomato model**
 +
 +For improved leaf shape, we can define the leaf contour using a mathematical model.
 +Below is the implementation of a simplified version; for the full equation, see [[https://doi.org/10.14214/sf.7740|Coussement et al. (2018)]].
 +
 +To add the leaf shape function into the model, open the ''simple_tomato_growth_sdau.gsz'' example and copy the code below inside the ''modules_organs.rgg'' file.
 +
 +<code java>
 +module Leaflet(float length, double width)
 +{
 +} ==> 
 +[
 +    { 
 +        int segments = 100; 
 +    } 
 +
 +    for (double i=1; i < segments; i++)
 +    (
 +        {
 +            double segmentLength;
 +            segmentLength = length/segments;
 +            // getNormalizedLeafWidth specifies the half of the shape
 +            double segmentWidth = 0.5*width * getNormalizedLeafWidth(1 - i/segments);
 +        }
 +
 +        Parallelogram(segmentLength, 2*segmentWidth).(setShader(GREEN))
 +         
 +        RL(60.0/segments)
 +    )
 +];
 +
 +// calculate leaf shape as the normalized width along the midrib, 
 +// full model: Coussement et al. 2018
 +// https://doi.org/10.14214/sf.7740
 +static double getNormalizedLeafWidth(float lnorm) {
 +
 +    double k1 = 2;
 +    double k2 = 2.2;
 +
 +    double gL = 0;
 +
 +    double maxWidth = 0.6;
 +
 +    if (lnorm <= maxWidth) {
 +        gL = 1 - Math.pow((maxWidth - lnorm)/maxWidth,k1);
 +        } else {
 +            gL = 1 - Math.pow((lnorm - maxWidth)/(1 - maxWidth),k2);
 +        }
 +
 +        return gL;
 +    }
 +</code>
 +
 +Then, inside the definition of ''module Leaf'', replace every occurrence of ''Parallelogram'' by ''Leaflet''.
 +
 +Updated model:
 +  * {{ :workshops:simple_tomato_growth_niceleaflet_sdau.gsz |}}
 +
 **Modelling with L-systems.** **Modelling with L-systems.**
  
Line 6: Line 64:
 Model example: Model example:
   * {{ :workshops:simple_development_template_sdau.gsz |}}   * {{ :workshops:simple_development_template_sdau.gsz |}}
 +  * {{ :workshops:lsystems.gsz |}}
  
  
Line 18: Line 77:
   * {{ :workshops:simple_development_rggrules_sdau.gsz |}}   * {{ :workshops:simple_development_rggrules_sdau.gsz |}}
  
-Simple tomato crop model.+**Simple tomato crop model.**
  
 Model example: Model example:
workshops/sdau_course.1762946337.txt.gz · Last modified: 2025/11/12 12:18 by ksmolen