From 6b1f1ecc2a6a720e1ce1843fe95d2989c1d729b4 Mon Sep 17 00:00:00 2001 From: Lorenz Stechauner Date: Fri, 6 May 2022 22:42:28 +0200 Subject: [PATCH] Refactored for AB5 --- angabe/Aufgabenblatt5.md | 7 +- src/Aufgabe5Test.java | 147 +++++++++++++------------------------ src/Massive.java | 67 +++++++++-------- src/MassiveLinkedList.java | 86 +++++++++++++--------- src/NamedBody.java | 34 +++++---- src/Simulation5.java | 34 +++++---- 6 files changed, 176 insertions(+), 199 deletions(-) diff --git a/angabe/Aufgabenblatt5.md b/angabe/Aufgabenblatt5.md index 9b242cf..10c005e 100644 --- a/angabe/Aufgabenblatt5.md +++ b/angabe/Aufgabenblatt5.md @@ -19,7 +19,7 @@ Ziel der Aufgabe ist die Anwendung der Konzepte: Gleichheit und Hash-Werte, Hash - [Massive](../src/Massive.java) ist ein Interface, das Himmelskörper (als kohärente Massen) beschreibt. `Massive` ist der gemeinsame Obertyp für verschiedene Klassen von Himmelkörpern. Die meisten spezifizierten Methoden sind mit einer `default`-Implementierung definiert. Dieser -Programcode wird ausgeführt, falls die entsprechende Klasse (`Body` oder `NamedBody`) über keine +Programmcode wird ausgeführt, falls die entsprechende Klasse (`Body` oder `NamedBody`) über keine eigene Definition der Methode verfügt. Verändern Sie diese Datei bitte nicht. - [NamedBody](../src/NamedBody.java) ist das Gerüst einer Klassendefinition. Die Klasse repräsentiert Himmelskörper, die einen Namen haben. @@ -100,8 +100,3 @@ Ihre Aufgaben sind folgende: - Implementierung von `Simulation5`: 1 Punkte - Gesamt: 5 Punkte - - - - - diff --git a/src/Aufgabe5Test.java b/src/Aufgabe5Test.java index ba959b6..e188c1e 100644 --- a/src/Aufgabe5Test.java +++ b/src/Aufgabe5Test.java @@ -1,125 +1,78 @@ +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + public class Aufgabe5Test { - public static void main(String[] args) { - + @Test + public void testEP2() { /* //TODO: uncomment for testing //test classes NamedBody and MassiveForceHashMap // create 12 named bodies - NamedBody sun1, mercury1, venus1, earth1, moon1, mars1, deimos1, phobos1, vesta1, - pallas1, hygiea1, ceres1; + NamedBody sun1, mercury1, venus1, earth1, moon1, mars1, deimos1, phobos1, vesta1, pallas1, hygiea1, ceres1; // create a nameless body - Body earth2 = new Body(5.972E24, new Vector3(-6.13135922534815E10,-1.383789852227691E11, - 2.719682263474911E7), new Vector3(26832.720535473603,-11948.23168764519,1.9948243075997851)); - + Body earth2 = new Body(5.972E24, new Vector3(-6.13135922534815E10, -1.383789852227691E11, 2.719682263474911E7), new Vector3(26832.720535473603, -11948.23168764519, 1.9948243075997851)); // create the same 12 named body-force pairs - sun1 = new NamedBody("Sun",1.989E30, new Vector3(0.0,0.0,0.0) - , new Vector3(0.0,0.0,0.0)); - earth1 = new NamedBody("Earth",5.972E24, - new Vector3(-6.13135922534815E10,-1.383789852227691E11,2.719682263474911E7), new Vector3(26832.720535473603,-11948.23168764519,1.9948243075997851)); - moon1 = new NamedBody("Moon",7.349E22, - new Vector3(-6.132484773775896E10,-1.387394951280871E11,1.701046736294776E7), new Vector3(27916.62329282941,-12020.39526008238,-94.89703264508708)); - mars1 = new NamedBody("Mars",6.41712E23, - new Vector3(-1.7923193702925848E11,1.726665823982123E11,7.991673845249474E9), new Vector3(-15925.78496403673,-15381.16179928219,68.67560910598857)); - deimos1 = new NamedBody("Deimos",1.8E20, - new Vector3(-1.792255010450533E11,1.726891122683271E11,7.990659337380297E9), new Vector3(-17100.476719804457,-15020.348656808,631.2927851249581)); - phobos1 = new NamedBody("Phobos",1.08E20, - new Vector3(-1.792253482539647E11,1.72661109673625E11,7.987848354800322E9), new Vector3(-14738.203714241401,-13671.17675223948,-411.0012490555253)); - mercury1 = new NamedBody("Mercury",3.301E23, - new Vector3(-5.167375560011926E10,-4.217574885682655E10,1.14808913958168E9), new Vector3(21580.25398577148,-34951.03632847389,-4835.225596525241)); - venus1 = new NamedBody("Venus",4.86747E24, - new Vector3(-3.123150865740532E10,1.0395568504115701E11,3.173401325838074E9), new Vector3(-33748.180519629335,-10014.25141045021,1809.94488874165)); - vesta1 = new NamedBody("Vesta",2.5908E20, - new Vector3(-3.337493557929893E11,-4.7147908276077385E10,4.1923010146878105E10), new Vector3(4440.54247538484,-19718.49074006637,48.06573124543601)); - pallas1 = new NamedBody("Pallas",2.14E20, - new Vector3(4.3452066613895575E11,-2.057319365171432E11,1.0549957423213101E11), new Vector3(5058.947582097117,11184.45711782372,-8183.524138259704)); - hygiea1 = new NamedBody("Hygiea",8.32E19, - new Vector3(-3.983943433707043E11,2.325833000024021E11,-2.233667695713672E10), new Vector3(-6931.864585548552,-15686.8108598699,-690.5791992347208)); - ceres1 = new NamedBody("Ceres",9.394E20, - new Vector3(3.781372641419032E11,1.96718960466285E11,-6.366459168068592E10), new Vector3(-8555.324226752316,14718.33755980907,2040.230135060142)); + sun1 = new NamedBody("Sun", 1.989E30, new Vector3(0.0, 0.0, 0.0), new Vector3(0.0, 0.0, 0.0)); + earth1 = new NamedBody("Earth", 5.972E24, new Vector3(-6.13135922534815E10, -1.383789852227691E11, 2.719682263474911E7), new Vector3(26832.720535473603, -11948.23168764519, 1.9948243075997851)); + moon1 = new NamedBody("Moon", 7.349E22, new Vector3(-6.132484773775896E10, -1.387394951280871E11, 1.701046736294776E7), new Vector3(27916.62329282941, -12020.39526008238, -94.89703264508708)); + mars1 = new NamedBody("Mars", 6.41712E23, new Vector3(-1.7923193702925848E11, 1.726665823982123E11, 7.991673845249474E9), new Vector3(-15925.78496403673, -15381.16179928219, 68.67560910598857)); + deimos1 = new NamedBody("Deimos", 1.8E20, new Vector3(-1.792255010450533E11, 1.726891122683271E11, 7.990659337380297E9), new Vector3(-17100.476719804457, -15020.348656808, 631.2927851249581)); + phobos1 = new NamedBody("Phobos", 1.08E20, new Vector3(-1.792253482539647E11, 1.72661109673625E11, 7.987848354800322E9), new Vector3(-14738.203714241401, -13671.17675223948, -411.0012490555253)); + mercury1 = new NamedBody("Mercury", 3.301E23, new Vector3(-5.167375560011926E10, -4.217574885682655E10, 1.14808913958168E9), new Vector3(21580.25398577148, -34951.03632847389, -4835.225596525241)); + venus1 = new NamedBody("Venus", 4.86747E24, new Vector3(-3.123150865740532E10, 1.0395568504115701E11, 3.173401325838074E9), new Vector3(-33748.180519629335, -10014.25141045021, 1809.94488874165)); + vesta1 = new NamedBody("Vesta", 2.5908E20, new Vector3(-3.337493557929893E11, -4.7147908276077385E10, 4.1923010146878105E10), new Vector3(4440.54247538484, -19718.49074006637, 48.06573124543601)); + pallas1 = new NamedBody("Pallas", 2.14E20, new Vector3(4.3452066613895575E11, -2.057319365171432E11, 1.0549957423213101E11), new Vector3(5058.947582097117, 11184.45711782372, -8183.524138259704)); + hygiea1 = new NamedBody("Hygiea", 8.32E19, new Vector3(-3.983943433707043E11, 2.325833000024021E11, -2.233667695713672E10), new Vector3(-6931.864585548552, -15686.8108598699, -690.5791992347208)); + ceres1 = new NamedBody("Ceres", 9.394E20, new Vector3(3.781372641419032E11, 1.96718960466285E11, -6.366459168068592E10), new Vector3(-8555.324226752316, 14718.33755980907, 2040.230135060142)); - System.out.println("Test1:"); - NamedBody sun2 = new NamedBody("Sun",1.9895E30, new Vector3(0.1,0.0,0.0) - , new Vector3(0.0,0.0,0.0)); - NamedBody earth3 = new NamedBody("Earth", 1, new Vector3(0,0,0), new Vector3(0,0,0)); - testValue(sun1.equals(sun2), true); - testValue(sun1.hashCode(), sun2.hashCode()); - testValue(earth1.equals(earth3), true); - testValue(earth1.hashCode(), earth3.hashCode()); + NamedBody sun2 = new NamedBody("Sun", 1.9895E30, new Vector3(0.1, 0.0, 0.0), new Vector3(0.0, 0.0, 0.0)); + NamedBody earth3 = new NamedBody("Earth", 1, new Vector3(0, 0, 0), new Vector3(0, 0, 0)); + assertEquals(sun1, sun2); + assertEquals(sun2.hashCode(), sun1.hashCode()); + assertEquals(earth1, earth3); + assertEquals(earth3.hashCode(), earth1.hashCode()); // check basic functions of 'MassiveForceHashMap' - System.out.println("Test2:"); MassiveForceHashMap map = new MassiveForceHashMap(); - map.put(sun1, new Vector3(0,0,0)); - map.put(mercury1, new Vector3(0,0,0)); - map.put(venus1, new Vector3(0,0,0)); - map.put(earth1, new Vector3(0,0,0)); - map.put(moon1, new Vector3(0,0,0)); - map.put(mars1, new Vector3(0,0,0)); - map.put(deimos1, new Vector3(0,0,0)); - map.put(phobos1, new Vector3(0,0,0)); - map.put(vesta1, new Vector3(0,0,0)); - map.put(pallas1, new Vector3(0,0,0)); - map.put(hygiea1, new Vector3(0,0,0)); - map.put(ceres1, new Vector3(0,0,0)); - map.put(mars1, new Vector3(0,0,0)); // inserted twice - testValue(map.keyList().size(), 12); + map.put(sun1, new Vector3(0, 0, 0)); + map.put(mercury1, new Vector3(0, 0, 0)); + map.put(venus1, new Vector3(0, 0, 0)); + map.put(earth1, new Vector3(0, 0, 0)); + map.put(moon1, new Vector3(0, 0, 0)); + map.put(mars1, new Vector3(0, 0, 0)); + map.put(deimos1, new Vector3(0, 0, 0)); + map.put(phobos1, new Vector3(0, 0, 0)); + map.put(vesta1, new Vector3(0, 0, 0)); + map.put(pallas1, new Vector3(0, 0, 0)); + map.put(hygiea1, new Vector3(0, 0, 0)); + map.put(ceres1, new Vector3(0, 0, 0)); + map.put(mars1, new Vector3(0, 0, 0)); // inserted twice + assertEquals(12, map.keyList().size()); - System.out.println("Test3:"); - testValue(map.toString().contains("Mars"), true); - testValue(map.toString().contains("Deimos"), true); - testValue(map.toString().contains("Moon"), true); - testValue(map.toString().contains("Earth"), true); + assertTrue(map.toString().contains("Mars")); + assertTrue(map.toString().contains("Deimos")); + assertTrue(map.toString().contains("Moon")); + assertTrue(map.toString().contains("Earth")); - System.out.println("Test4:"); MassiveLinkedList bl = map.keyList(); boolean allThere = true; while (bl.size() > 0) { allThere &= map.containsKey(bl.pollFirst()); } - testValue(allThere, true); - testValue(map.containsKey(new Body(0,new Vector3(0,0,0), new Vector3(0,0,0))), - false); - testValue(map.containsKey(new NamedBody("Omuamua",0,new Vector3(0,0,0), new Vector3(0,0, - 0))), - false); + assertTrue(allThere); + assertFalse(map.containsKey(new Body(0, new Vector3(0, 0, 0), new Vector3(0, 0, 0)))); + assertFalse(map.containsKey(new NamedBody("Omuamua", 0, new Vector3(0, 0, 0), new Vector3(0, 0, 0)))); - System.out.println("Test5:"); - Vector3 f = new Vector3(5,5,5); + Vector3 f = new Vector3(5, 5, 5); map.put(earth3, f); - testValue(map.get(earth1), f); - testValue(map.get(earth2), null); + assertEquals(f, map.get(earth1)); + assertNull(map.get(earth2)); */ //TODO: uncomment } - - public static void testComparison(Object first, Object second, boolean expected) { - boolean real = first == second; - - if (real == expected) { - System.out.println("Successful comparison"); - } else { - System.out.println("Comparison NOT successful! Expected value: " + expected + " / Given value: " + real); - } - } - - public static void testValue(Object given, Object expected) { - if (given == expected) { - System.out.println("Successful test"); - } else { - System.out.println("Test NOT successful! Expected value: " + expected + " / Given value: " + given); - } - } - - public static void testValue(double given, double expected) { - if (given < expected + (expected + 1) / 1e12 && given > expected - (expected + 1) / 1e12) { - System.out.println("Successful test"); - } else { - System.out.println("Test NOT successful! Expected value: " + expected + " / Given value: " + given); - } - } - } diff --git a/src/Massive.java b/src/Massive.java index 044aa71..bbefb9c 100644 --- a/src/Massive.java +++ b/src/Massive.java @@ -1,64 +1,73 @@ -// Represents a coherent mass with a mass center in 3D space. Has two naming schemes for its -// methods. Please, do not change this interface definition! -// +/** + * Represents a coherent mass with a mass center in 3D space. Has two naming schemes for its + * methods. Please, do not change this interface definition! + */ public interface Massive extends Drawable { - // Returns the mass. + /** + * Returns the mass. + */ default double mass() { - return getMass(); } - // Returns the mass center. + /** + * Returns the mass center. + */ default Vector3 massCenter() { - return getMassCenter(); } - // Returns the mass. + /** + * Returns the mass. + */ default double getMass() { - return mass(); } - // Returns the mass center. + /** + * Returns the mass center. + */ default Vector3 getMassCenter() { - return massCenter(); } - // Returns the approximate radius of 'this', assuming it is a coherent round mass. - // (It is assumed that the radius r is related to the mass m by r = m ^ 0.5, - // where m and r measured in solar units.) + /** + * Returns the approximate radius of 'this', assuming it is a coherent round mass. + * (It is assumed that the radius r is related to the mass m by r = m ^ 0.5, + * where m and r measured in solar units.) + */ default double getRadius() { - return radius(); } - // Returns the approximate radius of 'this', assuming it is a coherent round mass. - // (It is assumed that the radius r is related to the mass m by r = m ^ 0.5, - // where m and r measured in solar units.) + /** + * Returns the approximate radius of 'this', assuming it is a coherent round mass. + * (It is assumed that the radius r is related to the mass m by r = m ^ 0.5, + * where m and r measured in solar units.) + */ default double radius() { - return SpaceDraw.massToRadius(mass()); } - // Returns a vector representing the gravitational force exerted by 'b' on this mass. - // The gravitational Force F is calculated by F = G*(m1*m2)/(r*r), with m1 and m2 being the - // masses of the objects interacting, r being the distance between the centers of the masses - // and G being the gravitational constant. + /** + * Returns a vector representing the gravitational force exerted by 'b' on this mass. + * The gravitational Force F is calculated by F = G*(m1*m2)/(r*r), with m1 and m2 being the + * masses of the objects interacting, r being the distance between the centers of the masses + * and G being the gravitational constant. + */ default Vector3 gravitationalForce(Massive b) { - Vector3 direction = b.massCenter().minus(this.massCenter()); double distance = direction.length(); direction.normalize(); - double force = Simulation.G*this.mass()*b.mass()/(distance * distance); + double force = Simulation.G * this.mass() * b.mass() / (distance * distance); return direction.times(force); } - // Centers this mass at a new position, according to the specified force vector 'force' exerted - // on it, and updates the current velocity vector accordingly. - // (Velocity depends on the mass of 'this', its current velocity and the exerted force.) + /** + * Centers this mass at a new position, according to the specified force vector 'force' exerted + * on it, and updates the current velocity vector accordingly. + * (Velocity depends on the mass of 'this', its current velocity and the exerted force.) + */ void move(Vector3 force); - } diff --git a/src/MassiveLinkedList.java b/src/MassiveLinkedList.java index 74ae6a6..c6834fe 100644 --- a/src/MassiveLinkedList.java +++ b/src/MassiveLinkedList.java @@ -1,94 +1,108 @@ -// A list of massive objects implemented as a linked list. -// The number of elements of the list is not limited. +/** + * A list of massive objects implemented as a linked list. + * The number of elements of the list is not limited. + */ public class MassiveLinkedList { //TODO: declare variables. - // Initializes 'this' as an empty list. + /** + * Initializes 'this' as an empty list. + */ public MassiveLinkedList() { - //TODO: define constructor. } - // Initializes 'this' as an independent copy of the specified list 'list'. - // Calling methods of this list will not affect the specified list 'list' - // and vice versa. - // Precondition: list != null. + /** + * Initializes 'this' as an independent copy of the specified list 'list'. + * Calling methods of this list will not affect the specified list 'list' + * and vice versa. + * Precondition: list != null. + */ public MassiveLinkedList(BodyLinkedList list) { - //TODO: define constructor. } - // Inserts the specified element 'body' at the beginning of this list. + /** + * Inserts the specified element 'body' at the beginning of this list. + */ public void addFirst(Massive body) { - //TODO: implement method. } - // Appends the specified element 'body' to the end of this list. + /** + * Appends the specified element 'body' to the end of this list. + */ public void addLast(Massive body) { - //TODO: implement method. } - // Returns the last element in this list. - // Returns 'null' if the list is empty. + /** + * Returns the last element in this list. + * Returns 'null' if the list is empty. + */ public Massive getLast() { - //TODO: implement method. return null; } - // Returns the first element in this list. - // Returns 'null' if the list is empty. + /** + * Returns the first element in this list. + * Returns 'null' if the list is empty. + */ public Massive getFirst() { - //TODO: implement method. return null; } - // Retrieves and removes the first element in this list. - // Returns 'null' if the list is empty. + /** + * Retrieves and removes the first element in this list. + * Returns 'null' if the list is empty. + */ public Massive pollFirst() { - //TODO: implement method. return null; } - // Retrieves and removes the last element in this list. - // Returns 'null' if the list is empty. + /** + * Retrieves and removes the last element in this list. + * Returns 'null' if the list is empty. + */ public Massive pollLast() { - //TODO: implement method. return null; } - // Inserts the specified element at the specified position in this list. - // Precondition: i >= 0 && i <= size(). + /** + * Inserts the specified element at the specified position in this list. + * Precondition: i >= 0 && i <= size(). + */ public void add(int i, Massive m) { - //TODO: implement method. } - // Returns the element at the specified position in this list. - // Precondition: i >= 0 && i < size(). + /** + * Returns the element at the specified position in this list. + * Precondition: i >= 0 && i < size(). + */ public Massive get(int i) { - //TODO: implement method. return null; } - // Returns the index of the first occurrence of the specified element in this list, or -1 if - // this list does not contain the element. + /** + * Returns the index of the first occurrence of the specified element in this list, or -1 if + * this list does not contain the element. + */ public int indexOf(Massive m) { - //TODO: implement method. return -2; } - // Returns the number of elements in this list. + /** + * Returns the number of elements in this list. + */ public int size() { - //TODO: implement method. return -1; } diff --git a/src/NamedBody.java b/src/NamedBody.java index 2922369..8f08592 100644 --- a/src/NamedBody.java +++ b/src/NamedBody.java @@ -1,42 +1,46 @@ -public class NamedBody /* TODO: add clause(s) */ -{ +public class NamedBody /* TODO: add clause(s) */ { // TODO: add missing parts of this class. - // Initializes this with name, mass, current position and movement. The associated force - // is initialized with a zero vector. + /** + * Initializes this with name, mass, current position and movement. The associated force + * is initialized with a zero vector. + */ public NamedBody(String name, double mass, Vector3 massCenter, Vector3 currentMovement) { // TODO: implement constructor. - } - // Returns the name of the body. + /** + * Returns the name of the body. + */ public String getName() { // TODO: implement method. return ""; - } - // Compares `this` with the specified object. Returns `true` if the specified `o` is not - // `null` and is of type `NamedBody` and both `this` and `o` have equal names. - // Otherwise `false` is returned. + /** + * Compares `this` with the specified object. Returns `true` if the specified `o` is not + * `null` and is of type `NamedBody` and both `this` and `o` have equal names. + * Otherwise `false` is returned. + */ public boolean equals(Object o) { //TODO: implement method. return false; - } - // Returns the hashCode of `this`. + /** + * Returns the hashCode of `this`. + */ public int hashCode() { //TODO: implement method. return 0; - } - // Returns a readable representation including the name of this body. + /** + * Returns a readable representation including the name of this body. + */ public String toString() { //TODO: implement method. return ""; - } } diff --git a/src/Simulation5.java b/src/Simulation5.java index e6f7352..2e77e2e 100644 --- a/src/Simulation5.java +++ b/src/Simulation5.java @@ -3,8 +3,9 @@ import codedraw.CodeDraw; import java.awt.*; import java.util.Random; -// Simulates the formation of a massive solar system. -// +/** + * Simulates the formation of a massive solar system. + */ public class Simulation5 { // gravitational constant @@ -30,25 +31,27 @@ public class Simulation5 { // all quantities are based on units of kilogram respectively second and meter. - // The main simulation method using instances of other classes. + /** + * The main simulation method using instances of other classes. + */ public static void main(String[] args) { // simulation CodeDraw cd = new CodeDraw(); // create solar system with 12 bodies - NamedBody sun = new NamedBody("Sun",1.989E30, new Vector3(0.0,0.0,0.0), new Vector3(0.0,0.0,0.0)); - NamedBody earth = new NamedBody("Earth",5.972E24, new Vector3(-6.13135922534815E10,-1.383789852227691E11,2.719682263474911E7), new Vector3(26832.720535473603,-11948.23168764519,1.9948243075997851)); - NamedBody moon = new NamedBody("Moon",7.349E22, new Vector3(-6.132484773775896E10,-1.387394951280871E11,1.701046736294776E7), new Vector3(27916.62329282941,-12020.39526008238,-94.89703264508708)); - NamedBody mars = new NamedBody("Mars",6.41712E23, new Vector3(-1.7923193702925848E11,1.726665823982123E11,7.991673845249474E9), new Vector3(-15925.78496403673,-15381.16179928219,68.67560910598857)); - NamedBody deimos = new NamedBody("Deimos",1.8E20, new Vector3(-1.792255010450533E11,1.726891122683271E11,7.990659337380297E9), new Vector3(-17100.476719804457,-15020.348656808,631.2927851249581)); - NamedBody phobos = new NamedBody("Phobos",1.08E20, new Vector3(-1.792253482539647E11,1.72661109673625E11,7.987848354800322E9), new Vector3(-14738.203714241401,-13671.17675223948,-411.0012490555253)); - NamedBody mercury = new NamedBody("Mercury",3.301E23, new Vector3(-5.167375560011926E10,-4.217574885682655E10,1.14808913958168E9), new Vector3(21580.25398577148,-34951.03632847389,-4835.225596525241)); - NamedBody venus = new NamedBody("Venus",4.86747E24, new Vector3(-3.123150865740532E10,1.0395568504115701E11,3.173401325838074E9), new Vector3(-33748.180519629335,-10014.25141045021,1809.94488874165)); - NamedBody vesta = new NamedBody("Vesta",2.5908E20, new Vector3(-3.337493557929893E11,-4.7147908276077385E10,4.1923010146878105E10), new Vector3(4440.54247538484,-19718.49074006637,48.06573124543601)); - NamedBody pallas = new NamedBody("Pallas",2.14E20, new Vector3(4.3452066613895575E11,-2.057319365171432E11,1.0549957423213101E11), new Vector3(5058.947582097117,11184.45711782372,-8183.524138259704)); - NamedBody hygiea = new NamedBody("Hygiea",8.32E19, new Vector3(-3.983943433707043E11,2.325833000024021E11,-2.233667695713672E10), new Vector3(-6931.864585548552,-15686.8108598699,-690.5791992347208)); - NamedBody ceres = new NamedBody("Ceres",9.394E20, new Vector3(3.781372641419032E11,1.96718960466285E11,-6.366459168068592E10), new Vector3(-8555.324226752316,14718.33755980907,2040.230135060142)); + NamedBody sun = new NamedBody("Sun", 1.989E30, new Vector3(0.0, 0.0, 0.0), new Vector3(0.0, 0.0, 0.0)); + NamedBody earth = new NamedBody("Earth", 5.972E24, new Vector3(-6.13135922534815E10, -1.383789852227691E11, 2.719682263474911E7), new Vector3(26832.720535473603, -11948.23168764519, 1.9948243075997851)); + NamedBody moon = new NamedBody("Moon", 7.349E22, new Vector3(-6.132484773775896E10, -1.387394951280871E11, 1.701046736294776E7), new Vector3(27916.62329282941, -12020.39526008238, -94.89703264508708)); + NamedBody mars = new NamedBody("Mars", 6.41712E23, new Vector3(-1.7923193702925848E11, 1.726665823982123E11, 7.991673845249474E9), new Vector3(-15925.78496403673, -15381.16179928219, 68.67560910598857)); + NamedBody deimos = new NamedBody("Deimos", 1.8E20, new Vector3(-1.792255010450533E11, 1.726891122683271E11, 7.990659337380297E9), new Vector3(-17100.476719804457, -15020.348656808, 631.2927851249581)); + NamedBody phobos = new NamedBody("Phobos", 1.08E20, new Vector3(-1.792253482539647E11, 1.72661109673625E11, 7.987848354800322E9), new Vector3(-14738.203714241401, -13671.17675223948, -411.0012490555253)); + NamedBody mercury = new NamedBody("Mercury", 3.301E23, new Vector3(-5.167375560011926E10, -4.217574885682655E10, 1.14808913958168E9), new Vector3(21580.25398577148, -34951.03632847389, -4835.225596525241)); + NamedBody venus = new NamedBody("Venus", 4.86747E24, new Vector3(-3.123150865740532E10, 1.0395568504115701E11, 3.173401325838074E9), new Vector3(-33748.180519629335, -10014.25141045021, 1809.94488874165)); + NamedBody vesta = new NamedBody("Vesta", 2.5908E20, new Vector3(-3.337493557929893E11, -4.7147908276077385E10, 4.1923010146878105E10), new Vector3(4440.54247538484, -19718.49074006637, 48.06573124543601)); + NamedBody pallas = new NamedBody("Pallas", 2.14E20, new Vector3(4.3452066613895575E11, -2.057319365171432E11, 1.0549957423213101E11), new Vector3(5058.947582097117, 11184.45711782372, -8183.524138259704)); + NamedBody hygiea = new NamedBody("Hygiea", 8.32E19, new Vector3(-3.983943433707043E11, 2.325833000024021E11, -2.233667695713672E10), new Vector3(-6931.864585548552, -15686.8108598699, -690.5791992347208)); + NamedBody ceres = new NamedBody("Ceres", 9.394E20, new Vector3(3.781372641419032E11, 1.96718960466285E11, -6.366459168068592E10), new Vector3(-8555.324226752316, 14718.33755980907, 2040.230135060142)); // create some additional bodies Body[] bodies = new Body[NUMBER_OF_BODIES]; @@ -63,6 +66,5 @@ public class Simulation5 { //TODO: implementation of this method according to 'Aufgabenblatt5.md'. // Add both, NamedBody- and Body-objects, to your simulation. - } }