User Tools

Site Tools


tutorials:a-beginners-tutorial

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
tutorials:a-beginners-tutorial [2024/12/19 11:56] – [Simple plant, consisting of an internode and an apical meristem] Timtutorials:a-beginners-tutorial [2024/12/19 13:34] (current) barley1965
Line 28: Line 28:
 After this you click on ‘Install’ and wait for the installation to finish (this can take more than ten minutes). After this you click on ‘Install’ and wait for the installation to finish (this can take more than ten minutes).
  
-After the installation, a folder “GroIMP-2.1.3” should be available under something like this address: “C:\Program Files\”.+After the installation, a folder “GroIMP-2.1.5” should be available under something like this address: “C:\Program Files\”.
  
 GroIMP will now be available either on your desktop or in the list of programmes: GroIMP will now be available either on your desktop or in the list of programmes:
Line 47: Line 47:
 {{:tutorials:beginnerstut_image15.png?536x291}} {{:tutorials:beginnerstut_image15.png?536x291}}
  
-Note that on your machine, the naming of the menu items might vary, due to the language settings of your Java version (I have a French Java installationso some of the menu items will appear in French, others in English).\\+Note that on your machine, the naming of the menu items might vary, due to the language settings of your Java version (in this tutorial, the menu items will appear in English).\\
 GroIMP is a multi-windows platform, i.e. it consists in fact of a (large) number of windows, which can be piled upon each other (like the sheets in an Excel file), “glued” side by side, or be viewed separately (this is handy if your computer is connected to more than one computer screen). To change the size of an integrated window you can simply click and drag on one of the grey hatched lines separating two windows. To change the position of a window you can click on the tab, hold and drag the whole window to its new position. You will see on your left a window called “View”, which contains the visual output of a model (currently a blue cylinder on its side, with a label “A” below it) and on your right a window called “jEdit – Alga.rgg”, in which you see the code of the model (you can scroll down the code using the slider on the right of the window). Another important window is located on the top left of your screen: on it you will find four buttons: GroIMP is a multi-windows platform, i.e. it consists in fact of a (large) number of windows, which can be piled upon each other (like the sheets in an Excel file), “glued” side by side, or be viewed separately (this is handy if your computer is connected to more than one computer screen). To change the size of an integrated window you can simply click and drag on one of the grey hatched lines separating two windows. To change the position of a window you can click on the tab, hold and drag the whole window to its new position. You will see on your left a window called “View”, which contains the visual output of a model (currently a blue cylinder on its side, with a label “A” below it) and on your right a window called “jEdit – Alga.rgg”, in which you see the code of the model (you can scroll down the code using the slider on the right of the window). Another important window is located on the top left of your screen: on it you will find four buttons:
  
Line 61: Line 61:
 {{:tutorials:beginnerstut_image20.png?375x139}} {{:tutorials:beginnerstut_image20.png?375x139}}
  
-From the lecture, you will already know that the text in line 24 is a rule, with a left-hand-side and a right-hand-side. The keyword ‘Axiom’ refers to the start word of the L-system, and ‘==>’ is an operator that essentially means “//replace the left-hand side with the right-hand side//”. Delete the semicolon and save the code. What happens is that the code will not be compiled. Instead, you will find in the Message window on the bottom of the jEdit window the following error message:+The text in line 24 is a rule, with a left-hand-side and a right-hand-side. The keyword ‘Axiom’ refers to the start word of the L-system, and ‘%%==>%%’ is an operator that essentially means “//replace the left-hand side with the right-hand side//”. Delete the semicolon and save the code. What happens is that the code will not be compiled. Instead, you will find in the Message window on the bottom of the jEdit window the following error message:
  
 {{:tutorials:beginnerstut_image21.png?357x247}} {{:tutorials:beginnerstut_image21.png?357x247}}
Line 72: Line 72:
 Let’s have a closer look at the code surrounding the Axiom rule: Let’s have a closer look at the code surrounding the Axiom rule:
  
-protected void init ()+''protected void init ()''
  
 init () is what is called a method in the Java language. Whenever you see a name followed by a pair of simple brackets, (), you can be almost certain that you are dealing with a method. A method is a little //programme within the programme//, a procedure that //does stuff//. The method init() carries out the Axiom rule. It is preceded by two key words, protected and void. protected refers to the type or visibility of the method. Here it means that the method is not visible to, or directly invokable by, the user. void refers to the type of output of the method. Java methods can be written such that they output a result of a certain type as we will see later. Our init() method just carries out a rule, but returns nothing otherwise, therefore its type is void, which means something like “empty”. Note that we also have a pair of square brackets surrounding the Axiom rule, [ and ] in lines 23 and 25, these are necessary to mark the beginning and end of the method code.\\ init () is what is called a method in the Java language. Whenever you see a name followed by a pair of simple brackets, (), you can be almost certain that you are dealing with a method. A method is a little //programme within the programme//, a procedure that //does stuff//. The method init() carries out the Axiom rule. It is preceded by two key words, protected and void. protected refers to the type or visibility of the method. Here it means that the method is not visible to, or directly invokable by, the user. void refers to the type of output of the method. Java methods can be written such that they output a result of a certain type as we will see later. Our init() method just carries out a rule, but returns nothing otherwise, therefore its type is void, which means something like “empty”. Note that we also have a pair of square brackets surrounding the Axiom rule, [ and ] in lines 23 and 25, these are necessary to mark the beginning and end of the method code.\\
Line 168: Line 168:
  
 Open Ex08.gsz ([[#appendix_9ex08rgg|Appendix 9]]). Again, we are working with the Koch snowflake curve. You might have noticed that writing the right-hand-side of the derivation rule is quite tedious and error-prone, especially the rotations and their arguments:\\ Open Ex08.gsz ([[#appendix_9ex08rgg|Appendix 9]]). Again, we are working with the Koch snowflake curve. You might have noticed that writing the right-hand-side of the derivation rule is quite tedious and error-prone, especially the rotations and their arguments:\\
 +<code java>
 F(x/3) RU(-60) F(x/3) RU(120) F(x/3) RU(-60) F(x/3) F(x/3) RU(-60) F(x/3) RU(120) F(x/3) RU(-60) F(x/3)
 +</code>
 Suppose we want to change the angle of the RU rotation, from 60 and -60 to 55 and -55. We could do this manually by changing all the arguments one by one (note that we replaced 120 by 2*55=110):\\ Suppose we want to change the angle of the RU rotation, from 60 and -60 to 55 and -55. We could do this manually by changing all the arguments one by one (note that we replaced 120 by 2*55=110):\\
 F(x/3) RU(-55) F(x/3) RU(110) F(x/3) RU(-55) F(x/3) F(x/3) RU(-55) F(x/3) RU(110) F(x/3) RU(-55) F(x/3)
Line 586: Line 587:
 ] ]
  
-public void executer ()+public void run ()
 [ [
  A ==> A B;  A ==> A B;
tutorials/a-beginners-tutorial.1734605818.txt.gz · Last modified: 2024/12/19 11:56 by Tim