From 010882aef22988f1288f571a0209ff16cfc1e1b9 Mon Sep 17 00:00:00 2001 From: Paul Schaller Date: Thu, 21 Dec 2023 19:54:25 +0100 Subject: [PATCH] Propably fixed a semantic issue which was caused by communication problems: the height of the tree can be bigger than 1.0 --- .../scanning/PointNormalizer.java | 2 ++ .../cristmastreescanning/ExampleTest.java | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/cringe_studios/christmastreescanning/scanning/PointNormalizer.java b/src/main/java/com/cringe_studios/christmastreescanning/scanning/PointNormalizer.java index 67b5210..65c70c8 100644 --- a/src/main/java/com/cringe_studios/christmastreescanning/scanning/PointNormalizer.java +++ b/src/main/java/com/cringe_studios/christmastreescanning/scanning/PointNormalizer.java @@ -54,6 +54,8 @@ public class PointNormalizer { normalizedX = normalizedX * 2.0 - 1.0; normalizedY = 1.0 - normalizedY; + double xyRatio = (biggestYValue - smallestYValue) / (biggestXValue - smallestXValue); + normalizedY = normalizedY * xyRatio; normalizedPoints[i] = new Point2D.Double(normalizedX, normalizedY); } diff --git a/src/test/java/com/cringe_studios/cristmastreescanning/ExampleTest.java b/src/test/java/com/cringe_studios/cristmastreescanning/ExampleTest.java index ab2c7a9..c9ef31b 100644 --- a/src/test/java/com/cringe_studios/cristmastreescanning/ExampleTest.java +++ b/src/test/java/com/cringe_studios/cristmastreescanning/ExampleTest.java @@ -75,9 +75,9 @@ public class ExampleTest { foundYMax = true; } - if(Math.abs(points[i].z - (1.0)) < 0.001) { + /*if(Math.abs(points[i].z - (1.0)) < 0.001) { foundZMax = true; - } + }*/ if(Math.abs(points[i].z - (0.0)) < 0.001) { foundZMin = true; @@ -85,7 +85,7 @@ public class ExampleTest { } - if(foundXMin && foundXMax && foundYMin && foundYMax && foundZMin && foundZMax) { + if(foundXMin && foundXMax && foundYMin && foundYMax && foundZMin /*&& foundZMax*/) { assertTrue(true); }else { System.out.println(foundXMin ); @@ -162,9 +162,9 @@ public class ExampleTest { foundYMax = true; } - if(Math.abs(points[i].z - (1.0)) < 0.001) { + /*if(Math.abs(points[i].z - (1.0)) < 0.001) { foundZMax = true; - } + }*/ if(Math.abs(points[i].z - (0.0)) < 0.001) { foundZMin = true; @@ -172,7 +172,7 @@ public class ExampleTest { } - if(foundXMin && foundXMax && foundYMin && foundYMax && foundZMin && foundZMax) { + if(foundXMin && foundXMax && foundYMin && foundYMax && foundZMin /*&& foundZMax*/) { assertTrue(true); }else { System.out.println(foundXMin );