-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSatsCollection.java
88 lines (65 loc) · 1.74 KB
/
SatsCollection.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import java.util.ArrayList;
import javax.vecmath.Vector3d;
/**
*
* @author AbdurRehman
* Create a Sats Collection to be called
*/
public class SatsCollection {
private int satsNumber;
private ArrayList<Sat> Sats;
private int counter;
public SatsCollection(int n) {
this.satsNumber = n;
Sats = new ArrayList<Sat>();
this.counter = 0;
this.iniateSats();
}
//Initialises the sats collection
private void iniateSats(){
for (int i = 0 ; i < satsNumber ; i++)
{
double randA = Math.random() * (4.24 - 1.0) + 1.0 ;
double randB = Math.random() * (randA - 0.7) + 0.7;
while (Math.pow(randA, 2) - Math.pow(randB, 2) <= 0.65)
{
randA = Math.random() * (4.24 - 1.0) + 1.0 ;
randB = Math.random() * (randA - 0.7) + 0.7;
}
randA = randA * 1.0E07;
randB = randB * 1.0E07;
Sat sat = new Sat(randA, randB, i);
Sats.add(sat);
}
}
/**
* This is for the RENDER to get the positions; the previous method is to update everything
* @param ID
* @return Vector3
*/
public Vector3d getSatPositionByID(int ID)
{
return this.getSatPositionByID(ID, this.getCounter());
}
//Our COunter which replaces the timer
private double getCounter() {
this.counter = this.counter + 60;
return this.counter;
}
/**
* Function that sets a new positions and returns a vector
* Please DO ignore z , it is always 1 (this is only private to provide a timer, please do not call it from outside, call the previouse one)
*
* MANU; YOU CAN ADD THE RENDER.UPDATE HERE
*
* @param ID
* @return Vector3 Positions
*/
private Vector3d getSatPositionByID(int ID, double t)
{
return Sats.get(ID).getPositions(t);
}
public int getsize() {
return Sats.size();
}
}