-2

I 've been set the following problem and don't have a clue how to start any help would be much appreciated.

In 2-D, read in the initial positions, velocities and masses of two bodies (suns, stars etc) . You will need to define suitable units for these. Then using the gravitational equation, calculate the force on each body from the other, and use Newton’s 3rd law to calculate the acceleration of that body. Generate a file with the positions of both bodies at each timestep for a long time period. Use this file to plot the paths of the two bodies.

Name is Nilay
  • 2,743
  • 4
  • 35
  • 77
Ben Burak
  • 3
  • 1
  • 2
  • 1
    Where are you stuck? Have you got the gravitational pull between two objects that doesn't care about time or motion? Have you added the timesteps? Have you gotten the output? Have you gotten to the plotting? – sarnold Mar 28 '12 at 22:25
  • 1
    This is much too vague for us to help. Try doing the first part of the assignment (read in the file) and then come back if you're having specific problems ("Why does reading my file in this way not work? ${code here}"). – Brendan Long Mar 28 '12 at 22:26
  • I disagree with this not being a question - agreed broad but can be simplified. In short the user needs to apply F = ma = mg and therefore by simply substitution can apply the math to generate the vector geometry – Paul Sullivan Mar 28 '12 at 22:34

1 Answers1

0
  • Store the initial position, velocity and masses.
  • Calculate the magnitude and direction of the gravitational force.
  • Knowing the force, you can calculate the acceleration of each body.
  • Knowing the acceleration you can calculate the new velocity.
  • Knowing the velocity you can calculate the new position.

Using suitably small time steps you can get a reasonably good approximation to continuous motion.

Mark Byers
  • 811,555
  • 193
  • 1,581
  • 1,452