Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- TwoBodySimG.java MrG 2012.0621 (work in progress)
- purpose: simulate a binary star system, nbody simulation, n=2, with G!
- required files: TwoBodySimG.java main class
- TwoBodyG.java derived class
- BodyG.java nbody class, n=1
- Vector.java adt class
- StdDraw.java graphics class
- translator: javac TwoBodySim.java
- interpreter: java TwoBodySim
- */
- public class TwoBodySimG
- {
- public static void main(String[] args)
- {
- double size= 5.0e10;
- double rx1 = 0.0e00; //meters
- double ry1 = 4.5e10;
- double vx1 = 1.0e04; //meters/sec
- double vy1 = 0.0e00;
- double m1 = 1.5e30; //kilograms
- Vector r1 = new Vector(rx1,ry1);
- Vector v1 = new Vector(vx1,vy1);
- BodyG star1 = new BodyG(r1,v1,m1);
- double rx2 = 0.0e00;
- double ry2 = -4.5e10;
- double vx2 = -1.0e04;
- double vy2 = 0.0e00;
- double m2 = 1.5e30;
- Vector r2 = new Vector(rx2,ry2);
- Vector v2 = new Vector(vx2,vy2);
- BodyG star2 = new BodyG(r2,v2,m2);
- StdDraw.setPenRadius(.03);
- TwoBodyG binary = new TwoBodyG(size, star1, star2);
- while(true)
- {
- StdDraw.clear();
- binary.move(25000);
- binary.draw();
- StdDraw.show(50);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement