Variation of NOC_02forces_many_mutual_boundaries
bustavo opened this issue · comments
Hi Daniel,
First of all, thanks for the wonderful work on code / videos / and your books.
Just wanted to post an enhancement for a variation for one of the exercises.
I'll call it Big-Bang.
It consists of exactly the same exercise (NOC_02forces_many_mutual_boundaries), but change the start position of all particles to the center of the screen.
Next generate a starting force and on each particle iteration, rotate the force so that each particle starts moving to a different angle simulating an explosion.
void setup() {
size(1500,1000);
for (int i = 0; i < movers.length; i++) {
movers[i] = new Mover(random(1,2),width/2,height/2);
// Determine an angle so that all particles get a force in a unique direction ( 360 / amount of particles )
float angle = 360/movers.length;
// Create a force with a random X
PVector some_force = new PVector(random(0,10),0);
// Rotate the force according to particle i
PVector force = some_force.rotate(radians(angle*(i+1)));
// Apply the force to the particle so that when the program starts, each one is moving in a direction
movers[i].applyForce(force);
}
}
This is a great suggestion, thank you! If you would like to add the solution as a pull request, please feel free!