-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPlanetOrbit.java
69 lines (63 loc) · 1.71 KB
/
PlanetOrbit.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/**
* PlanetOrbit Class
*/
package astro;
import astro.ATime;
import astro.Xyz;
public class PlanetOrbit {
private int planetNo;
private double jd;
private int nDivision;
private Xyz orbit[];
private void doGetPlanetOrbit(PlanetElm planetElm) {
double ae2 = -2.0 * planetElm.axis * planetElm.e;
double t = Math.sqrt(1.0 - planetElm.e * planetElm.e);
int xp1 = 0;
int xp2 = (nDivision/2);
int xp3 = (nDivision/2);
int xp4 = nDivision;
double E = 0.0;
for (int i = 0; i <= (nDivision/4); i++, E += (360.0 / nDivision)) {
double rcosv = planetElm.axis * (UdMath.udcos(E) - planetElm.e);
double rsinv = planetElm.axis * t * UdMath.udsin(E);
orbit[xp1++] = new Xyz(rcosv, rsinv, 0.0);
orbit[xp2--] = new Xyz(ae2 - rcosv, rsinv, 0.0);
orbit[xp3++] = new Xyz(ae2 - rcosv, -rsinv, 0.0);
orbit[xp4--] = new Xyz(rcosv, -rsinv, 0.0);
}
}
public PlanetOrbit(int planetNo, ATime atime, int nDivision) {
this.planetNo = planetNo;
this.jd = atime.getJd();
this.nDivision = nDivision;
PlanetElm planetElm = new PlanetElm(planetNo, atime);
orbit = new Xyz[nDivision + 1];
doGetPlanetOrbit(planetElm);
Matrix vec = Matrix.VectorConstant(planetElm.peri * Math.PI/180.0,
planetElm.node * Math.PI/180.0,
planetElm.incl * Math.PI/180.0,
atime);
Matrix prec = Matrix.PrecMatrix(atime.getJd(), 2451512.5);
for (int i = 0; i <= nDivision; i++) {
orbit[i] = orbit[i].Rotate(vec).Rotate(prec);
}
}
/**
* Get Epoch
*/
public double getEpoch() {
return jd;
}
/**
* Get Division Count
*/
public int getDivision() {
return nDivision;
}
/**
* Get Orbit Point
*/
public Xyz getAt(int nIndex) {
return orbit[nIndex];
}
}