Skip to content

Commit 94685a1

Browse files
committed
Initial commit
Documentation for each project is in progress.
1 parent 00433d2 commit 94685a1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+5929
-0
lines changed

.gitignore

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
## Java
2+
3+
*.class
4+
*.war
5+
*.ear
6+
hs_err_pid*
7+
8+
## Robovm
9+
robovm-build/
10+
11+
## GWT
12+
war/
13+
html/war/gwt_bree/
14+
html/gwt-unitCache/
15+
.apt_generated/
16+
html/war/WEB-INF/deploy/
17+
html/war/WEB-INF/classes/
18+
.gwt/
19+
gwt-unitCache/
20+
www-test/
21+
.gwt-tmp/
22+
23+
## Android Studio and Intellij and Android in general
24+
android/libs/armeabi/
25+
android/libs/armeabi-v7a/
26+
android/libs/arm64-v8a/
27+
android/libs/x86/
28+
android/libs/x86_64/
29+
android/gen/
30+
.idea/
31+
*.ipr
32+
*.iws
33+
*.iml
34+
out/
35+
com_crashlytics_export_strings.xml
36+
37+
## Eclipse
38+
.classpath
39+
.project
40+
.metadata
41+
**/bin/
42+
tmp/
43+
*.tmp
44+
*.bak
45+
*.swp
46+
*~.nib
47+
local.properties
48+
.settings/
49+
.loadpath
50+
.externalToolBuilders/
51+
*.launch
52+
53+
## NetBeans
54+
**/nbproject/private/
55+
build/
56+
nbbuild/
57+
dist/
58+
nbdist/
59+
nbactions.xml
60+
nb-configuration.xml
61+
62+
## Gradle
63+
64+
.gradle
65+
gradle-app.setting
66+
build/
67+
68+
## OS Specific
69+
.DS_Store
70+
Thumbs.db
71+
72+
#core & extension libs/ folders that have no 3rd party dependencies in them
73+
/gdx/libs
74+
/backends/gdx-backend-jglfw/libs/
75+
/backends/gdx-backend-robovm/libs/
76+
/extensions/gdx-audio/libs/
77+
/extensions/gdx-box2d/gdx-box2d/libs/
78+
/extensions/gdx-bullet/libs/
79+
/extensions/gdx-controllers/gdx-controllers-desktop/libs/
80+
/extensions/gdx-freetype/libs/
81+
/extensions/gdx-image/libs/
82+
/extensions/gdx-setup/gdx-setup.jar
83+
84+
#ensure gdx-setup.jar works properly
85+
!/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/gwt/war
86+
87+
#directories created by fetch.xml
88+
/tests/gdx-tests-android/libs
89+
/tmp/
90+
91+
#gradle wrapper
92+
/gradle/
93+
/gradlew
94+
/gradlew.bat
95+
/local.properties
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package com.interplanetaryorbitcalculator.rollercoaster;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
6+
/**
7+
* Created by Luke on 5/6/2016.
8+
*/
9+
10+
public class Body
11+
{
12+
public static final double G = 6.67408 * Math.pow(10,-11);
13+
public static final double sunMass = 1.989 * Math.pow(10,30);
14+
public static final double earthMass = 5.972 * Math.pow(10,24);
15+
public static final double AU = 149597870700D;
16+
public String name;
17+
public double mass;
18+
public Orbit orbit;
19+
public List<Body> satellites = new ArrayList<Body>();
20+
public Body parentBody;
21+
22+
public Body(String name, double mass)
23+
{
24+
this.name = name;
25+
this.mass = mass;
26+
}
27+
28+
public Body(String name, double mass, Orbit orbit)
29+
{
30+
this.name = name;
31+
this.mass = mass;
32+
this.orbit = orbit;
33+
}
34+
35+
public void addSatellite(Body satellite)
36+
{
37+
satellites.add(satellite);
38+
}
39+
40+
public Body getSatelliteByName(String name)
41+
{
42+
for (int i = 0; i < satellites.size(); i++)
43+
{
44+
if (satellites.get(i).name.equalsIgnoreCase(name))
45+
{
46+
return satellites.get(i);
47+
}
48+
}
49+
return null;
50+
}
51+
52+
public double getSOI()
53+
{
54+
//return orbit.getSemiMajorAxis()*Math.pow(mass/);
55+
return 0;
56+
}
57+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
package com.interplanetaryorbitcalculator.rollercoaster;
2+
3+
import com.badlogic.gdx.ApplicationAdapter;
4+
import com.badlogic.gdx.ApplicationListener;
5+
import com.badlogic.gdx.Gdx;
6+
import com.badlogic.gdx.graphics.*;
7+
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
8+
import com.badlogic.gdx.graphics.g3d.*;
9+
import com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute;
10+
import com.badlogic.gdx.graphics.g3d.environment.DirectionalLight;
11+
import com.badlogic.gdx.graphics.g3d.utils.CameraInputController;
12+
import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder;
13+
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
14+
import com.badlogic.gdx.math.Matrix4;
15+
import com.badlogic.gdx.math.Vector3;
16+
17+
public class MapView implements ApplicationListener
18+
{
19+
public ShapeRenderer renderer;
20+
public PerspectiveCamera camera;
21+
public Model earthModel;
22+
public ModelInstance earthInstance;
23+
public Model rocketModel;
24+
public ModelInstance rocketInstance;
25+
public Matrix4 rocketInitTransform;
26+
public ModelBatch modelBatch;
27+
public Environment environment;
28+
public CameraInputController cameraInputController;
29+
public double ellX;
30+
public double ellY;
31+
public double ellZ;
32+
public Body rocket;
33+
public float sF = 1000000;
34+
public double time=-600;
35+
36+
@Override
37+
public void create () {
38+
renderer = new ShapeRenderer();
39+
modelBatch = new ModelBatch();
40+
41+
environment = new Environment();
42+
environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1));
43+
environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -1f, -0.8f, -0.2f));
44+
45+
camera = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
46+
camera.position.set(0*6371000f*2/sF,2*6371000f*2/sF,0*6371000f*2/sF);
47+
camera.lookAt(0,0,0);
48+
camera.near = 1;
49+
camera.far = 6371000f*4/sF*100;
50+
camera.update();
51+
52+
cameraInputController = new CameraInputController(camera);
53+
Gdx.input.setInputProcessor(cameraInputController);
54+
55+
ModelBuilder modelBuilder = new ModelBuilder();
56+
//model = modelBuilder.createBox(6.371f,6.371f,6.371f, new Material(ColorAttribute.createDiffuse(Color.GREEN)), VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal);
57+
earthModel = modelBuilder.createSphere(6371000f/sF,6371000f/sF,6371000f/sF,100,100, new Material(ColorAttribute.createDiffuse(Color.GREEN)), VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal);
58+
rocketModel = modelBuilder.createSphere(1,1,1,50,50, new Material(ColorAttribute.createDiffuse(Color.BLUE)), VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal);
59+
earthInstance = new ModelInstance(earthModel);
60+
//earthInstance.transform.translate((float)2.5,(float)2.5,(float)2.5);
61+
System.out.println(earthInstance.transform);
62+
rocketInstance = new ModelInstance(rocketModel);
63+
rocketInitTransform = rocketInstance.transform;
64+
65+
rocket = new Body("rocket", 1000, new Orbit(7371000,1000000+6371000, Math.toRadians(0), 0, 0, 0, Body.G* Body.earthMass));
66+
//t=0 defined to be 01/15/2007, 12:30AM
67+
rocket.parentBody = new Body("earth", Body.earthMass, new Orbit(0.98329* Body.AU, 1.0167* Body.AU, Math.toRadians(0.00005), Math.toRadians(-11.26061), Math.toRadians(102.94717), 0, Body.G* Body.sunMass));
68+
rocket.parentBody.addSatellite(rocket);
69+
rocket.parentBody.parentBody = new Body("sun", Body.sunMass);
70+
rocket.parentBody.parentBody.addSatellite(rocket.parentBody);
71+
//Mars reached periapsis at 06/01/2007, 7:20AM
72+
rocket.parentBody.parentBody.addSatellite(new Body("mars", 6.39*Math.pow(10, 23), new Orbit(1.3814* Body.AU, 1.666* Body.AU, Math.toRadians(1.85061), Math.toRadians(49.57854), Math.toRadians(336.04084), 11861400, Body.G* Body.sunMass)));
73+
rocket.parentBody.parentBody.getSatelliteByName("mars").parentBody=rocket.parentBody.parentBody;
74+
System.out.println(rocket.orbit);
75+
}
76+
77+
@Override
78+
public void render () {
79+
Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
80+
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
81+
82+
Gdx.graphics.setVSync(true);
83+
84+
//Vector3 argAxis = new Vector3(0,0,1).rotateRad((float)rocket.orbit.inclination, 0,1,0).rotateRad((float)rocket.orbit.longitude, 0,0,1);
85+
Vector3 position = rocket.orbit.getPosition(time);//.rotate(argAxis, 180);
86+
rocketInstance.transform = rocketInstance.transform.setTranslation(position.scl(1f/sF).rotate(90, 1,0,0));
87+
88+
if (time==0)
89+
{
90+
System.out.println(rocket.orbit.getVelocity(time));
91+
System.out.println(rocket.orbit.getPosition(time));
92+
rocket.orbit = rocket.orbit.perturbOrbit(time, new Vector3(0,100,0));
93+
System.out.println(rocket.orbit.getVelocity(time));
94+
System.out.println(rocket.orbit.getPosition(time));
95+
System.out.println(rocket.orbit);
96+
}
97+
98+
if (time%600==0)
99+
{
100+
System.out.println(rocket.orbit.getPosition(time));
101+
}
102+
103+
time+=10;
104+
105+
cameraInputController.update();
106+
renderer.setProjectionMatrix(camera.combined);
107+
108+
//System.out.println(rocketInstance.transform);
109+
110+
renderer.begin(ShapeRenderer.ShapeType.Line);
111+
renderer.line(-1,0,0,10,0,0);
112+
renderer.line(0,-1,0,0,10,0);
113+
renderer.line(0,0,-1,0,0,10);
114+
float[] par = rocket.orbit.parameterize();
115+
Vector3 center = new Vector3(par[2]/sF,par[3]/sF,par[4]/sF).rotate(90, 1,0,0);
116+
Vector3 semiMajorAxis = new Vector3(par[5],par[6],par[7]).rotate(90, 1,0,0);
117+
Vector3 semiMinorAxis = new Vector3(par[8],par[9],par[10]).rotate(90, 1,0,0);
118+
float sMaA = par[0]/sF;
119+
float sMiA = par[1]/sF;
120+
for (int t = 0; t <= 100; t++)
121+
{
122+
double i = ((double)t/100)*(Math.PI*2);
123+
double x = center.x + sMaA * Math.cos(i) * semiMajorAxis.x + sMiA * Math.sin(i) * semiMinorAxis.x;
124+
double y = center.y + sMaA * Math.cos(i) * semiMajorAxis.y + sMiA * Math.sin(i) * semiMinorAxis.y;
125+
double z = center.z + sMaA * Math.cos(i) * semiMajorAxis.z + sMiA * Math.sin(i) * semiMinorAxis.z;
126+
if (i==0)
127+
{
128+
renderer.line((float)x,(float)y,(float)z,(float)x,(float)y,(float)z);
129+
}
130+
else
131+
{
132+
renderer.line((float)ellX,(float)ellY,(float)ellZ,(float)x,(float)y,(float)z);
133+
}
134+
ellX=x;
135+
ellY=y;
136+
ellZ=z;
137+
138+
}
139+
renderer.end();
140+
141+
modelBatch.begin(camera);
142+
modelBatch.render(earthInstance, environment);
143+
modelBatch.render(rocketInstance, environment);
144+
modelBatch.end();
145+
}
146+
147+
public void dispose()
148+
{
149+
earthModel.dispose();
150+
rocketModel.dispose();
151+
modelBatch.dispose();
152+
}
153+
154+
public void resume()
155+
{
156+
157+
}
158+
159+
public void pause()
160+
{
161+
162+
}
163+
164+
public void resize(int x, int y)
165+
{
166+
167+
}
168+
}

0 commit comments

Comments
 (0)