1
0
mirror of https://github.com/christiaangoossens/Planetary-Orbit-Simulator synced 2025-07-06 11:00:47 +00:00

Moved the processor to the correct file

This commit is contained in:
2016-12-10 19:02:06 +01:00
parent 7bbb858688
commit bba7370aa8
5 changed files with 114 additions and 312 deletions

View File

@ -59,7 +59,7 @@ public class Main {
* Object listing
*/
Object[] objects = {sun, jupiter, saturn, neptune, uranus, object1};
Object[] objects = {sun, earth, moon, jupiter};
/**

View File

@ -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

View File

@ -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);

View File

@ -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<String, Object> initialObjectValues = new HashMap<>();
public HashMap<String, SimpleObjectProcessor> objects = new HashMap<>();
public HashMap<String, TreeMap<Integer, Double>> 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<String, Object> 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<Integer, Double> agmnts = new TreeMap<>();
arguments.put(objectName, agmnts);
}
arguments.get(objectName).put(Simulator.round, object.calculateAOP());
// 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.objects.put(objectName, object);
}
this.write(objects);
}
private void write(HashMap<String, Object> objects) throws ProcessingException, WritingException {
private void writePos(HashMap<String, Object> 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<Integer, Double> arguments = this.arguments.get(objectName);