Skip to content

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

Open
@Higemoto

Description

@Higemoto

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(40
cos(iinc), 40sin(iinc), 0),
IG.v(5
cos((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,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions