User Tools

Site Tools


tutorials:radiation-model-in-crop_model4

Differences

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

Link to this comparison view

Next revision
Previous revision
tutorials:radiation-model-in-crop_model4 [2025/05/27 16:51] – created barley1965tutorials:radiation-model-in-crop_model4 [2025/05/27 17:58] (current) barley1965
Line 1: Line 1:
 ====== Introducing absorbing tiles ====== ====== Introducing absorbing tiles ======
  
-//Open Tiles.gsz.// +//Open the file {{ :tutorials:tiles.gsz |Tiles.gsz}}.// 
  
 We also want to visualize how much light is reaching the ground. To do that, we cover the soil surface around the plant with light-absorbing tiles. First of all, you need to declare a new module: We also want to visualize how much light is reaching the ground. To do that, we cover the soil surface around the plant with light-absorbing tiles. First of all, you need to declare a new module:
Line 13: Line 13:
 </code> </code>
    
-Note that we declare the variable al, which will be used to store the light absorbed by a tile, in a different way, namely not between parentheses but between curly braces and on a new line. We could have declared module Tile(float len, float wid, float al) …, and this would not have made a big difference. However, the method to declare variables in parentheses behind the name becomes increasingly cumbersome when we are dealing with many variables. Also, when we declare the variables in this new way, we can refer to them in a more straightforward way, for instance t:Tile ::> t[al]… and don’t need to worry about the position of the variable in the module declaration (as was the case in parametric L-systems). +Note that we declare the variable ''al'', which will be used to store the light absorbed by a tile, in a different way, namely not between parentheses but between curly braces and on a new line. We could have declared module ''Tile(float len, float wid, float al)'' …, and this would not have made a big difference. However, the method to declare variables in parentheses behind the name becomes increasingly cumbersome when we are dealing with many variables. Also, when we declare the variables in this new way, we can refer to them in a more straightforward way, for instance  
 +<code java> 
 +t:Tile ::> t[al]…  
 +</code> 
 +and don’t need to worry about the position of the variable in the module declaration (as was the case in parametric L-systems).  
 In the Axiom rule, preceding the Bud, we place 1600 (40 x 40) tiles (L. 84ff): In the Axiom rule, preceding the Bud, we place 1600 (40 x 40) tiles (L. 84ff):
-  +<code java> 
-Like the leaves, the tiles will become brighter when they absorb light. Update is done in the absorbAndGrow() method:  +Axiom ==> //insert light absorbing tiles here:  
-  +
-Task: Obtain the sum of light that is absorbed by the tiles and plot it! (Hint: you can simply add a column “1” to the existing data table and then extend the method updateChart() with the sum function). + RL(90) M(4) RU(90) M(-4) 
 + for((1:40)) ( 
 + for((1:40)) ( 
 + Tile(0.25,0.25).(setShader(new RGBAShader(0.6, 0.3, 0.1))) 
 +
 + M(-10) RU(90) M(0.25) RU(-90) 
 +
 +
 +  
 + Bud(1, PHYLLOCHRON, 1); 
 +</code> 
 + 
 +Like the [[tutorials:radiation-model-in-crop_model|leaves]], the tiles will become brighter when they absorb light. Update is done within the ''absorbAndGrow()'' method:  
 + 
 +<code java> 
 +        //repainting the tiles: 
 + t:Tile ::> { 
 + t[al] = lm.getAbsorbedPower3d(t).integrate(); 
 + //println(lf[al]); 
 + t.(setShader(new AlgorithmSwitchShader( 
 + new RGBAShader(t[al]*300, t[al]*200, t[al]), 
 + new RGBAShader(0.6, 0.3, 0.1)))); 
 +
 +</code> 
 + 
 +{{tutorials:tiles.png}} 
 + 
 +//Task: Obtain the sum of light that is absorbed by the tiles and plot it! (Hint: you can simply add a column “1” to the existing data table and then extend the method ''updateChart()'' with the ''sum'' function).// 
  
tutorials/radiation-model-in-crop_model4.1748357510.txt.gz · Last modified: 2025/05/27 16:51 by barley1965