Guest User

Untitled

a guest
Dec 14th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. PVector [] asts = new PVector [astN];
  2. for (int i = 1; i < astN; i++) {
  3. asts[i] = new PVector(random(0, width), random(0, height));
  4. }
  5. pushMatrix();
  6. scale(astSiz);
  7. translate(asts[i].x, asts[i].y);
  8. shape(model);
  9. popMatrix();
  10.  
  11. //PVector [] accs = new PVector [astN];
  12. //PVector [] vels = new PVector [astN];
  13. for (int i = 1; i < astN; i++) {
  14.  
  15. PVector [] tempAccs = new PVector [astN];
  16. float [] tempforces = new float [astN];
  17.  
  18. tempAccs[i] = PVector.sub(pos2, asts.get(i));
  19. tempAccs[i].normalize();
  20. tempforces[i] = grav*mass/pow(PVector.dist(asts.get(i), pos2), 2);
  21. tempAccs[i].mult(tempforces[i]);
  22. accs[i].add(tempAccs[i]);
  23.  
  24. }
  25. for (int i = 1; i < astN; i++) {
  26. vels[i].add(accs[i]);
  27. vels[i].mult(0.5);
  28. asts.get(i).add(vels[i]);
  29. accs[i] = new PVector();
  30. accs[i].set(0,0);
  31.  
  32. }
Add Comment
Please, Sign In to add comment