-
Notifications
You must be signed in to change notification settings - Fork 2
/
Sat.java
73 lines (62 loc) · 1.89 KB
/
Sat.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
70
71
72
73
import javax.vecmath.Vector3d;
/**
*
* @authors AbdurRehman & Ted & Mat
* Sat object which describe it's orbit...
*/
public class Sat extends GravityObject {
private final double normliseFactorS = 11.0E06;
private int ID;
public Sat(){}
public Sat(double a, double b, int id)
{
super();
this.ID = id;
this.semiMajorAxis = a;
this.semiMinorAxis = b;
this.theta = Math.random() * ( 6.28 - 0);
this.setPeriodT(this.semiMajorAxis, this.semiMinorAxis);
this.phaseDif = Math.random() * (this.periodT - 0 ) ;
}
/**
* Get the Positions!! z is always 1
* @param time double
* @return Vector3 positions
*/
public Vector3d getPositions(double t)
{
double xDash = this.getX(t + this.phaseDif) * Math.cos(theta) + this.getY(t + this.phaseDif) * Math.sin(theta);
double yDash = -this.getX(t + this.phaseDif) * Math.sin(theta) + this.getY(t + this.phaseDif) * Math.cos(theta);
Vector3d temp = new Vector3d(xDash, yDash, 1);
return temp;
}
private void setPeriodT(double a, double b)
{
this.periodT = 2*Math.PI * Math.sqrt((Math.pow(this.semiMajorAxis, 3)/MU));
System.out.println(" \nPeriod: " + this.periodT+ "\n");
}
/*
* returns C positions
* @param double t // for current time you want to find the position
*/
public double getY(double t)
{
this.currentTime = t;
this.yPosition =
(this.semiMinorAxis * Math.sin((this.currentTime/this.periodT)*2*Math.PI)) / (2 * this.normliseFactorS) ;
return this.yPosition;
}
/*
* returns C positions
* @param double t // for current time you want to find the position
*/
public double getX(double t)
{
this.currentTime = t;
//Calculating X axis
this.xPosition =
( Math.sqrt( Math.pow(this.semiMajorAxis, 2) - Math.pow(this.semiMinorAxis, 2))
+ this.semiMajorAxis * Math.cos((this.currentTime/this.periodT)*2*Math.PI) ) / (2 * this.normliseFactorS);
return this.xPosition;
}
}