50 lines
1.9 KiB
Java
50 lines
1.9 KiB
Java
import codedraw.CodeDraw;
|
|
|
|
import java.awt.*;
|
|
|
|
/**
|
|
* Simulates the formation of a massive solar system.
|
|
*/
|
|
public class Simulation4 {
|
|
|
|
public static final double SECTION_SIZE = 10 * Simulation.AU;
|
|
|
|
/**
|
|
* The main simulation method using instances of other classes.
|
|
*/
|
|
public static void main(String[] args) {
|
|
CodeDraw cd = new CodeDraw();
|
|
|
|
NamedBodyForcePair sun = new NamedBodyForcePair(SolSystem4.SUN_NAMED);
|
|
NamedBodyForcePair earth = new NamedBodyForcePair(SolSystem4.EARTH_NAMED);
|
|
NamedBodyForcePair moon = new NamedBodyForcePair(SolSystem4.MOON_NAMED);
|
|
NamedBodyForcePair mars = new NamedBodyForcePair(SolSystem4.MARS_NAMED);
|
|
NamedBodyForcePair deimos = new NamedBodyForcePair(SolSystem4.DEIMOS_NAMED);
|
|
NamedBodyForcePair phobos = new NamedBodyForcePair(SolSystem4.PHOBOS_NAMED);
|
|
NamedBodyForcePair mercury = new NamedBodyForcePair(SolSystem4.MERCURY_NAMED);
|
|
NamedBodyForcePair venus = new NamedBodyForcePair(SolSystem4.VENUS_NAMED);
|
|
NamedBodyForcePair vesta = new NamedBodyForcePair(SolSystem4.VESTA_NAMED);
|
|
NamedBodyForcePair pallas = new NamedBodyForcePair(SolSystem4.PALLAS_NAMED);
|
|
NamedBodyForcePair hygiea = new NamedBodyForcePair(SolSystem4.HYGIEA_NAMED);
|
|
NamedBodyForcePair ceres = new NamedBodyForcePair(SolSystem4.CERES_NAMED);
|
|
|
|
CosmicSystem earthSystem = new HierarchicalSystem(earth, moon);
|
|
CosmicSystem marsSystem = new HierarchicalSystem(mars, deimos, phobos);
|
|
CosmicSystem sol = new HierarchicalSystem(sun, mercury, venus, earthSystem, marsSystem, vesta, pallas, hygiea, ceres);
|
|
|
|
long seconds = 0;
|
|
while (true) {
|
|
seconds++;
|
|
|
|
sol.addForceTo(sol);
|
|
sol.update();
|
|
|
|
if ((seconds % 3600) == 0) {
|
|
cd.clear(Color.BLACK);
|
|
sol.draw(cd);
|
|
cd.show();
|
|
}
|
|
}
|
|
}
|
|
}
|