Skip to content

Commit

Permalink
Fix bugs
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas ADAM <[email protected]>
  • Loading branch information
tadam50 committed Oct 23, 2023
1 parent 5a133e0 commit c85f848
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ private static void simplifyRecursive(List<Point> path, int start, int end, doub

private static double perpendicularDistance(Point point, Point start, Point end) {
double numerator = Math.abs((end.y() - start.y()) * point.x() - (end.x() - start.x()) * point.y() + end.x() * start.y() - end.y() * start.x());
double denominator = Math.sqrt(Math.pow(end.y() - start.y(), 2) + Math.pow(end.x() - start.x(), 2));
double denominator = Math.sqrt(Math.pow((double) end.y() - (double) start.y(), 2) + Math.pow((double) end.x() - (double) start.x(), 2));
return numerator / denominator;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,19 @@ public void computePathFindingGrid(ZoneGraph graph, LayoutParameters layoutParam
}

// Substations
computeSubstationsAvailability();

// Empty cells
computeEmptyCellsAvailability();

// Horizontal hallways
computeHorizontalHallwaysAvailability(width, height, layoutParameters);

// Vertical hallways
computeVerticalHallwaysAvailability(width, height, layoutParameters);
}

private void computeSubstationsAvailability() {
cellsById.keySet().forEach(id -> {
int ssX = getX(id);
int ssY = getY(id);
Expand All @@ -152,7 +165,9 @@ public void computePathFindingGrid(ZoneGraph graph, LayoutParameters layoutParam
}
}
});
// Empty cells
}

private void computeEmptyCellsAvailability() {
emptyCells.forEach(cell -> {
int ssX = getX(cell.col());
int ssY = getY(cell.row());
Expand All @@ -162,8 +177,9 @@ public void computePathFindingGrid(ZoneGraph graph, LayoutParameters layoutParam
}
}
});
}

// Horizontal hallways
private void computeHorizontalHallwaysAvailability(int width, int height, LayoutParameters layoutParameters) {
for (int r = 0; r < matrixNbRow; r++) {
for (int x = 0; x < width; x++) {
for (int hy = 0; hy < height; hy += snakelineHallwayWidth + matrixCellHeight) {
Expand All @@ -173,7 +189,9 @@ public void computePathFindingGrid(ZoneGraph graph, LayoutParameters layoutParam
}
}
}
// Vertical hallways
}

private void computeVerticalHallwaysAvailability(int width, int height, LayoutParameters layoutParameters) {
for (int c = 0; c < matrixNbCol; c++) {
for (int y = 0; y < height; y++) {
for (int hx = 0; hx < width; hx += snakelineHallwayWidth + matrixCellWidth) {
Expand Down

0 comments on commit c85f848

Please sign in to comment.