-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGravSim.java
More file actions
38 lines (37 loc) · 1.03 KB
/
GravSim.java
File metadata and controls
38 lines (37 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
* Class for running a gravity simulation. This class uses
* {@link GravUniverseReader} to read in data from a text file and a
* {@link GravEngine} to run the simulation.
*
* @author Sean Stern
* @version 1.0
*/
public class GravSim{
/**
* Runs a gravity simulation
* Required command line argument: fileName
* Optional command line arguments: timeDelta r-value b-value g-value
*/
public static void main(String[] args){
if(args.length == 0){
System.out.println("usage: java GravSim fileName [timeDelta] " +
"[r-value] [b-value] [g-value]");
return;
}
UniverseReader ur = new GravUniverseReader(args[0]);
double timeDelta = 0.001;
if(args.length > 1){
timeDelta = Double.parseDouble(args[1]);
}
int r = 0, b = 0, g = 0;
if(args.length > 4){
r = Integer.parseInt(args[2]);
b = Integer.parseInt(args[3]);
g = Integer.parseInt(args[4]);
}
PhysicsEngine pe = new GravEngine(ur.getBodies(), timeDelta,
ur.getUniverseRadius(),
r, b, g);
pe.run();
}
}