TOP

Gravity Java simulation

Objective
You will write a JAVA program that simulates the motion of N objects affected by gravitational 
forces and animates the results. The techniques are used throughout natural sciences, especially in 
areas of physics like semiconductors and cosmology to analyze complex systems. The same methods 
are also applied into other physical forces which depend on the distance between the objects.
Background
In his Principia, Isaac Newton formulated the principles governing the motion of two objects under 
the gravitational attraction. But he was not able to find a solution to the problem with three particles. 
In general, solutions to complex systems of three or more objects must be approximated via numerical 
simulations.
Requirements
Write a program Gravity.java that has the following specifications:
1. It takes two double command-line arguments - the duration of the simulation (totalT) and the 
simulation time increment (deltaT)
2. It reads in the details of the universe to be simulated from standard input using StdIn, using 
several arrays to store the data
3. It simulates the universe, starting at time t = 0.0, and continuing in deltaT increments as long 
as t < totalT, using the leapfrog scheme (described in the following pages)
4. It animates the results to standard drawing using StdDraw
5. It prints the state of the universe at the end of the simulation (in the same format as the input 
file) to standard output using StdOut
Input
The input is a text file that contains the information for a given universe:
• The first value is an integer n which represents the number of objects
• The second value is a real number radius which represents the radius of the universe; it is 
used to determine the scaling of the drawing window (which displays particles with x- and y-
coordinates between −radius and +radius)
• Next, there are n lines (one for each object), with each line containing 6 values. The first two 
values are the x- and y-coordinates of the initial position; the next pair of values are the x-
and y-components of the initial velocity; the fifth value is the mass; the last value is a String 
that is the name of an image file used to display the particle

Skills Required:

FREELANCER BIDDING (0)
REPUTATION
BID
There are no bid to show.
ABOUT EMPLOYER
  • Address: N/A
  • Total Spent: $0
  • Project Posted: 1
  • Hires: 0