Skip to content

Instantly share code, notes, and snippets.

@Introscopia
Created April 28, 2017 22:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Introscopia/093aa7ee076ccb99bf72fa60293b9c51 to your computer and use it in GitHub Desktop.
Save Introscopia/093aa7ee076ccb99bf72fa60293b9c51 to your computer and use it in GitHub Desktop.
void gravitate( Particle p ){
PVector grav = new PVector(1,0);
grav.setMag( G*(p.area()) / sq( constrain(dist(pos.x, pos.y, p.pos.x, p.pos.y), 1, 100000) ) );
grav.rotate(atan2(p.pos.y - pos.y, p.pos.x - pos.x ));
acc.add(grav);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment