Goals |
Part 0: preparation |
Part 1: class Body members |
Part 2: move and show |
To get started, ignore gravity, and simply make the planets move in a straight line, as in the warmup.
that keeps track of the maximum coordinate. You can update this quantity after each new Body is instantiated by adding a few lines of code to the Body constructor. You can use the method Math.abs() to take absolute values.private static double maxXY = 0.0;
Part 3: resetForce and computeForce |
Part 4: move |
Explanation: the original formula assumes the acceleration is constant over an interval from time t to t + dt, whereas the modified formula assumes it is constant from time t - dt/2 to t + dt/2.p[ ] = p[ ] + v[ ] dt + a[ ]*dt*dt
General debugging hints |
Compiling and executing |
or compile a deluxe version with extra bells and whistles using:javac Body.java Nbody.java
javac Body.java NbodyDeluxe.java
appletviewer Nbody.html appletviewer NbodyDeluxe.html
chmod 644 *.html *.class *.gif *.au *.jpg chmod 600 *.java
Submission and readme (1 point) |
submit126 9 Body.java readme
Extra credit |
Enrichment Links |