From 4bd767ea160deeb6f530a8144f67dbea9dd5f0a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaros=C5=82aw=20Rulka?= Date: Thu, 9 Apr 2026 14:23:56 +0200 Subject: [PATCH] Fixed: reverse(). --- src/main/java/pl/wat/ms4ds/terrain/GeomUtils.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/pl/wat/ms4ds/terrain/GeomUtils.java b/src/main/java/pl/wat/ms4ds/terrain/GeomUtils.java index 47b42db..d9de3ec 100644 --- a/src/main/java/pl/wat/ms4ds/terrain/GeomUtils.java +++ b/src/main/java/pl/wat/ms4ds/terrain/GeomUtils.java @@ -283,8 +283,8 @@ public class GeomUtils { * Funkcja bada zawieranie się punktu w ramach wielokąta. * * @param polygon współrzędne wierzchołków wielokąta - * @param x współrzedna x badanego punktu - * @param y współrzedna y badanego punktu + * @param x współrzedna x badanego punktu + * @param y współrzedna y badanego punktu * @return true, jeśli testowany punkt należy do wielokąta */ public static boolean insidePolygon(Coord.Grid[] polygon, int x, int y) { @@ -859,7 +859,9 @@ public class GeomUtils { int mid = vertices.length / 2; int last = vertices.length - 1; for (int i = 0; i < mid; i++) { + Coord.Grid swap = vertices[i]; vertices[i] = vertices[last - i]; + vertices[last - i] = swap; } return vertices; } @@ -871,8 +873,7 @@ public class GeomUtils { public static Coord.Grid srodekOdcinka(int x1, int y1, int x2, int y2) { int xsr = (x1 + x2) / 2; int ysr = (y1 + y2) / 2; - Coord.Grid srodek = new Coord.Grid(xsr, ysr); - return srodek; + return new Coord.Grid(xsr, ysr); } /** @@ -916,6 +917,9 @@ public class GeomUtils { // ===================================================================== public static void main(String[] args) { + Coord.Grid[] tab = {new Coord.Grid(0, 0), new Coord.Grid(1, 1), new Coord.Grid(2, 2), new Coord.Grid(4, 4), new Coord.Grid(5, 5)}; + + tab = reverse(tab); int se = sector(0, 0); int sek = sector(0, 9); sek = sector(2, 6);