sghr / iGeo

iGeo: Computational Design and 3D Modeling Library for Processing
http://igeo.jp
GNU Lesser General Public License v3.0
146 stars 34 forks source link

Questions regarding code in the tutorials (IG.duration and for loop) #20

Open Higemoto opened 5 years ago

Higemoto commented 5 years ago

Hi, I'm currently training on IGeo and reached the last tutorial of this page http://igeo.jp/tutorial/36.html (updating Agents using vectors).

I was wondering why do we need a for loop in the following : import processing.opengl.; import igeo.; void setup(){ size(480, 360, IG.GL); IG.duration(250); int num = 40; float inc = 2PI/num; for(int i=0; i < num; i++){ new MyAgent(IG.v(40cos(iinc), 40sin(iinc), 0), IG.v(5cos((i+6)inc), sin((i+6)inc), 0)); } }

the IG.duration is setting up how many times the action is done, what is the role of that For Loop and the variable "int num = 40" ?

Does it mean there will be 40 initial instances starting at 40 different positions as the i is implemented in the vectors ?

Thanks in advance, Gari,