Advertisement
calcpage

LACS09_TwoBodySim.java

Jun 21st, 2012
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.98 KB | None | 0 0
  1. /**
  2. TwoBodySim.java MrG 2012.0621
  3. purpose:    simulate a binary star system, nbody simulation, n=2, no G
  4. required files: TwoBodySim.java         main class
  5.         TwoBody.java            derived class
  6.         Body.java           nbody class, n=1
  7.         Vector.java         adt class
  8.         StdDraw.java            graphics class
  9. translator: javac TwoBodySim.java
  10. interpreter:    java TwoBodySim
  11. */
  12. public class TwoBodySim
  13. {
  14.     public static void main(String[] args)
  15.     {
  16.         double size= 5.0e10;
  17.  
  18.         double rx1 = 0.0e00;
  19.         double ry1 = 4.5e10;
  20.         double vx1 = 1.0e04;
  21.         double vy1 = 0.0e00;
  22.         Vector r1 = new Vector(rx1,ry1);
  23.         Vector v1 = new Vector(vx1,vy1);
  24.         Body star1 = new Body(r1,v1);
  25.  
  26.         double rx2 = 0.0e00;
  27.         double ry2 = -4.5e10;
  28.         double vx2 = -1.0e04;
  29.         double vy2 = 0.0e00;
  30.         Vector r2 = new Vector(rx2,ry2);
  31.         Vector v2 = new Vector(vx2,vy2);
  32.         Body star2 = new Body(r2,v2);
  33.  
  34.         TwoBody binary = new TwoBody(size, star1, star2);
  35.         while(true)
  36.         {
  37.             binary.move(25000);
  38.             binary.draw();
  39.             StdDraw.show(50);
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement