1
0
mirror of https://github.com/christiaangoossens/Planetary-Orbit-Simulator synced 2024-11-24 20:04:09 +00:00

Add aphelion & perihelion calculations

This commit is contained in:
Christiaan Goossens 2016-09-15 16:32:14 +02:00
parent 29c14837eb
commit 8926fbae33
11 changed files with 183 additions and 78 deletions

View File

@ -7,11 +7,15 @@
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="17f368cb-44f8-4101-9a29-49a0f4ff1f92" name="Default" comment="Update workspace"> <list default="true" id="17f368cb-44f8-4101-9a29-49a0f4ff1f92" name="Default" comment="Update workspace">
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/out/production/simulator/com/verictas/pos/simulator/Object.class" afterPath="$PROJECT_DIR$/out/production/simulator/com/verictas/pos/simulator/Object.class" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/out/production/simulator/com/verictas/pos/simulator/Simulator.class" afterPath="$PROJECT_DIR$/out/production/simulator/com/verictas/pos/simulator/Simulator.class" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/out/production/simulator/com/verictas/pos/simulator/dataWriter/DataWriter.class" afterPath="$PROJECT_DIR$/out/production/simulator/com/verictas/pos/simulator/dataWriter/DataWriter.class" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/out/production/simulator/com/verictas/pos/simulator/mathUtils/AU.class" afterPath="$PROJECT_DIR$/out/production/simulator/com/verictas/pos/simulator/mathUtils/AU.class" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/com/verictas/pos/simulator/Main.java" afterPath="$PROJECT_DIR$/src/com/verictas/pos/simulator/Main.java" /> <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/com/verictas/pos/simulator/Main.java" afterPath="$PROJECT_DIR$/src/com/verictas/pos/simulator/Main.java" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/com/verictas/pos/simulator/Object.java" afterPath="$PROJECT_DIR$/src/com/verictas/pos/simulator/Object.java" /> <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/com/verictas/pos/simulator/Object.java" afterPath="$PROJECT_DIR$/src/com/verictas/pos/simulator/Object.java" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/com/verictas/pos/simulator/Simulator.java" afterPath="$PROJECT_DIR$/src/com/verictas/pos/simulator/Simulator.java" /> <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/com/verictas/pos/simulator/Simulator.java" afterPath="$PROJECT_DIR$/src/com/verictas/pos/simulator/Simulator.java" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/com/verictas/pos/simulator/dataWriter/DataWriter.java" afterPath="$PROJECT_DIR$/src/com/verictas/pos/simulator/dataWriter/DataWriter.java" /> <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/com/verictas/pos/simulator/dataWriter/DataWriter.java" afterPath="$PROJECT_DIR$/src/com/verictas/pos/simulator/dataWriter/DataWriter.java" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/com/verictas/pos/simulator/mathUtils/AU.java" afterPath="$PROJECT_DIR$/src/com/verictas/pos/simulator/mathUtils/AU.java" />
</list> </list>
<ignored path="simulator.iws" /> <ignored path="simulator.iws" />
<ignored path=".idea/workspace.xml" /> <ignored path=".idea/workspace.xml" />
@ -68,12 +72,12 @@
<option value="$PROJECT_DIR$/src/com/verictas/pos/simulator/WritingException.java" /> <option value="$PROJECT_DIR$/src/com/verictas/pos/simulator/WritingException.java" />
<option value="$PROJECT_DIR$/src/com/verictas/pos/simulator/DataWriter.java" /> <option value="$PROJECT_DIR$/src/com/verictas/pos/simulator/DataWriter.java" />
<option value="$PROJECT_DIR$/src/com/verictas/pos/simulator/dataWriter/WritingException.java" /> <option value="$PROJECT_DIR$/src/com/verictas/pos/simulator/dataWriter/WritingException.java" />
<option value="$PROJECT_DIR$/src/com/verictas/pos/simulator/SimulatorConfig.java" />
<option value="$PROJECT_DIR$/src/com/verictas/pos/simulator/Main.java" />
<option value="$PROJECT_DIR$/src/com/verictas/pos/simulator/Object.java" />
<option value="$PROJECT_DIR$/src/com/verictas/pos/simulator/Simulator.java" />
<option value="$PROJECT_DIR$/src/com/verictas/pos/simulator/mathUtils/AU.java" /> <option value="$PROJECT_DIR$/src/com/verictas/pos/simulator/mathUtils/AU.java" />
<option value="$PROJECT_DIR$/src/com/verictas/pos/simulator/dataWriter/DataWriter.java" /> <option value="$PROJECT_DIR$/src/com/verictas/pos/simulator/dataWriter/DataWriter.java" />
<option value="$PROJECT_DIR$/src/com/verictas/pos/simulator/Object.java" />
<option value="$PROJECT_DIR$/src/com/verictas/pos/simulator/SimulatorConfig.java" />
<option value="$PROJECT_DIR$/src/com/verictas/pos/simulator/Main.java" />
<option value="$PROJECT_DIR$/src/com/verictas/pos/simulator/Simulator.java" />
</list> </list>
</option> </option>
</component> </component>
@ -159,6 +163,46 @@
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT> </PATH_ELEMENT>
</PATH> </PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="simulator" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="simulator" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="src" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="simulator" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="simulator" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="simulator" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="src" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="simulator" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="dataWriter" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
</subPane> </subPane>
</pane> </pane>
</panes> </panes>
@ -473,11 +517,11 @@
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" /> <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" /> <window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="8" side_tool="false" content_ui="tabs" /> <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="8" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.71881604" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" /> <window_info id="Run" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.3012685" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="9" side_tool="false" content_ui="tabs" /> <window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="9" side_tool="false" content_ui="tabs" />
<window_info id="Capture Tool" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" /> <window_info id="Capture Tool" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Designer" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" /> <window_info id="Designer" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.17864583" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" /> <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.17864583" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="UI Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" /> <window_info id="UI Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
@ -509,7 +553,7 @@
</component> </component>
<component name="XDebuggerManager"> <component name="XDebuggerManager">
<breakpoint-manager> <breakpoint-manager>
<option name="time" value="7" /> <option name="time" value="8" />
</breakpoint-manager> </breakpoint-manager>
<watches-manager /> <watches-manager />
</component> </component>
@ -916,56 +960,6 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/com/verictas/pos/simulator/Main.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="331">
<caret line="20" column="0" selection-start-line="20" selection-start-column="0" selection-end-line="20" selection-end-column="0" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/com/verictas/pos/simulator/Object.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="430">
<caret line="162" column="0" selection-start-line="162" selection-start-column="0" selection-end-line="162" selection-end-column="0" />
<folding>
<element signature="imports" expanded="true" />
<element signature="method#getSpeed#0;class#Object#0" expanded="false" />
<element signature="method#getPosition#0;class#Object#0" expanded="false" />
<element signature="method#setAcceleration#1;class#Object#0" expanded="false" />
<element signature="method#getAcceleration#0;class#Object#0" expanded="false" />
<element signature="method#setOldAcceleration#1;class#Object#0" expanded="false" />
<element signature="method#getOldAcceleration#0;class#Object#0" expanded="false" />
<element signature="method#toString#0;class#Object#0" expanded="false" />
<element signature="method#getForceOnObject#0;class#Object#0" expanded="false" />
<element signature="method#getDistance#0;class#Object#0" expanded="false" />
<element signature="method#updatePosition#0;class#Object#0" expanded="false" />
<element signature="method#updateSpeed#0;class#Object#0" expanded="false" />
<element signature="method#enactForceOnObject#0;class#Object#0" expanded="false" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/com/verictas/pos/simulator/Simulator.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="187">
<caret line="11" column="23" selection-start-line="11" selection-start-column="23" selection-end-line="11" selection-end-column="23" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/com/verictas/pos/simulator/SimulatorConfig.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="153">
<caret line="9" column="1" selection-start-line="9" selection-start-column="1" selection-end-line="9" selection-end-column="1" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/com/verictas/pos/simulator/mathUtils/AU.java"> <entry file="file://$PROJECT_DIR$/src/com/verictas/pos/simulator/mathUtils/AU.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="578"> <state relative-caret-position="578">
@ -995,20 +989,68 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/com/verictas/pos/simulator/SimulatorConfig.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="170">
<caret line="10" column="0" selection-start-line="10" selection-start-column="0" selection-end-line="10" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/com/verictas/pos/simulator/dataWriter/DataWriter.java"> <entry file="file://$PROJECT_DIR$/src/com/verictas/pos/simulator/dataWriter/DataWriter.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1054"> <state relative-caret-position="361">
<caret line="132" column="21" selection-start-line="132" selection-start-column="21" selection-end-line="132" selection-end-column="21" /> <caret line="99" column="0" selection-start-line="99" selection-start-column="0" selection-end-line="99" selection-end-column="0" />
<folding> <folding>
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />
<element signature="method#DataWriter#0;class#DataWriter#0" expanded="false" />
<element signature="method#write#0;class#DataWriter#0" expanded="false" /> <element signature="method#write#0;class#DataWriter#0" expanded="false" />
<element signature="method#write#1;class#DataWriter#0" expanded="false" />
<element signature="method#save#0;class#DataWriter#0" expanded="false" /> <element signature="method#save#0;class#DataWriter#0" expanded="false" />
</folding> </folding>
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/com/verictas/pos/simulator/Object.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="352">
<caret line="24" column="49" selection-start-line="24" selection-start-column="46" selection-end-line="24" selection-end-column="49" />
<folding>
<element signature="imports" expanded="true" />
<element signature="method#getSpeed#0;class#Object#0" expanded="false" />
<element signature="method#getPosition#0;class#Object#0" expanded="false" />
<element signature="method#setAcceleration#1;class#Object#0" expanded="false" />
<element signature="method#getAcceleration#0;class#Object#0" expanded="false" />
<element signature="method#setOldAcceleration#1;class#Object#0" expanded="false" />
<element signature="method#getOldAcceleration#0;class#Object#0" expanded="false" />
<element signature="method#toString#0;class#Object#0" expanded="false" />
<element signature="method#getForceOnObject#0;class#Object#0" expanded="false" />
<element signature="method#getDistance#0;class#Object#0" expanded="false" />
<element signature="method#updatePosition#0;class#Object#0" expanded="false" />
<element signature="method#updateSpeed#0;class#Object#0" expanded="false" />
<element signature="method#enactForceOnObject#0;class#Object#0" expanded="false" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/com/verictas/pos/simulator/Main.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="279">
<caret line="35" column="0" selection-start-line="35" selection-start-column="0" selection-end-line="35" selection-end-column="0" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/com/verictas/pos/simulator/Simulator.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1598">
<caret line="94" column="82" selection-start-line="94" selection-start-column="82" selection-end-line="94" selection-end-column="82" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
</component> </component>
<component name="masterDetails"> <component name="masterDetails">
<states> <states>

View File

@ -21,19 +21,20 @@ public class Main {
public static void main(String[] args) { public static void main(String[] args) {
/** /**
* Object definitions (in 1990) * Object definitions
*/ */
Object sun = new Object("Sun", 1.988544E30, AU.convertToMeter(new Vector3d(3.621484938699030E-03,3.203347049968909E-03,-1.609087138389905E-04)), AU.convertToMetersPerSecond(new Vector3d(-1.730306264794065E-06,6.909301960615850E-06,3.332250766613383E-08))); Object sun = new Object("Sun", 1.988544E30, AU.convertToMeter(new Vector3d(3.621484938699030E-03,3.203347049968909E-03,-1.609087138389905E-04)), AU.convertToMetersPerSecond(new Vector3d(-1.730306264794065E-06,6.909301960615850E-06,3.332250766613383E-08)));
//Object venus = new Object("Venus", 48.685E23, AU.convertToMeter(new Vector3d(-3.786926829662159E-01,-6.122709221027441E-01,1.346180701578967E-02)), AU.convertToMetersPerSecond(new Vector3d(1.703979708314098E-02,-1.075790617185284E-02,-1.130972411646143E-03))); //Object venus = new Object("Venus", 48.685E23, AU.convertToMeter(new Vector3d(-3.786926829662159E-01,-6.122709221027441E-01,1.346180701578967E-02)), AU.convertToMetersPerSecond(new Vector3d(1.703979708314098E-02,-1.075790617185284E-02,-1.130972411646143E-03)));
Object earth = new Object("Earth", 5.97219E24, AU.convertToMeter(new Vector3d(1.000272608326749E+00,-1.305632418724720E-01,-1.614384880329670E-04)), AU.convertToMetersPerSecond(new Vector3d(2.003180730888720E-03,1.698793770993201E-02,5.869001824818362E-08))); Object earth = new Object("Earth", 5.97219E24, AU.convertToMeter(new Vector3d(1.000272608326749E+00,-1.305632418724720E-01,-1.614384880329670E-04)), AU.convertToMetersPerSecond(new Vector3d(2.003180730888720E-03,1.698793770993201E-02,5.869001824818362E-08)));
// Object mars = new Object("Mars", 6.4185E23, AU.convertToMeter(new Vector3d(8.638055532014732E-01,-1.094520306989018E+00,-4.427515002554464E-02)), AU.convertToMetersPerSecond(new Vector3d(1.154235320339802E-02,9.839355267552327E-03,-7.723750026136471E-05))); // Object mars = new Object("Mars", 6.4185E23, AU.convertToMeter(new Vector3d(8.638055532014732E-01,-1.094520306989018E+00,-4.427515002554464E-02)), AU.convertToMetersPerSecond(new Vector3d(1.154235320339802E-02,9.839355267552327E-03,-7.723750026136471E-05)));
// Object jupiter = new Object("Jupiter", 1898.13E24, AU.convertToMeter(new Vector3d(-5.440309619306835E+00,-2.383659935837559E-01,1.226571001615609E-01)), AU.convertToMetersPerSecond(new Vector3d(2.422143907277735E-04,-7.182284468246539E-03,2.440789748210396E-05))); // Object jupiter = new Object("Jupiter", 1898.13E24, AU.convertToMeter(new Vector3d(-5.440309619306835E+00,-2.383659935837559E-01,1.226571001615609E-01)), AU.convertToMetersPerSecond(new Vector3d(2.422143907277735E-04,-7.182284468246539E-03,2.440789748210396E-05)));
Object moon = new Object("The Moon", 734.9E20, AU.convertToMeter(new Vector3d(1.002390058141768E+00,-1.318677081380600E-01,-1.051759034600983E-04)), AU.convertToMetersPerSecond(new Vector3d(2.294349896503608E-03,1.752303034437222E-02,-5.522655228080146E-05)));
/** /**
* Object listing * Object listing
*/ */
Object[] objects = {sun, earth}; Object[] objects = {sun, earth, moon};
/** /**
* Run the simulator for the specified objects * Run the simulator for the specified objects

View File

@ -10,6 +10,11 @@ public class Object {
public Vector3d acceleration; public Vector3d acceleration;
public Vector3d oldAcceleration; public Vector3d oldAcceleration;
public Vector3d aphelion;
public Vector3d perihelion;
public double aphelionDistance = 0;
public double perihelionDistance = 0;
public String name; public String name;
private double gravitationalConstant = 6.67384E-11; private double gravitationalConstant = 6.67384E-11;
@ -197,4 +202,38 @@ public class Object {
acceleration.scale(factor); acceleration.scale(factor);
this.acceleration = acceleration; this.acceleration = acceleration;
} }
/**
* Processes the aphelion & perihelion
* @param sun
*/
public void processAphelionAndPerihelion(Object sun) {
double sunDistance = this.getDistance(sun).length();
/**
* Set the defaults
*/
if (this.aphelionDistance == 0) {
this.aphelionDistance = sunDistance;
}
if (this.perihelionDistance == 0) {
this.perihelionDistance = sunDistance;
}
/**
* Check if the aphelion or perihelion should be changed
*/
if (sunDistance > aphelionDistance) {
this.aphelion = position;
this.aphelionDistance = sunDistance;
}
if (sunDistance < perihelionDistance) {
this.perihelion = position;
this.perihelionDistance = sunDistance;
}
}
} }

View File

@ -38,7 +38,7 @@ public class Simulator {
*/ */
for(int i = 0; i < objects.length; i++) { for(int i = 0; i < objects.length; i++) {
writer.write(objects[i].name, objects[i].position, objects[i].speed, objects[i].oldAcceleration, objects[i].acceleration, objects[i].mass); writer.write(objects[i], objects[0]);
} }
/** /**
@ -65,7 +65,13 @@ public class Simulator {
for(int i = 0; i < objects.length; i++) { for(int i = 0; i < objects.length; i++) {
objects[i].updateSpeed(time); objects[i].updateSpeed(time);
writer.write(objects[i].name, objects[i].position, objects[i].speed, objects[i].oldAcceleration, objects[i].acceleration, objects[i].mass); writer.write(objects[i], objects[0]);
/**
* Do some processing to get the aphelion & perihelion
*/
objects[i].processAphelionAndPerihelion(objects[0]);
} }
/** /**
@ -79,6 +85,15 @@ public class Simulator {
writer.save(); writer.save();
System.out.println("========== Simulation Finished =========="); System.out.println("========== Simulation Finished ==========");
// TEST
System.out.println("\n\n============== Simulation data =============");
System.out.println("Position during aphelion: " + objects[1].aphelion);
System.out.println("Distance from the sun during aphelion in km: " + objects[1].aphelionDistance);
System.out.println("Position during perihelion: " + objects[1].perihelion);
System.out.println("Distance from the sun during perihelion in km: " + objects[1].perihelionDistance);
System.out.println("===========================================\n\n");
/** /**
* Display information about the program runtime * Display information about the program runtime
*/ */

View File

@ -1,5 +1,6 @@
package com.verictas.pos.simulator.dataWriter; package com.verictas.pos.simulator.dataWriter;
import com.verictas.pos.simulator.Object;
import com.verictas.pos.simulator.SimulatorConfig; import com.verictas.pos.simulator.SimulatorConfig;
import com.verictas.pos.simulator.mathUtils.AU; import com.verictas.pos.simulator.mathUtils.AU;
@ -47,7 +48,7 @@ public class DataWriter {
* Open a file to write to and write the header * Open a file to write to and write the header
*/ */
this.writer = new FileWriter(path); 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.writer.write("Object" + DELIMITER + "Position (m)" + DELIMITER + "Position (AU)" + DELIMITER+ "Distance from the sun (m)" + DELIMITER + "Speed (m/s)" + DELIMITER + "Speed (AU/day)" + DELIMITER + "Old Acceleration" + DELIMITER + "Acceleration" + DELIMITER + "Mass" + NEW_LINE);
this.counter++; this.counter++;
} catch(IOException e) { } catch(IOException e) {
throw new WritingException("The destination file couldn't be created."); throw new WritingException("The destination file couldn't be created.");
@ -78,22 +79,29 @@ public class DataWriter {
} }
/** /**
* Writes some data about the current object to the file *
* @param id String * @param object The object you want to write data about
* @param position Vector3d * @param reference The system's star
* @param speed Vector3d
* @param oldAcceleration Vector3d
* @param acceleration Vector3d
* @param mass double
* @throws WritingException * @throws WritingException
*/ */
public void write(String id, Vector3d position, Vector3d speed, Vector3d oldAcceleration, Vector3d acceleration, double mass) throws WritingException { public void write(Object object, Object reference) throws WritingException {
String id = object.name;
Vector3d position = object.position;
Vector3d speed = object.speed;
Vector3d oldAcceleration = object.oldAcceleration;
Vector3d acceleration = object.acceleration;
double mass = object.mass;
if (this.writer == null) { if (this.writer == null) {
throw new WritingException("The writer isn't defined yet"); throw new WritingException("The writer isn't defined yet");
} else { } else {
try { try {
if (this.counter % SimulatorConfig.skipLines == 0) { if (this.counter % SimulatorConfig.skipLines == 0) {
this.writer.append(id + DELIMITER + position.toString() + DELIMITER + AU.convertFromMeter(position).toString() + DELIMITER + speed.toString() + DELIMITER + AU.convertFromMetersPerSecond(speed).toString() + DELIMITER + oldAcceleration.toString() + DELIMITER + acceleration.toString() + DELIMITER + String.valueOf(mass) + NEW_LINE);
// Calculate the distance to the sun
double sunDistance = object.getDistance(reference).length();
this.writer.append(id + DELIMITER + position.toString() + DELIMITER + AU.convertFromMeter(position).toString() + DELIMITER + String.valueOf(sunDistance) + DELIMITER + speed.toString() + DELIMITER + AU.convertFromMetersPerSecond(speed).toString() + DELIMITER + oldAcceleration.toString() + DELIMITER + acceleration.toString() + DELIMITER + String.valueOf(mass) + NEW_LINE);
} }
this.counter++; this.counter++;
} catch (Exception e) { } catch (Exception e) {