4 public class Algorithm {
5 public double initialTime,time;
6 public double currIteration;
7 public ConflictList cList;
10 cList=new ConflictList();
13 public /*static*/ void setInitialTime(double time) {
18 public /*static*/ boolean isConflict(D2 d2, Point4d p1, Point4d p2) {
19 Point2d pAux1=new Point2d(p1.x,p1.y);
20 Point2d pAux2=new Point2d(p2.x,p2.y);
21 if ( (Point2d.squaredDistance(pAux1,pAux2) <=
22 Math.pow(d2.getStatic().radius(),2))
24 && Math.abs(p1.z-p2.z) <= d2.getStatic().distance()
31 public /*static*/ Point4d findConflict(D2 d2, Flight a, Flight b) {
32 Point4d conflictPoint=new Point4d(Point4d.outOfRangeTime(),0,0,0);
33 if (a.flightID!=b.flightID) {
34 Vector p1=a.traject.p;
35 Vector p2=b.traject.p;
40 while ( (pos<p1.size()) && (pos<p2.size()) && (!found) ) {
41 Point4d point1=(Point4d) p1.elementAt(pos);
42 Point4d point2=(Point4d) p2.elementAt(pos);
43 if (isConflict(d2, point1,point2)) {
44 System.out.println(point1+" "+point2);
54 public /*static*/ ConflictList getConflictsWith(D2 d2, double time, Flight flight) {
55 ConflictList conflicts=new ConflictList();
57 Vector flights=d2.getFlightList().f;
59 n=d2.getFlightList().noFlights;
61 d2.getTrajectorySynthesizer().updateTrajectory(d2, time, flight);
63 Flight aAux=(Flight) flights.elementAt(i);
64 d2.getTrajectorySynthesizer().updateTrajectory(d2, time, aAux);
69 Flight aux2=(Flight) flights.elementAt(i);
70 Point4d conflictPoint=findConflict(d2, aux1,aux2);
71 if (!(conflictPoint.outOfRange())) {
72 conflicts.newConflict(conflictPoint,aux1,aux2);
78 public /*static*/ void doIteration(D2 d2) {
79 time=initialTime+currIteration*d2.getStatic().iterationStep();
81 System.out.println("In doIteration!");
82 System.out.println("Time:"+time);
86 Vector flights=d2.getFlightList().f;
87 int n=d2.getFlightList().noFlights;
91 Flight aAux=(Flight) flights.elementAt(i);
92 d2.getTrajectorySynthesizer().updateTrajectory(d2, time,aAux);
95 System.out.println("Does it get here? (after the trajectory update)");
99 Flight aux1=(Flight) flights.elementAt(i);
100 Flight aux2=(Flight) flights.elementAt(j);
101 Point4d conflictPoint=findConflict(d2, aux1,aux2);
102 if (!(conflictPoint.outOfRange())) {
103 cList.newConflict(conflictPoint,aux1,aux2);