mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-02 17:19:37 +00:00
avoid index out of bounds in getGridIndexes; make optimization use its own boundary
This commit is contained in:
1 parent
d97e4e3b45
commit
60d38ddbb7
2 files changed
+8
-7
No files matched your search
+5
-4
@@ -210,13 +210,13 @@ public class RectangularBoundary implements Boundary {
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
System.out.println("Grid Index Test:");
|
||||
/*System.out.println("Grid Index Test:");
|
||||
for (int i =0; i<vPoints; i++) {
|
||||
for (int j=0; j<hPoints; j++) {
|
||||
System.out.print(""+this.getGridIndex(grid[i][j])+", ");
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
}*/
|
||||
return grid;
|
||||
|
||||
}
|
||||
@@ -229,9 +229,10 @@ public class RectangularBoundary implements Boundary {
|
||||
|
||||
double sPrd = scX[0]*nvHor[0]+scX[1]*nvHor[1];
|
||||
|
||||
int vIdx = (int) Math.round(scX[0]*nvVrt[0]+scX[1]*nvVrt[1]);
|
||||
int hIdx = (int) Math.round(sPrd+(hPoints-1)/2.);
|
||||
int vIdx = Math.min(Math.max(0, (int) Math.round(scX[0]*nvVrt[0]+scX[1]*nvVrt[1])), vPoints-1);
|
||||
int hIdx = Math.min(Math.max(0, (int) Math.round(sPrd+(hPoints-1)/2.)), hPoints-1);
|
||||
|
||||
//System.out.println("getGridIndex: "+vIdx+","+hIdx+"("+vPoints+","+hPoints+")");
|
||||
return new Pair<Integer, Integer>(vIdx,hIdx);
|
||||
|
||||
}
|
||||
|
||||
+3
-3
@@ -194,7 +194,7 @@ public class SailingSimulatorImpl implements SailingSimulator {
|
||||
|
||||
private Path createDjikstra() {
|
||||
//retrieve simulation parameters
|
||||
Boundary boundary = simulationParameters.getBoundaries();
|
||||
Boundary boundary = new RectangularBoundary(simulationParameters.getCourse().get(0),simulationParameters.getCourse().get(1));//simulationParameters.getBoundaries();
|
||||
WindField windField = simulationParameters.getWindField();
|
||||
PolarDiagram polarDiagram = simulationParameters.getBoatPolarDiagram();
|
||||
Position start = simulationParameters.getCourse().get(0);
|
||||
@@ -318,8 +318,8 @@ public class SailingSimulatorImpl implements SailingSimulator {
|
||||
@Override
|
||||
public Map<String, Path> getAllPaths() {
|
||||
Map<String, Path> allPaths = new HashMap<String, Path>();
|
||||
allPaths.put("Dummy", createDummy());
|
||||
allPaths.put("Heuristic", createHeuristic());
|
||||
//allPaths.put("Dummy", createDummy());
|
||||
//allPaths.put("Heuristic", createHeuristic());
|
||||
allPaths.put("Djikstra", createDjikstra());
|
||||
return allPaths;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user