-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBackGround.java
60 lines (51 loc) · 1.34 KB
/
BackGround.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
import javax.vecmath.Vector3d;
// this is a Asynch thread that keeps running until its interrupted by a query
public class BackGround extends Thread implements Runnable {
static Home b;
static GUI g;
int a=10;
SatsCollection sats;
static double[]xs,ys,zs;
// put here the object id -> which object details to flood
public BackGround(){
}
public BackGround(GUI g2) {
g = g2; // use to access the gui
// use to access the bodies info
}
@Override
public void run() {
// create satellites here
//System.out.println(b.objects_sats);
sats = new SatsCollection(a); // create n number of satellites
xs = new double[a];
ys = new double[a];
zs = new double[a];
while(true){
//System.out.println("BACKGROUND!!!!");
get_all();
//from bodies which is updated by gui
//xs = xs.clone();
//b.ys = ys.clone();
for(int i=0;i<a;i++)
g.update(xs[i],ys[i],zs[i],i);
//b.xs = xs;
//b.ys = ys; // in bodies
//System.out.println(xs[0]+" "+ys[0]);
// later calculations can go here
try {
Thread.sleep(150);// priority
} catch (InterruptedException e) {}
}
}
public void get_all() {
for(int i=0;i<a;i++){
Vector3d pos = sats.getSatPositionByID(i);
xs[i] = pos.x;
ys[i] = pos.y;
//zs[i] = pos.z;
zs[i] = -0.2 ;
//System.out.println(xs[i]+ " "+ys[i]);
}
}
}