diff --git a/simulator/.idea/workspace.xml b/simulator/.idea/workspace.xml
index 19765a5..476807e 100644
--- a/simulator/.idea/workspace.xml
+++ b/simulator/.idea/workspace.xml
@@ -7,8 +7,11 @@
-
+
+
+
+
@@ -29,75 +32,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
-
-
-
@@ -224,46 +159,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -568,7 +463,7 @@
-
+
@@ -578,11 +473,11 @@
-
+
-
+
@@ -614,7 +509,7 @@
-
+
@@ -667,13 +562,18 @@
-
-
+
+
+
+
+
+
+
@@ -741,13 +641,18 @@
-
-
+
+
+
+
+
+
+
@@ -788,13 +693,18 @@
-
-
+
+
+
+
+
+
+
@@ -835,13 +745,18 @@
-
-
+
+
+
+
+
+
+
@@ -882,13 +797,18 @@
-
-
+
+
+
+
+
+
+
@@ -919,13 +839,18 @@
-
-
+
+
+
+
+
+
+
@@ -983,14 +908,6 @@
-
-
-
-
-
-
-
-
@@ -999,26 +916,10 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -1027,29 +928,32 @@
-
-
+
+
-
-
+
+
+
+
+
+
+
-
+
-
-
+
+
-
-
@@ -1062,12 +966,45 @@
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/simulator/out/production/simulator/com/verictas/pos/simulator/Object.class b/simulator/out/production/simulator/com/verictas/pos/simulator/Object.class
index b695225..4cebda6 100644
Binary files a/simulator/out/production/simulator/com/verictas/pos/simulator/Object.class and b/simulator/out/production/simulator/com/verictas/pos/simulator/Object.class differ
diff --git a/simulator/out/production/simulator/com/verictas/pos/simulator/Simulator.class b/simulator/out/production/simulator/com/verictas/pos/simulator/Simulator.class
index 2e53d9e..62132d5 100644
Binary files a/simulator/out/production/simulator/com/verictas/pos/simulator/Simulator.class and b/simulator/out/production/simulator/com/verictas/pos/simulator/Simulator.class differ
diff --git a/simulator/out/production/simulator/com/verictas/pos/simulator/SimulatorConfig.class b/simulator/out/production/simulator/com/verictas/pos/simulator/SimulatorConfig.class
index 753140b..8bfdb3e 100644
Binary files a/simulator/out/production/simulator/com/verictas/pos/simulator/SimulatorConfig.class and b/simulator/out/production/simulator/com/verictas/pos/simulator/SimulatorConfig.class differ
diff --git a/simulator/out/production/simulator/com/verictas/pos/simulator/dataWriter/DataWriter.class b/simulator/out/production/simulator/com/verictas/pos/simulator/dataWriter/DataWriter.class
index 291bae4..34305e7 100644
Binary files a/simulator/out/production/simulator/com/verictas/pos/simulator/dataWriter/DataWriter.class and b/simulator/out/production/simulator/com/verictas/pos/simulator/dataWriter/DataWriter.class differ
diff --git a/simulator/src/com/verictas/pos/simulator/Main.java b/simulator/src/com/verictas/pos/simulator/Main.java
index 81e3964..d5c96c3 100644
--- a/simulator/src/com/verictas/pos/simulator/Main.java
+++ b/simulator/src/com/verictas/pos/simulator/Main.java
@@ -16,7 +16,7 @@ public class Main {
* The MIT License (MIT)
* Copyright (c) 2016 Christiaan Goossens (Verictas) & Daniel Boutros
*
- * The full license is included in the git respository as LICENSE.md
+ * The full license is included in the git repository as LICENSE.md
*/
public static void main(String[] args) {
diff --git a/simulator/src/com/verictas/pos/simulator/Object.java b/simulator/src/com/verictas/pos/simulator/Object.java
index a495488..a4ef64d 100644
--- a/simulator/src/com/verictas/pos/simulator/Object.java
+++ b/simulator/src/com/verictas/pos/simulator/Object.java
@@ -25,9 +25,6 @@ public class Object {
this.mass = mass;
this.position = position;
this.speed = speed;
-
- System.out.println(speed);
-
this.oldAcceleration = new Vector3d(0,0,0);
this.acceleration = new Vector3d(0,0,0);
}
diff --git a/simulator/src/com/verictas/pos/simulator/Simulator.java b/simulator/src/com/verictas/pos/simulator/Simulator.java
index 373ef73..5213405 100644
--- a/simulator/src/com/verictas/pos/simulator/Simulator.java
+++ b/simulator/src/com/verictas/pos/simulator/Simulator.java
@@ -13,13 +13,16 @@ public class Simulator {
*/
int rounds = SimulatorConfig.rounds;
+ double time = SimulatorConfig.time;
/**
* Log a debug message to the console to signal the simulation has started
*/
System.out.println("========== Simulation Started ==========\n");
- // Create a timer
+ /**
+ * Create a time to measure runtime
+ */
long startTime = System.currentTimeMillis();
/**
@@ -52,10 +55,6 @@ public class Simulator {
* The round has started
*/
System.out.println("\nRound " + (t + 1) + " started!");
- /**
- * Define the initial values
- */
- double time = SimulatorConfig.time;
for(int i = 0; i < objects.length; i++) {
objects[i].updatePosition(time);
@@ -64,15 +63,14 @@ public class Simulator {
accelerate(objects, matrix);
- /**
- * Print the matrix for this round
- */
-
for(int i = 0; i < objects.length; i++) {
objects[i].updateSpeed(time);
writer.write(objects[i].name, objects[i].position, objects[i].speed, objects[i].oldAcceleration, objects[i].acceleration, objects[i].mass);
}
+ /**
+ * The round has ended
+ */
}
/**
@@ -81,7 +79,9 @@ public class Simulator {
writer.save();
System.out.println("========== Simulation Finished ==========");
- // Display time info
+ /**
+ * Display information about the program runtime
+ */
long stopTime = System.currentTimeMillis();
System.out.println("Simulation took: " + (stopTime - startTime) + "ms");
} catch(WritingException e) {
diff --git a/simulator/src/com/verictas/pos/simulator/dataWriter/DataWriter.java b/simulator/src/com/verictas/pos/simulator/dataWriter/DataWriter.java
index f1798dd..1ba69f9 100644
--- a/simulator/src/com/verictas/pos/simulator/dataWriter/DataWriter.java
+++ b/simulator/src/com/verictas/pos/simulator/dataWriter/DataWriter.java
@@ -13,25 +13,39 @@ import java.util.Date;
public class DataWriter {
private FileWriter writer = null;
- // Delimiter used in text file (for import in Excel)
+ /**
+ * Set global variables, such as the delimiter and the new line character
+ */
private static final String DELIMITER = "\t";
private static final String NEW_LINE = "\n";
private int counter = 0;
+ /**
+ * Constructor
+ * @throws WritingException
+ */
public DataWriter() throws WritingException {
try {
- // Define the save path
+ /**
+ * Define the save path
+ */
String directory = System.getProperty("user.home") + File.separator + "simulatorExports";
File directoryPath = new File(directory);
String path = directory + File.separator + getCurrentTimeStamp() + ".txt";
System.out.println("WRITING DATA TO: " + path);
+ /**
+ * Check if the saving directory exists to prevent IOException
+ */
if (!directoryPath.exists()) {
directoryPath.mkdirs();
}
+ /**
+ * Open a file to write to and write the header
+ */
this.writer = new FileWriter(path);
this.writer.write("Object" + DELIMITER + "Position (m)" + DELIMITER + "Position (AU)" + DELIMITER + "Speed (m/s)" + DELIMITER + "Speed (AU/day)" + DELIMITER + "Old Acceleration" + DELIMITER + "Acceleration" + DELIMITER + "Mass" + NEW_LINE);
this.counter++;
@@ -42,6 +56,11 @@ public class DataWriter {
}
}
+ /**
+ * Writes a string to the file
+ * @param string
+ * @throws WritingException
+ */
public void write(String string) throws WritingException {
if (this.writer == null) {
throw new WritingException("The writer isn't defined yet");
@@ -58,6 +77,16 @@ public class DataWriter {
}
}
+ /**
+ * Writes some data about the current object to the file
+ * @param id String
+ * @param position Vector3d
+ * @param speed Vector3d
+ * @param oldAcceleration Vector3d
+ * @param acceleration Vector3d
+ * @param mass double
+ * @throws WritingException
+ */
public void write(String id, Vector3d position, Vector3d speed, Vector3d oldAcceleration, Vector3d acceleration, double mass) throws WritingException {
if (this.writer == null) {
throw new WritingException("The writer isn't defined yet");
@@ -74,6 +103,10 @@ public class DataWriter {
}
}
+ /**
+ * Saves the file to disk
+ * @throws WritingException
+ */
public void save() throws WritingException {
if (this.writer == null) {
throw new WritingException("The writer isn't defined yet");
@@ -87,11 +120,19 @@ public class DataWriter {
}
}
+ /**
+ * Gets the current line count
+ * @return int
+ */
public int getLines() {
return this.counter;
}
- public String getCurrentTimeStamp() {
+ /**
+ * Gets the current filestamp for file naming
+ * @return String
+ */
+ private String getCurrentTimeStamp() {
return new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss").format(new Date());
}
}
diff --git a/simulator/src/com/verictas/pos/simulator/mathUtils/AU.java b/simulator/src/com/verictas/pos/simulator/mathUtils/AU.java
index 5c8463e..acf2ace 100644
--- a/simulator/src/com/verictas/pos/simulator/mathUtils/AU.java
+++ b/simulator/src/com/verictas/pos/simulator/mathUtils/AU.java
@@ -6,6 +6,12 @@ public class AU {
/**
* Helper class for working with astronomical units
*/
+
+ /**
+ * Converts AU to meters
+ * @param input Vector3d with values in AU
+ * @return Vector3d with values in meter
+ */
public static Vector3d convertToMeter(Vector3d input) {
Vector3d output = new Vector3d(input);
@@ -16,6 +22,11 @@ public class AU {
return output;
}
+ /**
+ * Converts AU/day to m/s
+ * @param input Vector3d with values in AU/day
+ * @return Vector3d with values in m/s
+ */
public static Vector3d convertToMetersPerSecond(Vector3d input) {
Vector3d output = new Vector3d(input);
@@ -25,6 +36,11 @@ public class AU {
return output;
}
+ /**
+ * Converts meters to AU for data collection
+ * @param input Vector3d with values in meters
+ * @return Vector3d with values in AU
+ */
public static Vector3d convertFromMeter(Vector3d input) {
Vector3d output = new Vector3d(input);
@@ -34,6 +50,11 @@ public class AU {
return output;
}
+ /**
+ * Converts m/s to AU/day for data collection
+ * @param input Vector3d with values in m/s
+ * @return Vector3d with values in AU/day
+ */
public static Vector3d convertFromMetersPerSecond(Vector3d input) {
Vector3d output = new Vector3d(input);