Implement AB6
This commit is contained in:
@ -65,8 +65,49 @@ public class Simulation6 {
|
||||
);
|
||||
}
|
||||
|
||||
//TODO: implementation of this method according to 'Aufgabenblatt6.md'.
|
||||
// Add both, NamedBody- and Body-objects, to your simulation.
|
||||
MassiveForceTreeMap forceOnBody = new MassiveForceTreeMap();
|
||||
forceOnBody.put(sun, new Vector3());
|
||||
forceOnBody.put(earth, new Vector3());
|
||||
forceOnBody.put(moon, new Vector3());
|
||||
forceOnBody.put(mars, new Vector3());
|
||||
forceOnBody.put(deimos, new Vector3());
|
||||
forceOnBody.put(phobos, new Vector3());
|
||||
forceOnBody.put(mercury, new Vector3());
|
||||
forceOnBody.put(venus, new Vector3());
|
||||
forceOnBody.put(vesta, new Vector3());
|
||||
forceOnBody.put(pallas, new Vector3());
|
||||
forceOnBody.put(hygiea, new Vector3());
|
||||
forceOnBody.put(ceres, new Vector3());
|
||||
|
||||
for (Body b : bodies) {
|
||||
forceOnBody.put(b, new Vector3());
|
||||
}
|
||||
|
||||
long seconds = 0;
|
||||
while (true) {
|
||||
seconds++;
|
||||
|
||||
for (Massive b1 : forceOnBody.getKeys()) {
|
||||
Vector3 force = new Vector3();
|
||||
for (Massive b2 : forceOnBody.getKeys()) {
|
||||
if (b1 != b2) {
|
||||
force = force.plus(b1.gravitationalForce(b2));
|
||||
}
|
||||
}
|
||||
forceOnBody.put(b1, force);
|
||||
}
|
||||
|
||||
for (Massive body : forceOnBody.getKeys()) {
|
||||
body.move(forceOnBody.get(body));
|
||||
}
|
||||
|
||||
if ((seconds % 3600) == 0) {
|
||||
cd.clear(Color.BLACK);
|
||||
for (Massive body : forceOnBody.getKeys()) {
|
||||
body.draw(cd);
|
||||
}
|
||||
cd.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user