Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variation of NOC_02forces_many_mutual_boundaries #59

Open
bustavo opened this issue Sep 7, 2015 · 1 comment
Open

Variation of NOC_02forces_many_mutual_boundaries #59

bustavo opened this issue Sep 7, 2015 · 1 comment

Comments

@bustavo
Copy link

bustavo commented Sep 7, 2015

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);

  }
}
@shiffman
Copy link
Member

shiffman commented Sep 7, 2015

This is a great suggestion, thank you! If you would like to add the solution as a pull request, please feel free!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants