diff --git a/simulator/.idea/libraries/vecmath_1_5_1.xml b/simulator/.idea/libraries/vecmath_1_5_1.xml new file mode 100644 index 0000000..f1567b6 --- /dev/null +++ b/simulator/.idea/libraries/vecmath_1_5_1.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/simulator/.idea/workspace.xml b/simulator/.idea/workspace.xml index af754cc..9645724 100644 --- a/simulator/.idea/workspace.xml +++ b/simulator/.idea/workspace.xml @@ -25,18 +25,48 @@ - - + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + - - + \ No newline at end of file diff --git a/simulator/src/com/verictas/pos/simulator/Main.java b/simulator/src/com/verictas/pos/simulator/Main.java index 997ebaf..de78de5 100644 --- a/simulator/src/com/verictas/pos/simulator/Main.java +++ b/simulator/src/com/verictas/pos/simulator/Main.java @@ -1,8 +1,16 @@ package com.verictas.pos.simulator; +import javax.vecmath.*; public class Main { public static void main(String[] args) { System.out.println("Hello World!"); + + Object object1 = new Object(10E8, new Vector3f(1,2,3), new Vector3f(0,4,3)); + Object object2 = new Object(20E4, new Vector3f(2,38,2), new Vector3f(3,4,5)); + + System.out.println(object1.toString()); + System.out.println(object2.toString()); + System.out.println(object1.getForceOnObject(object2)); } } diff --git a/simulator/src/com/verictas/pos/simulator/Object.java b/simulator/src/com/verictas/pos/simulator/Object.java new file mode 100644 index 0000000..abd2edf --- /dev/null +++ b/simulator/src/com/verictas/pos/simulator/Object.java @@ -0,0 +1,41 @@ +package com.verictas.pos.simulator; +import javax.vecmath.*; +import java.lang.*; + +public class Object { + public double mass; + public Vector3f position; + public Vector3f speed; + private double gravitationalConstant = 6.67384E-11; + + public Object(double mass, Vector3f position, Vector3f speed) { + this.mass = mass; + this.position = position; + this.speed = speed; + } + + public void setSpeed(Vector3f speed) { + this.speed = speed; + } + + public void setPosition(Vector3f position) { + this.position = position; + } + + public String toString() { + return "Mass: " + this.mass + " & Position: " + this.position + " & Speed: " + this.speed; + } + + public Vector3f getForceOnObject(Object secondObject) { + double scale = gravitationalConstant * ((this.mass * secondObject.mass) / Math.pow(getDistance(secondObject).length(), 3.0)); + Vector3f force = getDistance(secondObject); + force.scale((float) scale); + return force; + } + + private Vector3f getDistance(Object secondObject) { + Vector3f distance = new Vector3f(0,0,0); // Empty + distance.sub(this.position, secondObject.position); + return distance; + } +} diff --git a/simulator/vecmath-1.5.1.jar b/simulator/vecmath-1.5.1.jar new file mode 100644 index 0000000..6d8b3a1 Binary files /dev/null and b/simulator/vecmath-1.5.1.jar differ