From bba7370aa8746c66021330695ebf2db2f75e48a6 Mon Sep 17 00:00:00 2001 From: Christiaan Goossens Date: Sat, 10 Dec 2016 19:02:06 +0100 Subject: [PATCH] Moved the processor to the correct file --- simulator/.idea/workspace.xml | 340 +++++------------- .../src/com/verictas/pos/simulator/Main.java | 2 +- .../pos/simulator/SimulatorConfig.java | 7 +- .../AOP.java} | 25 +- .../pos/simulator/processor/Processor.java | 36 +- 5 files changed, 106 insertions(+), 304 deletions(-) rename simulator/src/com/verictas/pos/simulator/{processor/SimpleObjectProcessor.java => mathUtils/AOP.java} (60%) diff --git a/simulator/.idea/workspace.xml b/simulator/.idea/workspace.xml index c195950..db8a0ba 100644 --- a/simulator/.idea/workspace.xml +++ b/simulator/.idea/workspace.xml @@ -7,12 +7,11 @@ - - - - - + + + + @@ -37,18 +36,8 @@ - - - - - - - - - - - - + + @@ -56,101 +45,11 @@ - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -194,19 +93,20 @@ @@ -257,9 +157,6 @@ - - - @@ -310,74 +207,11 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + @@ -718,33 +552,33 @@ - + - + - + - - + + @@ -764,7 +598,7 @@ - @@ -788,6 +622,7 @@ + @@ -833,6 +668,7 @@ + @@ -878,6 +714,7 @@ + @@ -923,6 +760,7 @@ + @@ -958,6 +796,7 @@ + @@ -1010,98 +849,93 @@ - - - - - - - - - + + + - - + + - + - + - + - - + + - - - + + - + - + - + - - - + + + + + - + - - + + - - + - + - - + + - + - - + + - + - - + + - - + + + @@ -1118,49 +952,39 @@ - - - - - - - - - - - + - - + + - + - - - + + + + + - + - - + + - + - - - - - + + + diff --git a/simulator/src/com/verictas/pos/simulator/Main.java b/simulator/src/com/verictas/pos/simulator/Main.java index 18e7702..528f8af 100644 --- a/simulator/src/com/verictas/pos/simulator/Main.java +++ b/simulator/src/com/verictas/pos/simulator/Main.java @@ -59,7 +59,7 @@ public class Main { * Object listing */ - Object[] objects = {sun, jupiter, saturn, neptune, uranus, object1}; + Object[] objects = {sun, earth, moon, jupiter}; /** diff --git a/simulator/src/com/verictas/pos/simulator/SimulatorConfig.java b/simulator/src/com/verictas/pos/simulator/SimulatorConfig.java index d1f26e2..d82b87b 100644 --- a/simulator/src/com/verictas/pos/simulator/SimulatorConfig.java +++ b/simulator/src/com/verictas/pos/simulator/SimulatorConfig.java @@ -5,15 +5,14 @@ public class SimulatorConfig { * Time settings */ - public static int rounds = 3000000; // Amount of rounds to run the simulator for // 3000000 = 250.000 jaar - public static double time = 259200; // Time steps in seconds // 259200 = 1 month + public static int rounds = 2147483647; // Amount of rounds to run the simulator for // 3000000 = 250.000 jaar + public static double time = 60 * 60; // Time steps in seconds // 259200 = 1 month /** * Object settings */ - public static String sunName = "Sun"; // The name of the sun to calculate values TO - public static String[] objectNames = { "Jupiter", "Sedna" }; // The name of the object(s) your want to calculate the values OF + public static String[] objectNames = { "Earth" }; // The name of the object(s) your want to calculate the values OF /** * Output preferences diff --git a/simulator/src/com/verictas/pos/simulator/processor/SimpleObjectProcessor.java b/simulator/src/com/verictas/pos/simulator/mathUtils/AOP.java similarity index 60% rename from simulator/src/com/verictas/pos/simulator/processor/SimpleObjectProcessor.java rename to simulator/src/com/verictas/pos/simulator/mathUtils/AOP.java index 1411372..7fce378 100644 --- a/simulator/src/com/verictas/pos/simulator/processor/SimpleObjectProcessor.java +++ b/simulator/src/com/verictas/pos/simulator/mathUtils/AOP.java @@ -1,36 +1,25 @@ -package com.verictas.pos.simulator.processor; - -import com.verictas.pos.simulator.Object; - +package com.verictas.pos.simulator.mathUtils; import javax.vecmath.Vector3d; -public class SimpleObjectProcessor { - private Object thisObject; - public void setObjectData(Object object) { - this.thisObject = object; - } - - public double calculateAOP() { +public class AOP { + public static double calculate(Vector3d pos, Vector3d speed) { // ORBITAL MOMENTUM VECTOR Vector3d orbitalMomentum = new Vector3d(0,0,0); - Object object = this.thisObject; - - orbitalMomentum.cross(object.speed, object.position); + orbitalMomentum.cross(speed, pos); // ACCENDING NODE VECTOR Vector3d ascendingNode = new Vector3d(0,0,0); ascendingNode.cross(new Vector3d(0,0,1), orbitalMomentum); - // ECCENTRICITY VECTOR double mu = 1.32712440018E20; Vector3d upCross = new Vector3d(0,0,0); - upCross.cross(object.speed, orbitalMomentum); + upCross.cross(speed, orbitalMomentum); upCross.scale(1/mu); - double posLength = object.position.length(); - Vector3d rightPos = object.position; + double posLength = pos.length(); + Vector3d rightPos = pos; rightPos.scale(1/posLength); Vector3d eccentricity = new Vector3d(0,0,0); diff --git a/simulator/src/com/verictas/pos/simulator/processor/Processor.java b/simulator/src/com/verictas/pos/simulator/processor/Processor.java index 98e246a..b0de05b 100644 --- a/simulator/src/com/verictas/pos/simulator/processor/Processor.java +++ b/simulator/src/com/verictas/pos/simulator/processor/Processor.java @@ -6,7 +6,9 @@ import com.verictas.pos.simulator.SimulatorConfig; import com.verictas.pos.simulator.dataWriter.AOPDataWriter; import com.verictas.pos.simulator.dataWriter.PosDataWriter; import com.verictas.pos.simulator.dataWriter.WritingException; +import com.verictas.pos.simulator.mathUtils.AOP; +import javax.vecmath.Vector3d; import java.util.HashMap; import java.util.TreeMap; @@ -14,7 +16,6 @@ public class Processor { private PosDataWriter writer; private AOPDataWriter aopWriter; public HashMap initialObjectValues = new HashMap<>(); - public HashMap objects = new HashMap<>(); public HashMap> arguments = new HashMap<>(); public Processor(Object[] objects) throws ProcessingException, WritingException { @@ -30,26 +31,18 @@ public class Processor { this.initialObjectValues = objectArrayToHashMap(objects); // Write initial values to file - this.write(initialObjectValues); - - /** - * Create the object processing array - */ - for (Object object : initialObjectValues.values()) { - this.objects.put(object.name, new SimpleObjectProcessor()); - } + this.writePos(initialObjectValues); } public void process(Object[] objectArray) throws ProcessingException, WritingException { HashMap objects = objectArrayToHashMap(objectArray); + this.writePos(objects); + /** - * Only do the processing for the asked planet(s) + * Calculate AOP for specified objects */ for(String objectName : SimulatorConfig.objectNames) { - SimpleObjectProcessor object = this.objects.get(objectName); - object.setObjectData(objects.get(objectName)); - // Check if we need to calculate the AOP if (Simulator.round % SimulatorConfig.moduloArgument == 0) { if (arguments.get(objectName) == null) { @@ -57,16 +50,17 @@ public class Processor { TreeMap agmnts = new TreeMap<>(); arguments.put(objectName, agmnts); } - arguments.get(objectName).put(Simulator.round, object.calculateAOP()); - } - this.objects.put(objectName, object); + // Calculate AOP and put it in the array + Object object = objects.get(objectName); + Vector3d pos = new Vector3d(object.position); + Vector3d speed = new Vector3d(object.speed); + arguments.get(objectName).put(Simulator.round, AOP.calculate(pos, speed)); + } } - - this.write(objects); } - private void write(HashMap objects) throws ProcessingException, WritingException { + private void writePos(HashMap objects) throws ProcessingException, WritingException { if (SimulatorConfig.skipUnnecessary) { for (String name : SimulatorConfig.objectNames) { this.writer.write(objects.get(name)); @@ -93,10 +87,6 @@ public class Processor { try { this.writer.save(); System.out.println(""); - - System.out.println("TOTAL RESULTS: " + arguments); - System.out.println(""); - for(String objectName : SimulatorConfig.objectNames) { TreeMap arguments = this.arguments.get(objectName);