Teaching Aid

 
Spruce model

Spruce model

 

 
Copy/Paste the following code to your GroIMP project:
//**********************************************************
/* Spruce Modell
Written by: Kurth W. 11.6.2009
*/

module T;
module M1;
module S1;
module M2;
module S2;
module M3;
module S3;
module GU(float incd, int age) extends F0;
module BA(int age, super.angle) extends RL(angle);
module GA(int age, super.angle) extends RL(angle);
module HA(int age, super.angle) extends RL(angle);

const int ang = 45;
const int x3 = 50;
const int[] a = { 0, 15, 25, 32, 37, 40 };
const int[] gg = { 0, 0, 4 };
const int[] hh = { 0, 0, 2, 4, 8 };
int n, k;
const float[] prob_n = {0.1, 0.4, 0.3, 0.2};
const int[] n_subap = {5, 6, 7, 8};

protected void init()
[
Axiom ==> P(2) D(1) L(100) T;
]

public void grow()
[
x:T ==> Nl(80*TurtleState.length(x)) GU(2.2, 0)
RH(random(0, 360)) { k = 0; }
for ((1:3))
( [ MRel(random(0.2, 0.85)) RH(k*120+normal(0, 5.5))
{ k++; } RL(x3+normal(0, 2.2)) BA(0, 0) LMul(0.4) M1 ] )
RH(random(0, 360)) { n = n_subap[distribution(prob_n)]; k = 0; }
for ((1:n))
( [ MRel(random(0.85, 1)) RH(k*360/n+normal(0, 3.1))
{ k++; } RL(x3+normal(0, 2.2)) BA(0, 0) LMul(0.65) S1 ] )
T;
x:S1 ==> Nl(80*TurtleState.length(x)) GU(1.3, 0)
[ MRel(random(0.85, 1)) RH(15)
RU(ang+normal(0, 2.2)) AdjustLU LMul(0.7) S2 ]
[ MRel(random(0.85, 1)) RH(-15)
RU(-ang+normal(0, 2.2)) AdjustLU LMul(0.7) S2 ] GA(0, 0) S1;
x:M1 ==> Nl(80*TurtleState.length(x)) GU(0.8, 0)
[ MRel(random(0.85, 1)) RH(15)
RU(ang+normal(0, 2.2)) AdjustLU LMul(0.7) M2 ]
[ MRel(random(0.85, 1)) RH(-15)
RU(-ang+normal(0, 2.2)) AdjustLU LMul(0.7) M2 ] HA(0, 0) M1;
x:S2 ==> Nl(80*TurtleState.length(x)) GU(1.3, 0)
[ MRel(random(0.85, 1)) RH(10)
RU(ang) AdjustLU LMul(0.7) S3 ]
[ MRel(random(0.85, 1)) RH(-10)
RU(-ang) AdjustLU LMul(0.7) S3 ] S2;
x:M2 ==> Nl(80*TurtleState.length(x)) GU(0.8, 0)
[ MRel(random(0.85, 1)) RH(10)
RU(ang) AdjustLU LMul(0.7) M3 ]
[ MRel(random(0.85, 1)) RH(-10)
RU(-ang) AdjustLU LMul(0.7) M3 ] M2;
x:S3 ==> Nl(80*TurtleState.length(x)) GU(1.3, 0);
x:M3 ==> Nl(80*TurtleState.length(x)) GU(0.8, 0);
GU(incd, t) ==> DlAdd(incd*(t+1)) GU(incd, t+1);
DlAdd(arg) ==> ;
BA(age, angle) ==> BA(age+1, a[age<5 ? age+1 : 5]);
GA(age, angle) ==> GA(age+1, gg[age<2 ? age+1 : 2]);
HA(age, angle) ==> HA(age+1, hh[age<4 ? age+1 : 4]);
]

//**********************************************************
 

DATE: 2009

 

AUTHOR: W. Kurth

 

DESCRIPTION:  see model

 

Welcome to the website grogra.de. This site is the web centre of growth grammars of the Department Ecoinformatics, Biometrics and Forest Growth at the Georg-August University of Göttingen and its cooperation partners.

--- not found