You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Pflanze2.java 975B

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package garten.model;
  7. /**
  8. *
  9. * @author Jan
  10. */
  11. import lsystem.StochasticGrammar;
  12. class Pflanze2 extends PflanzeImpl
  13. {
  14. Pflanze2(int Xstart, int Ystart, int Generation,int startLength)//startLength 10-20 (Verzweigte Pflanze)3 Generationen
  15. {
  16. super(Xstart,Ystart,Generation,startLength);
  17. DELTA = (float) ((Math.PI)/5);
  18. createLSystem();
  19. translateRules();
  20. }
  21. public void createLSystem()
  22. {
  23. grammar = new StochasticGrammar(axiom);
  24. grammar.addRule('F',"F[+FF][-FF]F[-F][+F]F",(float) 0.1); // add rule, and weight
  25. grammar.addRule('F',"F[+FF][-FF]F[+F][+F]F",(float) 0.3);
  26. grammar.addRule('F',"F[+F][+FF]F[+F][-F]F",(float) 0.2);
  27. grammar.generateGrammar(generations);
  28. drawLength = (float) (startLength * Math.pow(0.6, (double) generations));
  29. }
  30. }