Hi, im trying to simulate a 2D fluid particle system width ellipses representing particles, but im having trouble when 2 of the particles collide and one of them is colliding a wall, they kind of go crazy.
I don't know if is the order of checking collitions (first wall-particle, or particle-particle), here is my code...
p.colision(); p.pared(); p.mover(); p.pintar();
class particula { PVector pos,vel,fuerza; float masa; int id,vecinas[],cont; color col,cal,cel; particula[] otros; int[] vecinos; particula(int id_) { pos = new PVector(random(width/3,2*width/3),height/2); vel = new PVector(0,0); fuerza = new PVector(0,G); masa=1; col=0; id=id_; otros=p; cont=0; } void pintar() { fill(100,10,180,30); noStroke(); ellipse(pos.x,pos.y,r,r); stroke(int(map(vecinos.length,0,6,0,255)),cal,0); strokeWeight(r/3); point(pos.x,pos.y); } void mover() { fuerza.mult(masa); vel=new PVector(fuerza.x,fuerza.y); pos.add(vel); fuerza = new PVector(0,G); }