I have a code, that has a class "behavior" and a class "obstacle"
I need that my "behavior" reacts according to my "obstacles"( LIne2D), but the code is pretty complex for me, and i really can not figure out a strategy to make it.
Would somebody please give me some ideas on how to make it or post some examples where this happens??
i am starting with geomerative library, so i still have troubles with the basic. hope somebody could give me a suggestion.
I have a shape and an array of points.
I need to check if the points are inside the shape with the boolean contains, and storage the ones that returns true into an array. The problem is that i can not simply add them into an array list, because for my project i need always the same amount of elements in my storage.
Probably i will have to use somehow the getPoints() command but i simply can not figure it out.....
i am starting with geomerative library, so i still have troubles with the basic. hope somebody could give me a suggestion.
I have a shape and an array of points.
I need to check if the points are inside the shape with the boolean contains, and storage the ones that returns true into an array. The problem is that i can not simply add them into an array list, because for my project i need always the same amount of elements in my storage.
Probably i will have to use somehow the getPoints() command but i simply can not figure it out.....
guys, i have this sketch as a simpler test to my work in progress, this is what i need:
-agents that move in a certain direction from the center
- vectors between the final positions of each agent, drawing the polygon that they form (i can not simply make lines, because later i will have to work with the vectors)
just for testing my vectors i did lines using the coordinates of them and they are completely crazy, instead of really drawing the shape of the polygon in red...
can somebody please,please help me??
int number = int(random(4, 10));
Agent [] agenten = new Agent[number];
void setup() {
size(500, 500);
smooth();
noFill();
float ang = TWO_PI / number;
//CREATES AGENTS
for (int i=0; i<agenten.length; i++) {
float dx = random(cos(ang*i), cos(ang*i+1));
float dy = random(sin (ang*i), sin (ang*i+1));
agenten[i] = new Agent(width/2, height/2, dx, dy);
}
}
void draw() {
background(255);
stroke(0);
noFill();
int time= millis();
int timelimit= 600;
PVector [] vec = new PVector [number] ;
for (int i=0; i<agenten.length; i++) {
agenten[i].render();
if (time < timelimit) {
agenten[i].move();
}
}
//CREATES VECTORS
for (int i=0; i < vec.length-1; i++) {
vec [i] = new PVector (agenten[i+1].position.x-agenten[i].position.x, agenten[i+1].position.y-agenten[i].position.y);
}
vec[vec.length-1] = new PVector (agenten[vec.length-1].position.x - agenten[0].position.x, agenten[vec.length-1].position.y - agenten[0].position.y);