You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2019/12/18 14:06:35 UTC
[commons-geometry] 01/03: GEOMETRY-62: fixing checkstyle issues in
unit tests and enabling checkstyle validation during build
This is an automated email from the ASF dual-hosted git repository.
erans pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-geometry.git
commit e86853dead6dedc96a18615bd10c1cba882c9a26
Author: Matt Juntunen <ma...@hotmail.com>
AuthorDate: Tue Dec 17 23:32:12 2019 -0500
GEOMETRY-62: fixing checkstyle issues in unit tests and enabling checkstyle validation during build
---
.../commons/geometry/core/EmbeddingTest.java | 3 +-
.../commons/geometry/core/GeometryTestUtils.java | 10 +-
.../core/internal/IteratorTransformTest.java | 7 +-
.../core/internal/SimpleTupleFormatTest.java | 27 +-
.../core/partition/test/PartitionTestUtils.java | 46 +-
.../geometry/core/partition/test/TestBSPTree.java | 3 +-
.../geometry/core/partition/test/TestLine.java | 6 +-
.../core/partition/test/TestLineSegment.java | 19 +-
.../test/TestLineSegmentCollectionBuilder.java | 12 +-
.../core/partition/test/TestRegionBSPTree.java | 86 ++++
.../AbstractConvexHyperplaneBoundedRegionTest.java | 4 +-
.../AbstractEmbeddingSubHyperplaneTest.java | 9 +-
.../core/partitioning/AbstractHyperplaneTest.java | 4 -
.../geometry/core/partitioning/SplitTest.java | 4 +-
.../bsp/AbstractBSPTreeMergeOperatorTest.java | 3 -
.../core/partitioning/bsp/AbstractBSPTreeTest.java | 36 +-
.../bsp/AbstractRegionBSPTreeTest.java | 488 ++++-----------------
.../partitioning/bsp/AttributeBSPTreeTest.java | 1 -
.../core/partitioning/bsp/BSPTreeVisitorTest.java | 4 +-
.../core/partitioning/bsp/MergeChecker.java | 227 ++++++++++
.../partitioning/bsp/RegionCutBoundaryTest.java | 1 -
.../core/precision/DoublePrecisionContextTest.java | 1 -
.../EpsilonDoublePrecisionContextTest.java | 5 +-
.../geometry/enclosing/WelzlEncloser2DTest.java | 6 +-
.../geometry/enclosing/WelzlEncloser3DTest.java | 70 +--
.../threed/enclosing/SphereGeneratorTest.java | 46 +-
.../twod/enclosing/DiskGeneratorTest.java | 2 +-
.../geometry/euclidean/EuclideanTestUtils.java | 15 +-
.../geometry/euclidean/internal/MatricesTest.java | 4 +-
.../oned/AffineTransformMatrix1DTest.java | 69 ++-
.../euclidean/oned/FunctionTransform1DTest.java | 8 +-
.../geometry/euclidean/oned/IntervalTest.java | 72 ++-
.../geometry/euclidean/oned/OrientedPointTest.java | 26 +-
.../euclidean/oned/RegionBSPTree1DTest.java | 8 +-
.../geometry/euclidean/oned/Vector1DTest.java | 5 +-
.../threed/AffineTransformMatrix3DTest.java | 171 ++++----
.../euclidean/threed/ConvexSubPlaneTest.java | 6 +-
.../euclidean/threed/ConvexVolumeTest.java | 27 +-
.../euclidean/threed/FunctionTransform3DTest.java | 36 +-
.../geometry/euclidean/threed/Line3DTest.java | 2 +-
.../geometry/euclidean/threed/PlaneTest.java | 9 +-
.../euclidean/threed/RegionBSPTree3DTest.java | 217 +++++----
.../euclidean/threed/SphericalCoordinatesTest.java | 4 +-
.../geometry/euclidean/threed/SubPlaneTest.java | 2 +-
.../geometry/euclidean/threed/Vector3DTest.java | 36 +-
.../threed/rotation/AxisAngleSequenceTest.java | 2 +-
.../threed/rotation/AxisSequenceTest.java | 2 +-
.../threed/rotation/QuaternionRotationTest.java | 49 +--
.../threed/rotation/StandardRotations.java | 29 +-
.../twod/AbstractSegmentConnectorTest.java | 7 +-
.../twod/AffineTransformMatrix2DTest.java | 134 +++---
.../geometry/euclidean/twod/ConvexAreaTest.java | 78 ++--
.../euclidean/twod/FunctionTransform2DTest.java | 28 +-
.../twod/InteriorAngleSegmentConnectorTest.java | 10 +-
.../commons/geometry/euclidean/twod/LineTest.java | 18 +-
.../euclidean/twod/PolarCoordinatesTest.java | 2 +-
.../euclidean/twod/RegionBSPTree2DTest.java | 14 +-
.../geometry/euclidean/twod/SegmentTest.java | 18 +-
.../geometry/euclidean/twod/SubLineTest.java | 23 +-
.../geometry/euclidean/twod/Vector2DTest.java | 17 +-
.../hull/ConvexHullGenerator2DAbstractTest.java | 133 +++---
.../euclidean/twod/hull/MonotoneChainTest.java | 2 +-
.../geometry/spherical/SphericalTestUtils.java | 7 +-
.../spherical/oned/AngularIntervalTest.java | 6 +-
.../geometry/spherical/oned/CutAngleTest.java | 14 +-
.../geometry/spherical/oned/Point1STest.java | 3 +-
.../spherical/oned/RegionBSPTree1STest.java | 135 +++---
.../twod/AbstractGreatArcPathConnectorTest.java | 8 +-
.../geometry/spherical/twod/ConvexArea2STest.java | 2 +-
.../geometry/spherical/twod/GreatArcTest.java | 2 +-
.../geometry/spherical/twod/GreatCircleTest.java | 2 +-
.../twod/InteriorAngleGreatArcConnectorTest.java | 76 ++--
.../spherical/twod/RegionBSPTree2STest.java | 22 +-
.../spherical/twod/SubGreatCircleTest.java | 2 +-
.../geometry/spherical/twod/Transform2STest.java | 6 +-
pom.xml | 21 +-
.../checkstyle/checkstyle-suppressions.xml | 1 +
77 files changed, 1351 insertions(+), 1369 deletions(-)
diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/EmbeddingTest.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/EmbeddingTest.java
index f15fcc8..0274232 100644
--- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/EmbeddingTest.java
+++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/EmbeddingTest.java
@@ -24,9 +24,8 @@ import org.apache.commons.geometry.core.partition.test.PartitionTestUtils;
import org.apache.commons.geometry.core.partition.test.TestLine;
import org.apache.commons.geometry.core.partition.test.TestPoint1D;
import org.apache.commons.geometry.core.partition.test.TestPoint2D;
-import org.junit.Test;
-
import org.junit.Assert;
+import org.junit.Test;
public class EmbeddingTest {
diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/GeometryTestUtils.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/GeometryTestUtils.java
index 242e2d9..76e6a92 100644
--- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/GeometryTestUtils.java
+++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/GeometryTestUtils.java
@@ -26,7 +26,9 @@ import org.junit.Assert;
/** Class containing various geometry-related test utilities.
*/
-public class GeometryTestUtils {
+public final class GeometryTestUtils {
+
+ private GeometryTestUtils() {}
/** Asserts that the given value is positive infinity.
* @param value
@@ -65,8 +67,7 @@ public class GeometryTestUtils {
try {
r.run();
Assert.fail("Operation should have thrown an exception");
- }
- catch (Exception exc) {
+ } catch (Exception exc) {
Class<?> actualType = exc.getClass();
Assert.assertTrue("Expected exception of type " + exceptionType.getName() + " but was " + actualType.getName(),
@@ -89,8 +90,7 @@ public class GeometryTestUtils {
try {
r.run();
Assert.fail("Operation should have thrown an exception");
- }
- catch (Exception exc) {
+ } catch (Exception exc) {
Class<?> actualType = exc.getClass();
Assert.assertTrue("Expected exception of type " + exceptionType.getName() + " but was " + actualType.getName(),
diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/internal/IteratorTransformTest.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/internal/IteratorTransformTest.java
index 8eaab17..c2347cd 100644
--- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/internal/IteratorTransformTest.java
+++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/internal/IteratorTransformTest.java
@@ -59,9 +59,9 @@ public class IteratorTransformTest {
return result;
}
- private static class EvenCharIterator extends IteratorTransform<Integer, String>{
+ private static class EvenCharIterator extends IteratorTransform<Integer, String> {
- public EvenCharIterator(final Iterator<Integer> inputIterator) {
+ EvenCharIterator(final Iterator<Integer> inputIterator) {
super(inputIterator);
}
@@ -80,8 +80,7 @@ public class IteratorTransformTest {
}
addAllOutput(strs);
- }
- else if (chars.length == 1) {
+ } else if (chars.length == 1) {
addOutput(chars[0] + "");
}
}
diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/internal/SimpleTupleFormatTest.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/internal/SimpleTupleFormatTest.java
index acbb022..4aa9622 100644
--- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/internal/SimpleTupleFormatTest.java
+++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/internal/SimpleTupleFormatTest.java
@@ -26,7 +26,7 @@ public class SimpleTupleFormatTest {
private static final String OPEN_PAREN = "(";
private static final String CLOSE_PAREN = ")";
- private static DoubleFunction1N<Stub1D> FACTORY_1D = new DoubleFunction1N<Stub1D>() {
+ private static final DoubleFunction1N<Stub1D> FACTORY_1D = new DoubleFunction1N<Stub1D>() {
@Override
public Stub1D apply(double v) {
@@ -37,7 +37,7 @@ public class SimpleTupleFormatTest {
}
};
- private static DoubleFunction2N<Stub2D> FACTORY_2D = new DoubleFunction2N<Stub2D>() {
+ private static final DoubleFunction2N<Stub2D> FACTORY_2D = new DoubleFunction2N<Stub2D>() {
@Override
public Stub2D apply(double v1, double v2) {
@@ -49,7 +49,7 @@ public class SimpleTupleFormatTest {
}
};
- private static DoubleFunction3N<Stub3D> FACTORY_3D = new DoubleFunction3N<Stub3D>() {
+ private static final DoubleFunction3N<Stub3D> FACTORY_3D = new DoubleFunction3N<Stub3D>() {
@Override
public Stub3D apply(double v1, double v2, double v3) {
@@ -423,8 +423,7 @@ public class SimpleTupleFormatTest {
try {
formatter.parse(str, FACTORY_1D);
Assert.fail("Operation should have failed");
- }
- catch (IllegalArgumentException exc) {
+ } catch (IllegalArgumentException exc) {
String excMsg = exc.getMessage();
Assert.assertTrue("Expected message to contain [" + msgSubstr + "] but was [" + excMsg + "]",
excMsg.contains(msgSubstr));
@@ -442,8 +441,7 @@ public class SimpleTupleFormatTest {
try {
formatter.parse(str, FACTORY_2D);
Assert.fail("Operation should have failed");
- }
- catch (IllegalArgumentException exc) {
+ } catch (IllegalArgumentException exc) {
String excMsg = exc.getMessage();
Assert.assertTrue("Expected message to contain [" + msgSubstr + "] but was [" + excMsg + "]",
excMsg.contains(msgSubstr));
@@ -462,8 +460,7 @@ public class SimpleTupleFormatTest {
try {
formatter.parse(str, FACTORY_3D);
Assert.fail("Operation should have failed");
- }
- catch (IllegalArgumentException exc) {
+ } catch (IllegalArgumentException exc) {
String excMsg = exc.getMessage();
Assert.assertTrue("Expected message to contain [" + msgSubstr + "] but was [" + excMsg + "]",
excMsg.contains(msgSubstr));
@@ -471,17 +468,17 @@ public class SimpleTupleFormatTest {
}
private static class Stub1D {
- public double v;
+ private double v;
}
private static class Stub2D {
- public double v1;
- public double v2;
+ private double v1;
+ private double v2;
}
private static class Stub3D {
- public double v1;
- public double v2;
- public double v3;
+ private double v1;
+ private double v2;
+ private double v3;
}
}
diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partition/test/PartitionTestUtils.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partition/test/PartitionTestUtils.java
index 107e5a7..2172224 100644
--- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partition/test/PartitionTestUtils.java
+++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partition/test/PartitionTestUtils.java
@@ -16,7 +16,12 @@
*/
package org.apache.commons.geometry.core.partition.test;
+import java.util.Arrays;
+import java.util.List;
+
import org.apache.commons.geometry.core.Point;
+import org.apache.commons.geometry.core.Region;
+import org.apache.commons.geometry.core.RegionLocation;
import org.apache.commons.geometry.core.partitioning.bsp.BSPTree;
import org.apache.commons.geometry.core.partitioning.bsp.BSPTree.Node;
import org.apache.commons.geometry.core.precision.DoublePrecisionContext;
@@ -26,13 +31,16 @@ import org.junit.Assert;
/** Class containing utility methods for tests related to the
* partition package.
*/
-public class PartitionTestUtils {
+public final class PartitionTestUtils {
public static final double EPS = 1e-6;
public static final DoublePrecisionContext PRECISION =
new EpsilonDoublePrecisionContext(EPS);
+
+ private PartitionTestUtils() {}
+
/**
* Asserts that corresponding values in the given points are equal.
* @param expected
@@ -44,6 +52,10 @@ public class PartitionTestUtils {
Assert.assertEquals(msg, expected.getY(), actual.getY(), EPS);
}
+ /** Assert that two line segemtns are equal using the default test epsilon.
+ * @param expected
+ * @param actual
+ */
public static void assertSegmentsEqual(TestLineSegment expected, TestLineSegment actual) {
String msg = "Expected line segment to equal " + expected + " but was " + actual;
@@ -58,6 +70,32 @@ public class PartitionTestUtils {
actual.getEndPoint().getY(), EPS);
}
+ /** Assert that all given points lie in the expected location of the region.
+ * @param region region to test
+ * @param location expected location of all points
+ * @param points points to test
+ */
+ public static void assertPointLocations(final Region<TestPoint2D> region, final RegionLocation location,
+ final TestPoint2D... points) {
+ assertPointLocations(region, location, Arrays.asList(points));
+ }
+
+ /** Assert that all given points lie in the expected location of the region.
+ * @param region region to test
+ * @param location expected location of all points
+ * @param points points to test
+ */
+ public static void assertPointLocations(final Region<TestPoint2D> region, final RegionLocation location,
+ final List<TestPoint2D> points) {
+
+ for (TestPoint2D p : points) {
+ Assert.assertEquals("Unexpected location for point " + p, location, region.classify(p));
+ }
+ }
+
+ /** Assert that the given node is a consistent internal node.
+ * @param node
+ */
public static void assertIsInternalNode(Node<?, ?> node) {
Assert.assertNotNull(node.getCut());
Assert.assertNotNull(node.getMinus());
@@ -67,6 +105,9 @@ public class PartitionTestUtils {
Assert.assertFalse(node.isLeaf());
}
+ /** Assert that the given node is a consistent leaf node.
+ * @param node
+ */
public static void assertIsLeafNode(Node<?, ?> node) {
Assert.assertNull(node.getCut());
Assert.assertNull(node.getMinus());
@@ -101,8 +142,7 @@ public class PartitionTestUtils {
Assert.assertNull(msg, node.getMinus());
Assert.assertNull(msg, node.getPlus());
- }
- else {
+ } else {
String msg = "Node with cut must have children";
Assert.assertNotNull(msg, node.getMinus());
diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partition/test/TestBSPTree.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partition/test/TestBSPTree.java
index 1540788..81a4f1e 100644
--- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partition/test/TestBSPTree.java
+++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partition/test/TestBSPTree.java
@@ -22,6 +22,7 @@ import org.apache.commons.geometry.core.partitioning.bsp.AbstractBSPTree;
/** BSP Tree implementation class for testing purposes.
*/
public class TestBSPTree extends AbstractBSPTree<TestPoint2D, TestBSPTree.TestNode> {
+
/** {@inheritDoc} */
@Override
protected TestNode createNode() {
@@ -42,7 +43,7 @@ public class TestBSPTree extends AbstractBSPTree<TestPoint2D, TestBSPTree.TestNo
/** BSP Tree node class for {@link TestBSPTree}.
*/
- public static class TestNode extends AbstractBSPTree.AbstractNode<TestPoint2D,TestNode> {
+ public static class TestNode extends AbstractBSPTree.AbstractNode<TestPoint2D, TestNode> {
public TestNode(AbstractBSPTree<TestPoint2D, TestNode> tree) {
super(tree);
}
diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partition/test/TestLine.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partition/test/TestLine.java
index e70f869..0f4ba88 100644
--- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partition/test/TestLine.java
+++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partition/test/TestLine.java
@@ -147,8 +147,7 @@ public class TestLine implements EmbeddingHyperplane<TestPoint2D, TestPoint1D> {
if (dirXCmp == 0) {
// vertical line
x = getOrigin().getX();
- }
- else {
+ } else {
x = (dirXCmp < 0 ^ abscissa < 0) ? Double.NEGATIVE_INFINITY : Double.POSITIVE_INFINITY;
}
@@ -156,8 +155,7 @@ public class TestLine implements EmbeddingHyperplane<TestPoint2D, TestPoint1D> {
if (dirYCmp == 0) {
// horizontal line
y = getOrigin().getY();
- }
- else {
+ } else {
y = (dirYCmp < 0 ^ abscissa < 0) ? Double.NEGATIVE_INFINITY : Double.POSITIVE_INFINITY;
}
diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partition/test/TestLineSegment.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partition/test/TestLineSegment.java
index b368dfa..011e010 100644
--- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partition/test/TestLineSegment.java
+++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partition/test/TestLineSegment.java
@@ -150,8 +150,7 @@ public class TestLineSegment implements ConvexSubHyperplane<TestPoint2D> {
if (startCmp == 0 || endCmp == 0) {
return RegionLocation.BOUNDARY;
- }
- else if (startCmp > 0 && endCmp < 0) {
+ } else if (startCmp > 0 && endCmp < 0) {
return RegionLocation.INSIDE;
}
}
@@ -252,13 +251,11 @@ public class TestLineSegment implements ConvexSubHyperplane<TestPoint2D> {
final int sign = PartitionTestUtils.PRECISION.sign(originOffset);
if (sign < 0) {
return new Split<TestLineSegment>(this, null);
- }
- else if (sign > 0) {
+ } else if (sign > 0) {
return new Split<TestLineSegment>(null, this);
}
return new Split<TestLineSegment>(null, null);
- }
- else {
+ } else {
// the lines intersect
final double intersectionAbscissa = line.toSubspaceValue(intersection);
@@ -275,7 +272,7 @@ public class TestLineSegment implements ConvexSubHyperplane<TestPoint2D> {
final double startOffset = splitter.offset(line.toSpace(intersectionAbscissa - 1));
final double startCmp = PartitionTestUtils.PRECISION.sign(startOffset);
- final TestLineSegment minus = (startCmp > 0) ? endSegment: startSegment;
+ final TestLineSegment minus = (startCmp > 0) ? endSegment : startSegment;
final TestLineSegment plus = (startCmp > 0) ? startSegment : endSegment;
return new Split<TestLineSegment>(minus, plus);
@@ -310,12 +307,10 @@ public class TestLineSegment implements ConvexSubHyperplane<TestPoint2D> {
if (startCmp == 0 && endCmp == 0) {
// the entire line segment is directly on the splitter line
return new Split<TestLineSegment>(null, null);
- }
- else if (startCmp < 1 && endCmp < 1) {
+ } else if (startCmp < 1 && endCmp < 1) {
// the entire line segment is on the minus side
return new Split<TestLineSegment>(this, null);
- }
- else if (startCmp > -1 && endCmp > -1) {
+ } else if (startCmp > -1 && endCmp > -1) {
// the entire line segment is on the plus side
return new Split<TestLineSegment>(null, this);
}
@@ -327,7 +322,7 @@ public class TestLineSegment implements ConvexSubHyperplane<TestPoint2D> {
final TestLineSegment startSegment = new TestLineSegment(start, intersectionAbscissa, line);
final TestLineSegment endSegment = new TestLineSegment(intersectionAbscissa, end, line);
- final TestLineSegment minus = (startCmp > 0) ? endSegment: startSegment;
+ final TestLineSegment minus = (startCmp > 0) ? endSegment : startSegment;
final TestLineSegment plus = (startCmp > 0) ? startSegment : endSegment;
return new Split<TestLineSegment>(minus, plus);
diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partition/test/TestLineSegmentCollectionBuilder.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partition/test/TestLineSegmentCollectionBuilder.java
index 8ab0d73..4deeb2a 100644
--- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partition/test/TestLineSegmentCollectionBuilder.java
+++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partition/test/TestLineSegmentCollectionBuilder.java
@@ -63,19 +63,17 @@ public class TestLineSegmentCollectionBuilder implements SubHyperplane.Builder<T
private void addSegment(final double start, final double end) {
if (intervals.isEmpty()) {
intervals.add(new SegmentInterval(start, end));
- }
- else {
+ } else {
boolean added = false;
SegmentInterval current;
- for (int i=0; i<intervals.size() && !added; ++i) {
+ for (int i = 0; i < intervals.size() && !added; ++i) {
current = intervals.get(i);
if (end < current.start) {
intervals.add(i, new SegmentInterval(start, end));
added = true;
- }
- else if (start <= current.end) {
+ } else if (start <= current.end) {
current.start = Math.min(current.start, start);
current.end = Math.max(current.end, end);
@@ -90,8 +88,8 @@ public class TestLineSegmentCollectionBuilder implements SubHyperplane.Builder<T
}
private static class SegmentInterval {
- public double start;
- public double end;
+ private double start;
+ private double end;
SegmentInterval(final double start, final double end) {
this.start = start;
diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partition/test/TestRegionBSPTree.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partition/test/TestRegionBSPTree.java
new file mode 100644
index 0000000..a8f052e
--- /dev/null
+++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partition/test/TestRegionBSPTree.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.geometry.core.partition.test;
+
+import org.apache.commons.geometry.core.RegionLocation;
+import org.apache.commons.geometry.core.partitioning.ConvexSubHyperplane;
+import org.apache.commons.geometry.core.partitioning.Hyperplane;
+import org.apache.commons.geometry.core.partitioning.Split;
+import org.apache.commons.geometry.core.partitioning.bsp.AbstractBSPTree;
+import org.apache.commons.geometry.core.partitioning.bsp.AbstractRegionBSPTree;
+
+/** Region BSP Tree implementation class for testing purposes.
+ */
+public final class TestRegionBSPTree extends AbstractRegionBSPTree<TestPoint2D, TestRegionBSPTree.TestRegionNode> {
+
+ public TestRegionBSPTree() {
+ this(true);
+ }
+
+ public TestRegionBSPTree(final boolean full) {
+ super(full);
+ }
+
+ /**
+ * Expose the direct node cut method for easier creation of test tree structures.
+ */
+ @Override
+ public void cutNode(final TestRegionNode node, final ConvexSubHyperplane<TestPoint2D> cut) {
+ super.cutNode(node, cut);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ protected TestRegionNode createNode() {
+ return new TestRegionNode(this);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ protected RegionSizeProperties<TestPoint2D> computeRegionSizeProperties() {
+ // return a set of stub values
+ return new RegionSizeProperties<>(1, TestPoint2D.ZERO);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public boolean contains(TestPoint2D pt) {
+ return classify(pt) != RegionLocation.OUTSIDE;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Split<TestRegionBSPTree> split(Hyperplane<TestPoint2D> splitter) {
+ return split(splitter, new TestRegionBSPTree(), new TestRegionBSPTree());
+ }
+
+ /** BSP Tree node class for {@link TestRegionBSPTree}.
+ */
+ public static final class TestRegionNode
+ extends AbstractRegionBSPTree.AbstractRegionNode<TestPoint2D, TestRegionNode> {
+
+ protected TestRegionNode(AbstractBSPTree<TestPoint2D, TestRegionNode> tree) {
+ super(tree);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ protected TestRegionNode getSelf() {
+ return this;
+ }
+ }
+}
diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/AbstractConvexHyperplaneBoundedRegionTest.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/AbstractConvexHyperplaneBoundedRegionTest.java
index 8b25791..7cdfbcd 100644
--- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/AbstractConvexHyperplaneBoundedRegionTest.java
+++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/AbstractConvexHyperplaneBoundedRegionTest.java
@@ -497,13 +497,13 @@ public class AbstractConvexHyperplaneBoundedRegionTest {
Assert.assertTrue(str.contains("boundaries= "));
}
- private static void checkClassify(Region<TestPoint2D> region, RegionLocation loc, TestPoint2D ... pts) {
+ private static void checkClassify(Region<TestPoint2D> region, RegionLocation loc, TestPoint2D... pts) {
for (TestPoint2D pt : pts) {
Assert.assertEquals("Unexpected location for point " + pt, loc, region.classify(pt));
}
}
- private static final class StubRegion extends AbstractConvexHyperplaneBoundedRegion<TestPoint2D, TestLineSegment>{
+ private static final class StubRegion extends AbstractConvexHyperplaneBoundedRegion<TestPoint2D, TestLineSegment> {
private static final StubRegion FULL = new StubRegion(Collections.emptyList());
diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/AbstractEmbeddingSubHyperplaneTest.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/AbstractEmbeddingSubHyperplaneTest.java
index 6b75c0a..d91f2f8 100644
--- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/AbstractEmbeddingSubHyperplaneTest.java
+++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/AbstractEmbeddingSubHyperplaneTest.java
@@ -106,11 +106,11 @@ public class AbstractEmbeddingSubHyperplaneTest {
private final StubRegion1D region;
- public StubSubHyperplane() {
+ StubSubHyperplane() {
this(0);
}
- public StubSubHyperplane(final double size) {
+ StubSubHyperplane(final double size) {
this.region = new StubRegion1D(size);
}
@@ -154,7 +154,7 @@ public class AbstractEmbeddingSubHyperplaneTest {
private final double size;
- public StubRegion1D(final double size) {
+ StubRegion1D(final double size) {
this.size = size;
}
@@ -189,8 +189,7 @@ public class AbstractEmbeddingSubHyperplaneTest {
if (sign < 0) {
return RegionLocation.INSIDE;
- }
- else if (sign == 0) {
+ } else if (sign == 0) {
return RegionLocation.BOUNDARY;
}
return RegionLocation.OUTSIDE;
diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/AbstractHyperplaneTest.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/AbstractHyperplaneTest.java
index 89e677c..98fe31f 100644
--- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/AbstractHyperplaneTest.java
+++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/AbstractHyperplaneTest.java
@@ -19,10 +19,6 @@ package org.apache.commons.geometry.core.partitioning;
import org.apache.commons.geometry.core.Transform;
import org.apache.commons.geometry.core.partition.test.TestLine;
import org.apache.commons.geometry.core.partition.test.TestPoint2D;
-import org.apache.commons.geometry.core.partitioning.AbstractHyperplane;
-import org.apache.commons.geometry.core.partitioning.ConvexSubHyperplane;
-import org.apache.commons.geometry.core.partitioning.Hyperplane;
-import org.apache.commons.geometry.core.partitioning.HyperplaneLocation;
import org.apache.commons.geometry.core.precision.DoublePrecisionContext;
import org.apache.commons.geometry.core.precision.EpsilonDoublePrecisionContext;
import org.junit.Assert;
diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/SplitTest.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/SplitTest.java
index 5b4ec57..89ac124 100644
--- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/SplitTest.java
+++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/SplitTest.java
@@ -16,10 +16,8 @@
*/
package org.apache.commons.geometry.core.partitioning;
-import org.junit.Test;
-import org.apache.commons.geometry.core.partitioning.Split;
-import org.apache.commons.geometry.core.partitioning.SplitLocation;
import org.junit.Assert;
+import org.junit.Test;
public class SplitTest {
diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractBSPTreeMergeOperatorTest.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractBSPTreeMergeOperatorTest.java
index 4f1a5fc..d3c2f91 100644
--- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractBSPTreeMergeOperatorTest.java
+++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractBSPTreeMergeOperatorTest.java
@@ -19,9 +19,6 @@ package org.apache.commons.geometry.core.partitioning.bsp;
import org.apache.commons.geometry.core.partition.test.PartitionTestUtils;
import org.apache.commons.geometry.core.partition.test.TestLine;
import org.apache.commons.geometry.core.partition.test.TestPoint2D;
-import org.apache.commons.geometry.core.partitioning.bsp.AbstractBSPTreeMergeOperator;
-import org.apache.commons.geometry.core.partitioning.bsp.AttributeBSPTree;
-import org.apache.commons.geometry.core.partitioning.bsp.BSPTree;
import org.apache.commons.geometry.core.partitioning.bsp.AttributeBSPTree.AttributeNode;
import org.junit.Assert;
import org.junit.Test;
diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractBSPTreeTest.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractBSPTreeTest.java
index b3077bc..18e5a48 100644
--- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractBSPTreeTest.java
+++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractBSPTreeTest.java
@@ -1087,8 +1087,7 @@ public class AbstractBSPTreeTest {
List<TestNode> nodes = new ArrayList<>();
// act
- for (TestNode node : tree)
- {
+ for (TestNode node : tree) {
nodes.add(node);
}
@@ -1113,8 +1112,7 @@ public class AbstractBSPTreeTest {
List<TestNode> nodes = new ArrayList<>();
// act
- for (TestNode node : tree)
- {
+ for (TestNode node : tree) {
nodes.add(node);
}
@@ -1202,8 +1200,7 @@ public class AbstractBSPTreeTest {
List<TestNode> nodes = new ArrayList<>();
// act
- for (TestNode n : node)
- {
+ for (TestNode n : node) {
nodes.add(n);
}
@@ -1222,8 +1219,7 @@ public class AbstractBSPTreeTest {
List<TestNode> nodes = new ArrayList<>();
// act
- for (TestNode n : node)
- {
+ for (TestNode n : node) {
nodes.add(n);
}
@@ -1520,7 +1516,7 @@ public class AbstractBSPTreeTest {
// arrange
TestBSPTree tree = new TestBSPTree();
- Transform<TestPoint2D> t = new TestTransform2D((p) -> new TestPoint2D(p.getX(), p.getY() + 2));
+ Transform<TestPoint2D> t = new TestTransform2D(p -> new TestPoint2D(p.getX(), p.getY() + 2));
// act
tree.transform(t);
@@ -1536,7 +1532,7 @@ public class AbstractBSPTreeTest {
TestBSPTree tree = new TestBSPTree();
tree.getRoot().insertCut(TestLine.X_AXIS);
- Transform<TestPoint2D> t = new TestTransform2D((p) -> new TestPoint2D(p.getX(), p.getY() + 2));
+ Transform<TestPoint2D> t = new TestTransform2D(p -> new TestPoint2D(p.getX(), p.getY() + 2));
// act
tree.transform(t);
@@ -1563,7 +1559,7 @@ public class AbstractBSPTreeTest {
new TestLineSegment(new TestPoint2D(3, 1), new TestPoint2D(3, 2))
));
- Transform<TestPoint2D> t = new TestTransform2D((p) -> new TestPoint2D(0.5 * p.getX(), p.getY() + 2));
+ Transform<TestPoint2D> t = new TestTransform2D(p -> new TestPoint2D(0.5 * p.getX(), p.getY() + 2));
// act
tree.transform(t);
@@ -1601,7 +1597,7 @@ public class AbstractBSPTreeTest {
new TestLineSegment(new TestPoint2D(0, 3), new TestPoint2D(3, 0))
));
- Transform<TestPoint2D> t = new TestTransform2D((p) -> new TestPoint2D(-p.getX(), p.getY()));
+ Transform<TestPoint2D> t = new TestTransform2D(p -> new TestPoint2D(-p.getX(), p.getY()));
Map<TestPoint2D, TestNode> pointNodeMap = createPointNodeMap(tree, -5, 5);
@@ -1625,7 +1621,7 @@ public class AbstractBSPTreeTest {
new TestLineSegment(new TestPoint2D(0, 3), new TestPoint2D(3, 0))
));
- Transform<TestPoint2D> t = new TestTransform2D((p) -> new TestPoint2D(p.getX(), -p.getY()));
+ Transform<TestPoint2D> t = new TestTransform2D(p -> new TestPoint2D(p.getX(), -p.getY()));
Map<TestPoint2D, TestNode> pointNodeMap = createPointNodeMap(tree, -5, 5);
@@ -1649,7 +1645,7 @@ public class AbstractBSPTreeTest {
new TestLineSegment(new TestPoint2D(0, 3), new TestPoint2D(3, 0))
));
- Transform<TestPoint2D> t = new TestTransform2D((p) -> new TestPoint2D(-p.getX(), -p.getY()));
+ Transform<TestPoint2D> t = new TestTransform2D(p -> new TestPoint2D(-p.getX(), -p.getY()));
Map<TestPoint2D, TestNode> pointNodeMap = createPointNodeMap(tree, -5, 5);
@@ -1897,15 +1893,13 @@ public class AbstractBSPTreeTest {
Assert.assertEquals(orig.getCut(), copy.getCut());
- if (!orig.isLeaf())
- {
+ if (!orig.isLeaf()) {
Assert.assertNotSame(orig.getMinus(), copy.getMinus());
Assert.assertNotSame(orig.getPlus(), copy.getPlus());
assertNodesCopiedRecursive(orig.getMinus(), copy.getMinus());
assertNodesCopiedRecursive(orig.getPlus(), copy.getPlus());
- }
- else {
+ } else {
Assert.assertNull(copy.getMinus());
Assert.assertNull(copy.getPlus());
}
@@ -1965,12 +1959,12 @@ public class AbstractBSPTreeTest {
private final List<TestNode> visited = new ArrayList<>();
- public TestVisitor(Order order) {
+ TestVisitor(Order order) {
this.order = order;
}
- public TestVisitor withTerminationNode(TestNode terminationNode) {
- this.terminationNode = terminationNode;
+ public TestVisitor withTerminationNode(TestNode newTerminationNode) {
+ this.terminationNode = newTerminationNode;
return this;
}
diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractRegionBSPTreeTest.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractRegionBSPTreeTest.java
index 53ad322..d78b268 100644
--- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractRegionBSPTreeTest.java
+++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractRegionBSPTreeTest.java
@@ -19,7 +19,6 @@ package org.apache.commons.geometry.core.partitioning.bsp;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import java.util.function.Consumer;
import java.util.function.Supplier;
import org.apache.commons.geometry.core.RegionLocation;
@@ -29,13 +28,13 @@ import org.apache.commons.geometry.core.partition.test.TestLine;
import org.apache.commons.geometry.core.partition.test.TestLineSegment;
import org.apache.commons.geometry.core.partition.test.TestLineSegmentCollection;
import org.apache.commons.geometry.core.partition.test.TestPoint2D;
+import org.apache.commons.geometry.core.partition.test.TestRegionBSPTree;
+import org.apache.commons.geometry.core.partition.test.TestRegionBSPTree.TestRegionNode;
import org.apache.commons.geometry.core.partition.test.TestTransform2D;
import org.apache.commons.geometry.core.partitioning.ConvexSubHyperplane;
-import org.apache.commons.geometry.core.partitioning.Hyperplane;
import org.apache.commons.geometry.core.partitioning.Split;
import org.apache.commons.geometry.core.partitioning.SplitLocation;
import org.apache.commons.geometry.core.partitioning.SubHyperplane;
-import org.apache.commons.geometry.core.partitioning.bsp.AbstractRegionBSPTree.AbstractRegionNode;
import org.apache.commons.geometry.core.partitioning.bsp.AbstractRegionBSPTree.RegionSizeProperties;
import org.junit.Assert;
import org.junit.Before;
@@ -180,8 +179,6 @@ public class AbstractRegionBSPTreeTest {
new TestLineSegment(TestPoint2D.ZERO, new TestPoint2D(0, 1)),
new TestLineSegment(TestPoint2D.ZERO, new TestPoint2D(0, -1))));
- TestRegionNode root = tree.getRoot();
-
// act
root.clearCut();
@@ -602,7 +599,7 @@ public class AbstractRegionBSPTreeTest {
Assert.assertTrue(tree.isFull());
Assert.assertFalse(tree.isEmpty());
- assertPointLocations(tree, RegionLocation.INSIDE, TestPoint2D.ZERO);
+ PartitionTestUtils.assertPointLocations(tree, RegionLocation.INSIDE, TestPoint2D.ZERO);
}
@Test
@@ -619,12 +616,12 @@ public class AbstractRegionBSPTreeTest {
Assert.assertFalse(tree.isFull());
Assert.assertFalse(tree.isEmpty());
- assertPointLocations(tree, RegionLocation.OUTSIDE,
+ PartitionTestUtils.assertPointLocations(tree, RegionLocation.OUTSIDE,
new TestPoint2D(0, -1), TestPoint2D.ZERO, new TestPoint2D(0, 1));
- assertPointLocations(tree, RegionLocation.BOUNDARY, new TestPoint2D(0, 2));
+ PartitionTestUtils.assertPointLocations(tree, RegionLocation.BOUNDARY, new TestPoint2D(0, 2));
- assertPointLocations(tree, RegionLocation.INSIDE,
+ PartitionTestUtils.assertPointLocations(tree, RegionLocation.INSIDE,
new TestPoint2D(0, 3), new TestPoint2D(0, 4));
}
@@ -642,13 +639,13 @@ public class AbstractRegionBSPTreeTest {
Assert.assertFalse(tree.isFull());
Assert.assertFalse(tree.isEmpty());
- assertPointLocations(tree, RegionLocation.INSIDE,
+ PartitionTestUtils.assertPointLocations(tree, RegionLocation.INSIDE,
new TestPoint2D(0, 5), new TestPoint2D(-1, 4), new TestPoint2D(1, 6));
- assertPointLocations(tree, RegionLocation.BOUNDARY,
+ PartitionTestUtils.assertPointLocations(tree, RegionLocation.BOUNDARY,
new TestPoint2D(-2, 4), new TestPoint2D(2, 6));
- assertPointLocations(tree, RegionLocation.OUTSIDE,
+ PartitionTestUtils.assertPointLocations(tree, RegionLocation.OUTSIDE,
new TestPoint2D(-3, 5), new TestPoint2D(3, 5));
}
@@ -666,14 +663,14 @@ public class AbstractRegionBSPTreeTest {
Assert.assertFalse(tree.isFull());
Assert.assertFalse(tree.isEmpty());
- assertPointLocations(tree, RegionLocation.INSIDE,
+ PartitionTestUtils.assertPointLocations(tree, RegionLocation.INSIDE,
TestPoint2D.ZERO, new TestPoint2D(-1, 1), new TestPoint2D(1, -1));
- assertPointLocations(tree, RegionLocation.BOUNDARY,
+ PartitionTestUtils.assertPointLocations(tree, RegionLocation.BOUNDARY,
new TestPoint2D(0, 1), new TestPoint2D(0, -1),
new TestPoint2D(-4, 0), new TestPoint2D(4, 0));
- assertPointLocations(tree, RegionLocation.OUTSIDE,
+ PartitionTestUtils.assertPointLocations(tree, RegionLocation.OUTSIDE,
new TestPoint2D(1, 1), new TestPoint2D(-1, -1));
}
@@ -691,14 +688,14 @@ public class AbstractRegionBSPTreeTest {
Assert.assertFalse(tree.isFull());
Assert.assertFalse(tree.isEmpty());
- assertPointLocations(tree, RegionLocation.INSIDE,
+ PartitionTestUtils.assertPointLocations(tree, RegionLocation.INSIDE,
TestPoint2D.ZERO, new TestPoint2D(1, -1), new TestPoint2D(-1, 1));
- assertPointLocations(tree, RegionLocation.BOUNDARY,
+ PartitionTestUtils.assertPointLocations(tree, RegionLocation.BOUNDARY,
new TestPoint2D(0, 1), new TestPoint2D(0, -1),
new TestPoint2D(-4, 0), new TestPoint2D(4, 0));
- assertPointLocations(tree, RegionLocation.OUTSIDE,
+ PartitionTestUtils.assertPointLocations(tree, RegionLocation.OUTSIDE,
new TestPoint2D(-1, -1), new TestPoint2D(1, 1));
}
@@ -716,14 +713,14 @@ public class AbstractRegionBSPTreeTest {
Assert.assertFalse(tree.isFull());
Assert.assertFalse(tree.isEmpty());
- assertPointLocations(tree, RegionLocation.INSIDE,
+ PartitionTestUtils.assertPointLocations(tree, RegionLocation.INSIDE,
TestPoint2D.ZERO, new TestPoint2D(1, 1), new TestPoint2D(-1, -1));
- assertPointLocations(tree, RegionLocation.BOUNDARY,
+ PartitionTestUtils.assertPointLocations(tree, RegionLocation.BOUNDARY,
new TestPoint2D(0, 1), new TestPoint2D(0, -1),
new TestPoint2D(-4, 0), new TestPoint2D(4, 0));
- assertPointLocations(tree, RegionLocation.OUTSIDE,
+ PartitionTestUtils.assertPointLocations(tree, RegionLocation.OUTSIDE,
new TestPoint2D(-1, 1), new TestPoint2D(1, -1));
}
@@ -1060,16 +1057,16 @@ public class AbstractRegionBSPTreeTest {
result.extract(tree.findNode(pt));
// assert
- assertPointLocations(result, RegionLocation.INSIDE,
+ PartitionTestUtils.assertPointLocations(result, RegionLocation.INSIDE,
new TestPoint2D(0, 0.5), new TestPoint2D(2, 2));
- assertPointLocations(result, RegionLocation.OUTSIDE,
+ PartitionTestUtils.assertPointLocations(result, RegionLocation.OUTSIDE,
new TestPoint2D(-2, 2),
new TestPoint2D(-2, -2), new TestPoint2D(0, -0.5), new TestPoint2D(-2, 2));
- assertPointLocations(tree, RegionLocation.INSIDE,
+ PartitionTestUtils.assertPointLocations(tree, RegionLocation.INSIDE,
new TestPoint2D(0, 0.5), new TestPoint2D(2, 2),
new TestPoint2D(-2, -2), new TestPoint2D(0, -0.5));
- assertPointLocations(tree, RegionLocation.OUTSIDE,
+ PartitionTestUtils.assertPointLocations(tree, RegionLocation.OUTSIDE,
new TestPoint2D(2, -2), new TestPoint2D(-2, 2));
}
@@ -1087,16 +1084,16 @@ public class AbstractRegionBSPTreeTest {
result.extract(tree.findNode(pt));
// assert
- assertPointLocations(result, RegionLocation.OUTSIDE,
+ PartitionTestUtils.assertPointLocations(result, RegionLocation.OUTSIDE,
new TestPoint2D(0, 0.5), new TestPoint2D(2, 2));
- assertPointLocations(result, RegionLocation.INSIDE,
+ PartitionTestUtils.assertPointLocations(result, RegionLocation.INSIDE,
new TestPoint2D(-2, 2),
new TestPoint2D(-2, -2), new TestPoint2D(0, -0.5), new TestPoint2D(-2, 2));
- assertPointLocations(tree, RegionLocation.OUTSIDE,
+ PartitionTestUtils.assertPointLocations(tree, RegionLocation.OUTSIDE,
new TestPoint2D(0, 0.5), new TestPoint2D(2, 2),
new TestPoint2D(-2, -2), new TestPoint2D(0, -0.5));
- assertPointLocations(tree, RegionLocation.INSIDE,
+ PartitionTestUtils.assertPointLocations(tree, RegionLocation.INSIDE,
new TestPoint2D(2, -2), new TestPoint2D(-2, 2));
}
@@ -1163,8 +1160,8 @@ public class AbstractRegionBSPTreeTest {
.outside(new TestPoint2D(1, -1))
.boundary(TestPoint2D.ZERO)
.count(5)
- .check(tree -> {
- TestLineSegment seg = (TestLineSegment) tree.getRoot().getPlus().getCut();
+ .check(t -> {
+ TestLineSegment seg = (TestLineSegment) t.getRoot().getPlus().getCut();
PartitionTestUtils.assertPointsEqual(new TestPoint2D(0.0, Double.NEGATIVE_INFINITY), seg.getStartPoint());
PartitionTestUtils.assertPointsEqual(TestPoint2D.ZERO, seg.getEndPoint());
@@ -1200,16 +1197,16 @@ public class AbstractRegionBSPTreeTest {
public void testUnion_treeWithComplement() {
// arrange
Supplier<TestRegionBSPTree> treeFactory = () -> {
- TestRegionBSPTree tree = fullTree();
- insertSkewedBowtie(tree);
+ TestRegionBSPTree t = fullTree();
+ insertSkewedBowtie(t);
- return tree;
+ return t;
};
Supplier<TestRegionBSPTree> complementFactory = () -> {
- TestRegionBSPTree tree = treeFactory.get();
- tree.complement();
+ TestRegionBSPTree t = treeFactory.get();
+ t.complement();
- return tree;
+ return t;
};
// act/assert
@@ -1288,8 +1285,8 @@ public class AbstractRegionBSPTreeTest {
.outside(new TestPoint2D(1, 1), new TestPoint2D(1, -1), new TestPoint2D(-1, -1))
.boundary(TestPoint2D.ZERO)
.count(5)
- .check(tree -> {
- TestLineSegment seg = (TestLineSegment) tree.getRoot().getMinus().getCut();
+ .check(t -> {
+ TestLineSegment seg = (TestLineSegment) t.getRoot().getMinus().getCut();
PartitionTestUtils.assertPointsEqual(TestPoint2D.ZERO, seg.getStartPoint());
PartitionTestUtils.assertPointsEqual(new TestPoint2D(0.0, Double.POSITIVE_INFINITY), seg.getEndPoint());
@@ -1327,16 +1324,16 @@ public class AbstractRegionBSPTreeTest {
public void testIntersection_treeWithComplement() {
// arrange
Supplier<TestRegionBSPTree> treeFactory = () -> {
- TestRegionBSPTree tree = fullTree();
- insertSkewedBowtie(tree);
+ TestRegionBSPTree t = fullTree();
+ insertSkewedBowtie(t);
- return tree;
+ return t;
};
Supplier<TestRegionBSPTree> complementFactory = () -> {
- TestRegionBSPTree tree = treeFactory.get();
- tree.complement();
+ TestRegionBSPTree t = treeFactory.get();
+ t.complement();
- return tree;
+ return t;
};
// act/assert
@@ -1415,8 +1412,8 @@ public class AbstractRegionBSPTreeTest {
.outside(new TestPoint2D(-1, 1), new TestPoint2D(1, -1), new TestPoint2D(-1, -1))
.boundary(TestPoint2D.ZERO)
.count(5)
- .check(tree -> {
- TestLineSegment seg = (TestLineSegment) tree.getRoot().getMinus().getCut();
+ .check(t -> {
+ TestLineSegment seg = (TestLineSegment) t.getRoot().getMinus().getCut();
PartitionTestUtils.assertPointsEqual(TestPoint2D.ZERO, seg.getStartPoint());
PartitionTestUtils.assertPointsEqual(new TestPoint2D(0.0, Double.POSITIVE_INFINITY), seg.getEndPoint());
@@ -1456,10 +1453,10 @@ public class AbstractRegionBSPTreeTest {
public void testDifference_treeWithCopy() {
// arrange
Supplier<TestRegionBSPTree> treeFactory = () -> {
- TestRegionBSPTree tree = fullTree();
- insertSkewedBowtie(tree);
+ TestRegionBSPTree t = fullTree();
+ insertSkewedBowtie(t);
- return tree;
+ return t;
};
// act/assert
@@ -1544,13 +1541,13 @@ public class AbstractRegionBSPTreeTest {
.outside(new TestPoint2D(-1, 1), new TestPoint2D(1, -1))
.boundary(TestPoint2D.ZERO)
.count(7)
- .check(tree -> {
- TestLineSegment minusSeg = (TestLineSegment) tree.getRoot().getMinus().getCut();
+ .check(t -> {
+ TestLineSegment minusSeg = (TestLineSegment) t.getRoot().getMinus().getCut();
PartitionTestUtils.assertPointsEqual(TestPoint2D.ZERO, minusSeg.getStartPoint());
PartitionTestUtils.assertPointsEqual(new TestPoint2D(0.0, Double.POSITIVE_INFINITY), minusSeg.getEndPoint());
- TestLineSegment plusSeg = (TestLineSegment) tree.getRoot().getPlus().getCut();
+ TestLineSegment plusSeg = (TestLineSegment) t.getRoot().getPlus().getCut();
PartitionTestUtils.assertPointsEqual(new TestPoint2D(0.0, Double.NEGATIVE_INFINITY), plusSeg.getStartPoint());
PartitionTestUtils.assertPointsEqual(TestPoint2D.ZERO, plusSeg.getEndPoint());
@@ -1591,16 +1588,16 @@ public class AbstractRegionBSPTreeTest {
public void testXor_treeWithComplement() {
// arrange
Supplier<TestRegionBSPTree> treeFactory = () -> {
- TestRegionBSPTree tree = fullTree();
- insertSkewedBowtie(tree);
+ TestRegionBSPTree t = fullTree();
+ insertSkewedBowtie(t);
- return tree;
+ return t;
};
Supplier<TestRegionBSPTree> complementFactory = () -> {
- TestRegionBSPTree tree = treeFactory.get();
- tree.complement();
+ TestRegionBSPTree t = treeFactory.get();
+ t.complement();
- return tree;
+ return t;
};
// act/assert
@@ -1625,7 +1622,6 @@ public class AbstractRegionBSPTreeTest {
@Test
public void testProject_halfSpace() {
// arrange
- TestRegionBSPTree tree = fullTree();
tree.getRoot().cut(TestLine.X_AXIS);
// act/assert
@@ -1641,7 +1637,6 @@ public class AbstractRegionBSPTreeTest {
@Test
public void testProject_box() {
// arrange
- TestRegionBSPTree tree = fullTree();
insertBox(tree, new TestPoint2D(0, 1), new TestPoint2D(1, 0));
// act/assert
@@ -1656,7 +1651,7 @@ public class AbstractRegionBSPTreeTest {
@Test
public void testSplit_empty() {
// arrange
- TestRegionBSPTree tree = emptyTree();
+ tree = emptyTree();
// act
Split<TestRegionBSPTree> split = tree.split(TestLine.X_AXIS);
@@ -1671,7 +1666,7 @@ public class AbstractRegionBSPTreeTest {
@Test
public void testSplit_full() {
// arrange
- TestRegionBSPTree tree = fullTree();
+ tree = fullTree();
// act
Split<TestRegionBSPTree> split = tree.split(TestLine.X_AXIS);
@@ -1680,26 +1675,25 @@ public class AbstractRegionBSPTreeTest {
Assert.assertEquals(SplitLocation.BOTH, split.getLocation());
TestRegionBSPTree minus = split.getMinus();
- assertPointLocations(minus, RegionLocation.INSIDE,
+ PartitionTestUtils.assertPointLocations(minus, RegionLocation.INSIDE,
new TestPoint2D(-1, 1), new TestPoint2D(0, 1), new TestPoint2D(1, 1));
- assertPointLocations(minus, RegionLocation.BOUNDARY,
+ PartitionTestUtils.assertPointLocations(minus, RegionLocation.BOUNDARY,
new TestPoint2D(-1, 0), new TestPoint2D(0, 0), new TestPoint2D(1, 0));
- assertPointLocations(minus, RegionLocation.OUTSIDE,
+ PartitionTestUtils.assertPointLocations(minus, RegionLocation.OUTSIDE,
new TestPoint2D(-1, -1), new TestPoint2D(0, -1), new TestPoint2D(1, -1));
TestRegionBSPTree plus = split.getPlus();
- assertPointLocations(plus, RegionLocation.OUTSIDE,
+ PartitionTestUtils.assertPointLocations(plus, RegionLocation.OUTSIDE,
new TestPoint2D(-1, 1), new TestPoint2D(0, 1), new TestPoint2D(1, 1));
- assertPointLocations(plus, RegionLocation.BOUNDARY,
+ PartitionTestUtils.assertPointLocations(plus, RegionLocation.BOUNDARY,
new TestPoint2D(-1, 0), new TestPoint2D(0, 0), new TestPoint2D(1, 0));
- assertPointLocations(plus, RegionLocation.INSIDE,
+ PartitionTestUtils.assertPointLocations(plus, RegionLocation.INSIDE,
new TestPoint2D(-1, -1), new TestPoint2D(0, -1), new TestPoint2D(1, -1));
}
@Test
public void testSplit_halfSpace() {
// arrange
- TestRegionBSPTree tree = fullTree();
tree.getRoot().insertCut(TestLine.X_AXIS);
TestLine splitter = TestLine.Y_AXIS;
@@ -1711,20 +1705,19 @@ public class AbstractRegionBSPTreeTest {
Assert.assertEquals(SplitLocation.BOTH, split.getLocation());
TestRegionBSPTree minus = split.getMinus();
- assertPointLocations(minus, RegionLocation.INSIDE, new TestPoint2D(-1, 1));
- assertPointLocations(minus, RegionLocation.OUTSIDE,
+ PartitionTestUtils.assertPointLocations(minus, RegionLocation.INSIDE, new TestPoint2D(-1, 1));
+ PartitionTestUtils.assertPointLocations(minus, RegionLocation.OUTSIDE,
new TestPoint2D(1, 1), new TestPoint2D(-1, -1), new TestPoint2D(1, -1));
TestRegionBSPTree plus = split.getPlus();
- assertPointLocations(plus, RegionLocation.INSIDE, new TestPoint2D(1, 1));
- assertPointLocations(plus, RegionLocation.OUTSIDE,
+ PartitionTestUtils.assertPointLocations(plus, RegionLocation.INSIDE, new TestPoint2D(1, 1));
+ PartitionTestUtils.assertPointLocations(plus, RegionLocation.OUTSIDE,
new TestPoint2D(-1, 1), new TestPoint2D(-1, -1), new TestPoint2D(1, -1));
}
@Test
public void testSplit_box() {
// arrange
- TestRegionBSPTree tree = fullTree();
insertBox(tree, new TestPoint2D(0, 1), new TestPoint2D(1, 0));
TestLine splitter = new TestLine(new TestPoint2D(1, 0), new TestPoint2D(0, 1));
@@ -1736,24 +1729,23 @@ public class AbstractRegionBSPTreeTest {
Assert.assertEquals(SplitLocation.BOTH, split.getLocation());
TestRegionBSPTree minus = split.getMinus();
- assertPointLocations(minus, RegionLocation.INSIDE, new TestPoint2D(0.25, 0.25));
- assertPointLocations(minus, RegionLocation.BOUNDARY,
+ PartitionTestUtils.assertPointLocations(minus, RegionLocation.INSIDE, new TestPoint2D(0.25, 0.25));
+ PartitionTestUtils.assertPointLocations(minus, RegionLocation.BOUNDARY,
new TestPoint2D(0.5, 0), new TestPoint2D(0, 0.5));
- assertPointLocations(minus, RegionLocation.OUTSIDE,
+ PartitionTestUtils.assertPointLocations(minus, RegionLocation.OUTSIDE,
new TestPoint2D(1, 0.5), new TestPoint2D(0.5, 1), new TestPoint2D(0.75, 0.75));
TestRegionBSPTree plus = split.getPlus();
- assertPointLocations(plus, RegionLocation.INSIDE, new TestPoint2D(0.75, 0.75));
- assertPointLocations(plus, RegionLocation.OUTSIDE,
+ PartitionTestUtils.assertPointLocations(plus, RegionLocation.INSIDE, new TestPoint2D(0.75, 0.75));
+ PartitionTestUtils.assertPointLocations(plus, RegionLocation.OUTSIDE,
new TestPoint2D(0.5, 0), new TestPoint2D(0, 0.5), new TestPoint2D(0.25, 0.25));
- assertPointLocations(plus, RegionLocation.BOUNDARY,
+ PartitionTestUtils.assertPointLocations(plus, RegionLocation.BOUNDARY,
new TestPoint2D(1, 0.5), new TestPoint2D(0.5, 1));
}
@Test
public void testSplit_box_onMinusOnly() {
// arrange
- TestRegionBSPTree tree = fullTree();
insertBox(tree, new TestPoint2D(0, 1), new TestPoint2D(1, 0));
TestLine splitter = new TestLine(new TestPoint2D(2, 0), new TestPoint2D(1, 1));
@@ -1765,8 +1757,8 @@ public class AbstractRegionBSPTreeTest {
Assert.assertEquals(SplitLocation.MINUS, split.getLocation());
TestRegionBSPTree minus = split.getMinus();
- assertPointLocations(minus, RegionLocation.INSIDE, new TestPoint2D(0.5, 0.5));
- assertPointLocations(minus, RegionLocation.BOUNDARY,
+ PartitionTestUtils.assertPointLocations(minus, RegionLocation.INSIDE, new TestPoint2D(0.5, 0.5));
+ PartitionTestUtils.assertPointLocations(minus, RegionLocation.BOUNDARY,
new TestPoint2D(0.5, 0), new TestPoint2D(0, 0.5),
new TestPoint2D(1, 0.5), new TestPoint2D(0.5, 1));
@@ -1776,7 +1768,6 @@ public class AbstractRegionBSPTreeTest {
@Test
public void testSplit_box_onPlusOnly() {
// arrange
- TestRegionBSPTree tree = fullTree();
insertBox(tree, new TestPoint2D(0, 1), new TestPoint2D(1, 0));
TestLine splitter = new TestLine(new TestPoint2D(0, 0), new TestPoint2D(-1, 1));
@@ -1790,8 +1781,8 @@ public class AbstractRegionBSPTreeTest {
Assert.assertNull(split.getMinus());
TestRegionBSPTree plus = split.getPlus();
- assertPointLocations(plus, RegionLocation.INSIDE, new TestPoint2D(0.5, 0.5));
- assertPointLocations(plus, RegionLocation.BOUNDARY,
+ PartitionTestUtils.assertPointLocations(plus, RegionLocation.INSIDE, new TestPoint2D(0.5, 0.5));
+ PartitionTestUtils.assertPointLocations(plus, RegionLocation.BOUNDARY,
new TestPoint2D(0.5, 0), new TestPoint2D(0, 0.5),
new TestPoint2D(1, 0.5), new TestPoint2D(0.5, 1));
}
@@ -1799,7 +1790,6 @@ public class AbstractRegionBSPTreeTest {
@Test
public void testToString() {
// arrange
- TestRegionBSPTree tree = fullTree();
tree.getRoot().cut(TestLine.X_AXIS);
// act
@@ -1810,40 +1800,17 @@ public class AbstractRegionBSPTreeTest {
Assert.assertTrue(tree.getRoot().toString().contains("TestRegionNode"));
}
- /** Assert that all given points lie in the expected location of the region.
- * @param tree region tree
- * @param points points to test
- * @param location expected location of all points
- */
- private static void assertPointLocations(final TestRegionBSPTree tree, final RegionLocation location,
- final TestPoint2D ... points) {
- assertPointLocations(tree, location, Arrays.asList(points));
- }
-
- /** Assert that all given points lie in the expected location of the region.
- * @param tree region tree
- * @param points points to test
- * @param location expected location of all points
- */
- private static void assertPointLocations(final TestRegionBSPTree tree, final RegionLocation location,
- final List<TestPoint2D> points) {
-
- for (TestPoint2D p : points) {
- Assert.assertEquals("Unexpected location for point " + p, location, tree.classify(p));
- }
- }
-
private static MergeChecker unionChecker(
final Supplier<TestRegionBSPTree> r1,
final Supplier<TestRegionBSPTree> r2) {
- MergeOperation constOperation = (a, b) -> {
+ MergeChecker.Operation constOperation = (a, b) -> {
TestRegionBSPTree result = fullTree();
result.union(a, b);
return result;
};
- MergeOperation inPlaceOperation = (a, b) -> {
+ MergeChecker.Operation inPlaceOperation = (a, b) -> {
a.union(b);
return a;
};
@@ -1855,13 +1822,13 @@ public class AbstractRegionBSPTreeTest {
final Supplier<TestRegionBSPTree> tree1Factory,
final Supplier<TestRegionBSPTree> tree2Factory) {
- MergeOperation constOperation = (a, b) -> {
+ MergeChecker.Operation constOperation = (a, b) -> {
TestRegionBSPTree result = fullTree();
result.intersection(a, b);
return result;
};
- MergeOperation inPlaceOperation = (a, b) -> {
+ MergeChecker.Operation inPlaceOperation = (a, b) -> {
a.intersection(b);
return a;
};
@@ -1873,13 +1840,13 @@ public class AbstractRegionBSPTreeTest {
final Supplier<TestRegionBSPTree> tree1Factory,
final Supplier<TestRegionBSPTree> tree2Factory) {
- MergeOperation constOperation = (a, b) -> {
+ MergeChecker.Operation constOperation = (a, b) -> {
TestRegionBSPTree result = fullTree();
result.difference(a, b);
return result;
};
- MergeOperation inPlaceOperation = (a, b) -> {
+ MergeChecker.Operation inPlaceOperation = (a, b) -> {
a.difference(b);
return a;
};
@@ -1891,13 +1858,13 @@ public class AbstractRegionBSPTreeTest {
final Supplier<TestRegionBSPTree> tree1Factory,
final Supplier<TestRegionBSPTree> tree2Factory) {
- MergeOperation constOperation = (a, b) -> {
+ MergeChecker.Operation constOperation = (a, b) -> {
TestRegionBSPTree result = fullTree();
result.xor(a, b);
return result;
};
- MergeOperation inPlaceOperation = (a, b) -> {
+ MergeChecker.Operation inPlaceOperation = (a, b) -> {
a.xor(b);
return a;
};
@@ -1905,7 +1872,8 @@ public class AbstractRegionBSPTreeTest {
return new MergeChecker(tree1Factory, tree2Factory, constOperation, inPlaceOperation);
}
- private static void insertBox(final TestRegionBSPTree tree, final TestPoint2D upperLeft, final TestPoint2D lowerRight) {
+ private static void insertBox(final TestRegionBSPTree tree, final TestPoint2D upperLeft,
+ final TestPoint2D lowerRight) {
final TestPoint2D upperRight = new TestPoint2D(lowerRight.getX(), upperLeft.getY());
final TestPoint2D lowerLeft = new TestPoint2D(upperLeft.getX(), lowerRight.getY());
@@ -1928,7 +1896,8 @@ public class AbstractRegionBSPTreeTest {
new TestLineSegment(new TestPoint2D(-4, -5), new TestPoint2D(1, 0))));
}
- private static void assertCutBoundarySegment(final SubHyperplane<TestPoint2D> boundary, final TestPoint2D start, final TestPoint2D end) {
+ private static void assertCutBoundarySegment(final SubHyperplane<TestPoint2D> boundary, final TestPoint2D start,
+ final TestPoint2D end) {
Assert.assertFalse("Expected boundary to not be empty", boundary.isEmpty());
TestLineSegmentCollection segmentCollection = (TestLineSegmentCollection) boundary;
@@ -1939,7 +1908,8 @@ public class AbstractRegionBSPTreeTest {
PartitionTestUtils.assertPointsEqual(end, segment.getEndPoint());
}
- private static void assertContainsSegment(final List<TestLineSegment> boundaries, final TestPoint2D start, final TestPoint2D end) {
+ private static void assertContainsSegment(final List<TestLineSegment> boundaries, final TestPoint2D start,
+ final TestPoint2D end) {
boolean found = false;
for (TestLineSegment seg : boundaries) {
TestPoint2D startPt = seg.getStartPoint();
@@ -1954,7 +1924,7 @@ public class AbstractRegionBSPTreeTest {
}
}
- Assert.assertTrue("Expected to find segment start= " + start + ", end= " + end , found);
+ Assert.assertTrue("Expected to find segment start= " + start + ", end= " + end, found);
}
private static TestRegionBSPTree emptyTree() {
@@ -1978,276 +1948,4 @@ public class AbstractRegionBSPTreeTest {
return tree;
}
-
- /** Helper interface used when testing tree merge operations.
- */
- @FunctionalInterface
- private static interface MergeOperation {
- TestRegionBSPTree apply(TestRegionBSPTree tree1, TestRegionBSPTree tree2);
- }
-
- /** Helper class with a fluent API used to construct assert conditions on tree merge operations.
- */
- private static class MergeChecker {
-
- /** First tree in the merge operation */
- private final Supplier<TestRegionBSPTree> tree1Factory;
-
- /** Second tree in the merge operation */
- private final Supplier<TestRegionBSPTree> tree2Factory;
-
- /** Merge operation that does not modify either input tree */
- private final MergeOperation constOperation;
-
- /** Merge operation that stores the result in the first input tree
- * and leaves the second one unmodified.
- */
- private final MergeOperation inPlaceOperation;
-
- /** If true, the resulting tree will be printed to stdout to help with
- * debugging.
- */
- private boolean print;
-
- /** The expected node count of the merged tree */
- private int expectedCount = -1;
-
- /** The expected full state of the merged tree */
- private boolean expectedFull = false;
-
- /** The expected empty state of the merged tree */
- private boolean expectedEmpty = false;
-
- /** Points expected to lie in the inside of the region */
- private List<TestPoint2D> insidePoints = new ArrayList<>();
-
- /** Points expected to lie on the outside of the region */
- private List<TestPoint2D> outsidePoints = new ArrayList<>();
-
- /** Points expected to lie on the boundary of the region */
- private List<TestPoint2D> boundaryPoints = new ArrayList<>();
-
- /** Construct a new instance that will verify the output of performing the given merge operation
- * on the input trees.
- * @param tree1 first tree in the merge operation
- * @param tree2 second tree in the merge operation
- * @param constOperation object that performs the merge operation in a form that
- * leaves both argument unmodified
- * @param inPlaceOperation object that performs the merge operation in a form
- * that stores the result in the first input tree and leaves the second
- * input unchanged.
- */
- public MergeChecker(
- final Supplier<TestRegionBSPTree> tree1Factory,
- final Supplier<TestRegionBSPTree> tree2Factory,
- final MergeOperation constOperation,
- final MergeOperation inPlaceOperation) {
-
- this.tree1Factory = tree1Factory;
- this.tree2Factory = tree2Factory;
- this.constOperation = constOperation;
- this.inPlaceOperation = inPlaceOperation;
- }
-
- /** Set the expected node count of the merged tree
- * @param expectedCount the expected node count of the merged tree
- * @return this instance
- */
- public MergeChecker count(final int expectedCount) {
- this.expectedCount = expectedCount;
- return this;
- }
-
- /** Set the expected full state of the merged tree.
- * @param expectedFull the expected full state of the merged tree.
- * @return this instance
- */
- public MergeChecker full(final boolean expectedFull) {
- this.expectedFull = expectedFull;
- return this;
- }
-
- /** Set the expected empty state of the merged tree.
- * @param expectedEmpty the expected empty state of the merged tree.
- * @return this instance
- */
- public MergeChecker empty(final boolean expectedEmpty) {
- this.expectedEmpty = expectedEmpty;
- return this;
- }
-
- /** Add points expected to be on the inside of the merged region.
- * @param points point expected to be on the inside of the merged
- * region
- * @return this instance
- */
- public MergeChecker inside(TestPoint2D ... points) {
- insidePoints.addAll(Arrays.asList(points));
- return this;
- }
-
- /** Add points expected to be on the outside of the merged region.
- * @param points point expected to be on the outside of the merged
- * region
- * @return this instance
- */
- public MergeChecker outside(TestPoint2D ... points) {
- outsidePoints.addAll(Arrays.asList(points));
- return this;
- }
-
- /** Add points expected to be on the boundary of the merged region.
- * @param points point expected to be on the boundary of the merged
- * region
- * @return this instance
- */
- public MergeChecker boundary(TestPoint2D ... points) {
- boundaryPoints.addAll(Arrays.asList(points));
- return this;
- }
-
- /** Set the flag for printing the merged tree to stdout before performing assertions.
- * This can be useful for debugging tests.
- * @param print if set to true, the merged tree will be printed to stdout
- * @return this instance
- */
- @SuppressWarnings("unused")
- public MergeChecker print(final boolean print) {
- this.print = print;
- return this;
- }
-
- /** Perform the merge operation and verify the output.
- */
- public void check() {
- check(null);
- }
-
- /** Perform the merge operation and verify the output. The given consumer
- * is passed the merge result and can be used to perform extra assertions.
- * @param assertions consumer that will be passed the merge result; may
- * be null
- */
- public void check(final Consumer<TestRegionBSPTree> assertions) {
- checkConst(assertions);
- checkInPlace(assertions);
- }
-
- private void checkConst(final Consumer<TestRegionBSPTree> assertions) {
- checkInternal(false, constOperation, assertions);
- }
-
- private void checkInPlace(final Consumer<TestRegionBSPTree> assertions) {
- checkInternal(true, inPlaceOperation, assertions);
- }
-
- private void checkInternal(final boolean inPlace, final MergeOperation operation,
- final Consumer<TestRegionBSPTree> assertions) {
-
- final TestRegionBSPTree tree1 = tree1Factory.get();
- final TestRegionBSPTree tree2 = tree2Factory.get();
-
- // store the number of nodes in each tree before the operation
- final int tree1BeforeCount = tree1.count();
- final int tree2BeforeCount = tree2.count();
-
- // perform the operation
- final TestRegionBSPTree result = operation.apply(tree1, tree2);
-
- if (print) {
- System.out.println((inPlace ? "In Place" : "Const") + " Result:");
- System.out.println(result.treeString());
- }
-
- // verify the internal consistency of all of the involved trees
- PartitionTestUtils.assertTreeStructure(tree1);
- PartitionTestUtils.assertTreeStructure(tree2);
- PartitionTestUtils.assertTreeStructure(result);
-
- // check full/empty status
- Assert.assertEquals("Unexpected tree 'full' property", expectedFull, result.isFull());
- Assert.assertEquals("Unexpected tree 'empty' property", expectedEmpty, result.isEmpty());
-
- // check the node count
- if (expectedCount > -1) {
- Assert.assertEquals("Unexpected node count", expectedCount, result.count());
- }
-
- // check in place or not
- if (inPlace) {
- Assert.assertSame("Expected merge operation to be in place", tree1, result);
- }
- else {
- Assert.assertNotSame("Expected merge operation to return a new instance", tree1, result);
-
- // make sure that tree1 wasn't modified
- Assert.assertEquals("Tree 1 node count should not have changed", tree1BeforeCount, tree1.count());
- }
-
- // make sure that tree2 wasn't modified
- Assert.assertEquals("Tree 2 node count should not have changed", tree2BeforeCount, tree2.count());
-
- // check region point locations
- assertPointLocations(result, RegionLocation.INSIDE, insidePoints);
- assertPointLocations(result, RegionLocation.OUTSIDE, outsidePoints);
- assertPointLocations(result, RegionLocation.BOUNDARY, boundaryPoints);
-
- // pass the result to the given function for any additional assertions
- if (assertions != null) {
- assertions.accept(result);
- }
- }
- }
-
- private static class TestRegionBSPTree extends AbstractRegionBSPTree<TestPoint2D, TestRegionNode> {
-
- TestRegionBSPTree() {
- this(true);
- }
-
- TestRegionBSPTree(final boolean full) {
- super(full);
- }
-
- /**
- * Expose the direct node cut method for easier creation of test tree structures.
- */
- @Override
- public void cutNode(final TestRegionNode node, final ConvexSubHyperplane<TestPoint2D> cut) {
- super.cutNode(node, cut);
- }
-
- @Override
- protected TestRegionNode createNode() {
- return new TestRegionNode(this);
- }
-
- @Override
- protected RegionSizeProperties<TestPoint2D> computeRegionSizeProperties() {
- // return a set of stub values
- return new RegionSizeProperties<>(1, TestPoint2D.ZERO);
- }
-
- @Override
- public boolean contains(TestPoint2D pt) {
- return classify(pt) != RegionLocation.OUTSIDE;
- }
-
- @Override
- public Split<TestRegionBSPTree> split(Hyperplane<TestPoint2D> splitter) {
- return split(splitter, new TestRegionBSPTree(), new TestRegionBSPTree());
- }
- }
-
- private static class TestRegionNode extends AbstractRegionNode<TestPoint2D, TestRegionNode> {
-
- protected TestRegionNode(AbstractBSPTree<TestPoint2D, TestRegionNode> tree) {
- super(tree);
- }
-
- @Override
- protected TestRegionNode getSelf() {
- return this;
- }
- }
}
diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/AttributeBSPTreeTest.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/AttributeBSPTreeTest.java
index e69425a..6fe05dd 100644
--- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/AttributeBSPTreeTest.java
+++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/AttributeBSPTreeTest.java
@@ -22,7 +22,6 @@ import org.apache.commons.geometry.core.partition.test.PartitionTestUtils;
import org.apache.commons.geometry.core.partition.test.TestLine;
import org.apache.commons.geometry.core.partition.test.TestLineSegment;
import org.apache.commons.geometry.core.partition.test.TestPoint2D;
-import org.apache.commons.geometry.core.partitioning.bsp.AttributeBSPTree;
import org.apache.commons.geometry.core.partitioning.bsp.AttributeBSPTree.AttributeNode;
import org.junit.Assert;
import org.junit.Test;
diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/BSPTreeVisitorTest.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/BSPTreeVisitorTest.java
index cd58ca1..4beadd8 100644
--- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/BSPTreeVisitorTest.java
+++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/BSPTreeVisitorTest.java
@@ -114,7 +114,7 @@ public class BSPTreeVisitorTest {
private static class ClosestFirstStubVisitor extends ClosestFirstVisitor<TestPoint2D, TestNode> {
- public ClosestFirstStubVisitor(TestPoint2D target) {
+ ClosestFirstStubVisitor(TestPoint2D target) {
super(target);
}
@@ -126,7 +126,7 @@ public class BSPTreeVisitorTest {
private static class FarthestFirstStubVisitor extends FarthestFirstVisitor<TestPoint2D, TestNode> {
- public FarthestFirstStubVisitor(TestPoint2D target) {
+ FarthestFirstStubVisitor(TestPoint2D target) {
super(target);
}
diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/MergeChecker.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/MergeChecker.java
new file mode 100644
index 0000000..55c3611
--- /dev/null
+++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/MergeChecker.java
@@ -0,0 +1,227 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.geometry.core.partitioning.bsp;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.function.Consumer;
+import java.util.function.Supplier;
+
+import org.apache.commons.geometry.core.RegionLocation;
+import org.apache.commons.geometry.core.partition.test.PartitionTestUtils;
+import org.apache.commons.geometry.core.partition.test.TestPoint2D;
+import org.apache.commons.geometry.core.partition.test.TestRegionBSPTree;
+import org.junit.Assert;
+
+/** Helper class with a fluent API used to construct assert conditions on tree merge operations.
+ */
+class MergeChecker {
+
+ /** Helper interface used when testing tree merge operations.
+ */
+ @FunctionalInterface
+ public interface Operation {
+ TestRegionBSPTree apply(TestRegionBSPTree tree1, TestRegionBSPTree tree2);
+ }
+
+ /** First tree in the merge operation */
+ private final Supplier<TestRegionBSPTree> tree1Factory;
+
+ /** Second tree in the merge operation */
+ private final Supplier<TestRegionBSPTree> tree2Factory;
+
+ /** Merge operation that does not modify either input tree */
+ private final Operation constOperation;
+
+ /** Merge operation that stores the result in the first input tree
+ * and leaves the second one unmodified.
+ */
+ private final Operation inPlaceOperation;
+
+ /** The expected node count of the merged tree */
+ private int expectedCount = -1;
+
+ /** The expected full state of the merged tree */
+ private boolean expectedFull = false;
+
+ /** The expected empty state of the merged tree */
+ private boolean expectedEmpty = false;
+
+ /** Points expected to lie in the inside of the region */
+ private List<TestPoint2D> insidePoints = new ArrayList<>();
+
+ /** Points expected to lie on the outside of the region */
+ private List<TestPoint2D> outsidePoints = new ArrayList<>();
+
+ /** Points expected to lie on the boundary of the region */
+ private List<TestPoint2D> boundaryPoints = new ArrayList<>();
+
+ /** Construct a new instance that will verify the output of performing the given merge operation
+ * on the input trees.
+ * @param tree1 first tree in the merge operation
+ * @param tree2 second tree in the merge operation
+ * @param constOperation object that performs the merge operation in a form that
+ * leaves both argument unmodified
+ * @param inPlaceOperation object that performs the merge operation in a form
+ * that stores the result in the first input tree and leaves the second
+ * input unchanged.
+ */
+ MergeChecker(
+ final Supplier<TestRegionBSPTree> tree1Factory,
+ final Supplier<TestRegionBSPTree> tree2Factory,
+ final Operation constOperation,
+ final Operation inPlaceOperation) {
+
+ this.tree1Factory = tree1Factory;
+ this.tree2Factory = tree2Factory;
+ this.constOperation = constOperation;
+ this.inPlaceOperation = inPlaceOperation;
+ }
+
+ /** Set the expected node count of the merged tree
+ * @param expectedCountVal the expected node count of the merged tree
+ * @return this instance
+ */
+ public MergeChecker count(final int expectedCountVal) {
+ this.expectedCount = expectedCountVal;
+ return this;
+ }
+
+ /** Set the expected full state of the merged tree.
+ * @param expectedFullVal the expected full state of the merged tree.
+ * @return this instance
+ */
+ public MergeChecker full(final boolean expectedFullVal) {
+ this.expectedFull = expectedFullVal;
+ return this;
+ }
+
+ /** Set the expected empty state of the merged tree.
+ * @param expectedEmptyVal the expected empty state of the merged tree.
+ * @return this instance
+ */
+ public MergeChecker empty(final boolean expectedEmptyVal) {
+ this.expectedEmpty = expectedEmptyVal;
+ return this;
+ }
+
+ /** Add points expected to be on the inside of the merged region.
+ * @param points point expected to be on the inside of the merged
+ * region
+ * @return this instance
+ */
+ public MergeChecker inside(TestPoint2D... points) {
+ insidePoints.addAll(Arrays.asList(points));
+ return this;
+ }
+
+ /** Add points expected to be on the outside of the merged region.
+ * @param points point expected to be on the outside of the merged
+ * region
+ * @return this instance
+ */
+ public MergeChecker outside(TestPoint2D... points) {
+ outsidePoints.addAll(Arrays.asList(points));
+ return this;
+ }
+
+ /** Add points expected to be on the boundary of the merged region.
+ * @param points point expected to be on the boundary of the merged
+ * region
+ * @return this instance
+ */
+ public MergeChecker boundary(TestPoint2D... points) {
+ boundaryPoints.addAll(Arrays.asList(points));
+ return this;
+ }
+
+ /** Perform the merge operation and verify the output.
+ */
+ public void check() {
+ check(null);
+ }
+
+ /** Perform the merge operation and verify the output. The given consumer
+ * is passed the merge result and can be used to perform extra assertions.
+ * @param assertions consumer that will be passed the merge result; may
+ * be null
+ */
+ public void check(final Consumer<TestRegionBSPTree> assertions) {
+ checkConst(assertions);
+ checkInPlace(assertions);
+ }
+
+ private void checkConst(final Consumer<TestRegionBSPTree> assertions) {
+ checkInternal(false, constOperation, assertions);
+ }
+
+ private void checkInPlace(final Consumer<TestRegionBSPTree> assertions) {
+ checkInternal(true, inPlaceOperation, assertions);
+ }
+
+ private void checkInternal(final boolean inPlace, final Operation operation,
+ final Consumer<TestRegionBSPTree> assertions) {
+
+ final TestRegionBSPTree tree1 = tree1Factory.get();
+ final TestRegionBSPTree tree2 = tree2Factory.get();
+
+ // store the number of nodes in each tree before the operation
+ final int tree1BeforeCount = tree1.count();
+ final int tree2BeforeCount = tree2.count();
+
+ // perform the operation
+ final TestRegionBSPTree result = operation.apply(tree1, tree2);
+
+ // verify the internal consistency of all of the involved trees
+ PartitionTestUtils.assertTreeStructure(tree1);
+ PartitionTestUtils.assertTreeStructure(tree2);
+ PartitionTestUtils.assertTreeStructure(result);
+
+ // check full/empty status
+ Assert.assertEquals("Unexpected tree 'full' property", expectedFull, result.isFull());
+ Assert.assertEquals("Unexpected tree 'empty' property", expectedEmpty, result.isEmpty());
+
+ // check the node count
+ if (expectedCount > -1) {
+ Assert.assertEquals("Unexpected node count", expectedCount, result.count());
+ }
+
+ // check in place or not
+ if (inPlace) {
+ Assert.assertSame("Expected merge operation to be in place", tree1, result);
+ } else {
+ Assert.assertNotSame("Expected merge operation to return a new instance", tree1, result);
+
+ // make sure that tree1 wasn't modified
+ Assert.assertEquals("Tree 1 node count should not have changed", tree1BeforeCount, tree1.count());
+ }
+
+ // make sure that tree2 wasn't modified
+ Assert.assertEquals("Tree 2 node count should not have changed", tree2BeforeCount, tree2.count());
+
+ // check region point locations
+ PartitionTestUtils.assertPointLocations(result, RegionLocation.INSIDE, insidePoints);
+ PartitionTestUtils.assertPointLocations(result, RegionLocation.OUTSIDE, outsidePoints);
+ PartitionTestUtils.assertPointLocations(result, RegionLocation.BOUNDARY, boundaryPoints);
+
+ // pass the result to the given function for any additional assertions
+ if (assertions != null) {
+ assertions.accept(result);
+ }
+ }
+}
diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/RegionCutBoundaryTest.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/RegionCutBoundaryTest.java
index 524ec3b..45fee2c 100644
--- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/RegionCutBoundaryTest.java
+++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/RegionCutBoundaryTest.java
@@ -19,7 +19,6 @@ package org.apache.commons.geometry.core.partitioning.bsp;
import org.apache.commons.geometry.core.partition.test.PartitionTestUtils;
import org.apache.commons.geometry.core.partition.test.TestLineSegment;
import org.apache.commons.geometry.core.partition.test.TestPoint2D;
-import org.apache.commons.geometry.core.partitioning.bsp.RegionCutBoundary;
import org.junit.Assert;
import org.junit.Test;
diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/precision/DoublePrecisionContextTest.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/precision/DoublePrecisionContextTest.java
index 5a6616d..3589e84 100644
--- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/precision/DoublePrecisionContextTest.java
+++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/precision/DoublePrecisionContextTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.commons.geometry.core.precision;
-import org.apache.commons.geometry.core.precision.DoublePrecisionContext;
import org.junit.Assert;
import org.junit.Test;
diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/precision/EpsilonDoublePrecisionContextTest.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/precision/EpsilonDoublePrecisionContextTest.java
index 224a2a8..595b67e 100644
--- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/precision/EpsilonDoublePrecisionContextTest.java
+++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/precision/EpsilonDoublePrecisionContextTest.java
@@ -17,7 +17,6 @@
package org.apache.commons.geometry.core.precision;
import org.apache.commons.geometry.core.GeometryTestUtils;
-import org.apache.commons.geometry.core.precision.EpsilonDoublePrecisionContext;
import org.junit.Assert;
import org.junit.Test;
@@ -231,7 +230,7 @@ public class EpsilonDoublePrecisionContextTest {
*/
private static double nextUp(double n, int count) {
double result = n;
- for (int i=0; i<count; ++i) {
+ for (int i = 0; i < count; ++i) {
result = Math.nextUp(result);
}
@@ -247,7 +246,7 @@ public class EpsilonDoublePrecisionContextTest {
*/
private static double nextDown(double n, int count) {
double result = n;
- for (int i=0; i<count; ++i) {
+ for (int i = 0; i < count; ++i) {
result = Math.nextDown(result);
}
diff --git a/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/enclosing/WelzlEncloser2DTest.java b/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/enclosing/WelzlEncloser2DTest.java
index a16f1fa..86ee470 100755
--- a/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/enclosing/WelzlEncloser2DTest.java
+++ b/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/enclosing/WelzlEncloser2DTest.java
@@ -88,7 +88,7 @@ public class WelzlEncloser2DTest {
@Test
public void testLargeSamples() {
- UniformRandomProvider random = RandomSource.create(RandomSource.WELL_1024_A, 0xa2a63cad12c01fb2l);
+ UniformRandomProvider random = RandomSource.create(RandomSource.WELL_1024_A, 0xa2a63cad12c01fb2L);
for (int k = 0; k < 100; ++k) {
int nbPoints = random.nextInt(10000);
List<Vector2D> points = new ArrayList<>();
@@ -112,11 +112,11 @@ public class WelzlEncloser2DTest {
);
double precision = 1;
DoublePrecisionContext precisionContext = new EpsilonDoublePrecisionContext(precision);
- WelzlEncloser< Vector2D> encloser = new WelzlEncloser<>(precisionContext, new DiskGenerator());
+ WelzlEncloser<Vector2D> encloser = new WelzlEncloser<>(precisionContext, new DiskGenerator());
encloser.enclose(points);
}
- private List<Vector2D> buildList(final double ... coordinates) {
+ private List<Vector2D> buildList(final double... coordinates) {
List<Vector2D> list = new ArrayList<>(coordinates.length / 2);
for (int i = 0; i < coordinates.length; i += 2) {
list.add(Vector2D.of(coordinates[i], coordinates[i + 1]));
diff --git a/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/enclosing/WelzlEncloser3DTest.java b/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/enclosing/WelzlEncloser3DTest.java
index d353b67..9f3b9d8 100644
--- a/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/enclosing/WelzlEncloser3DTest.java
+++ b/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/enclosing/WelzlEncloser3DTest.java
@@ -59,17 +59,17 @@ public class WelzlEncloser3DTest {
@Test
public void testReducingBall() {
List<Vector3D> list =
- Arrays.asList(Vector3D.of(-7.140397329568118, -16.571661242582177, 11.714458961735405),
- Vector3D.of(-7.137986707455888, -16.570767323375720, 11.708602108715928),
- Vector3D.of(-7.139185068549035, -16.570891204702250, 11.715554057357394),
- Vector3D.of(-7.142682716997507, -16.571609818234290, 11.710787934580328),
- Vector3D.of(-7.139018392423351, -16.574405614157020, 11.710518716711425),
- Vector3D.of(-7.140870659936730, -16.567993074240455, 11.710914678204503),
- Vector3D.of(-7.136350173659562, -16.570498228820930, 11.713965225900928),
- Vector3D.of(-7.141675762759172, -16.572852471407028, 11.714033471449508),
- Vector3D.of(-7.140453077221105, -16.570212820780647, 11.708624578004980),
- Vector3D.of(-7.140322188726825, -16.574152894557717, 11.710305611121410),
- Vector3D.of(-7.141116131477088, -16.574061164624560, 11.712938509321699));
+ Arrays.asList(Vector3D.of(-7.140397329568118, -16.571661242582177, 11.714458961735405),
+ Vector3D.of(-7.137986707455888, -16.570767323375720, 11.708602108715928),
+ Vector3D.of(-7.139185068549035, -16.570891204702250, 11.715554057357394),
+ Vector3D.of(-7.142682716997507, -16.571609818234290, 11.710787934580328),
+ Vector3D.of(-7.139018392423351, -16.574405614157020, 11.710518716711425),
+ Vector3D.of(-7.140870659936730, -16.567993074240455, 11.710914678204503),
+ Vector3D.of(-7.136350173659562, -16.570498228820930, 11.713965225900928),
+ Vector3D.of(-7.141675762759172, -16.572852471407028, 11.714033471449508),
+ Vector3D.of(-7.140453077221105, -16.570212820780647, 11.708624578004980),
+ Vector3D.of(-7.140322188726825, -16.574152894557717, 11.710305611121410),
+ Vector3D.of(-7.141116131477088, -16.574061164624560, 11.712938509321699));
WelzlEncloser<Vector3D> encloser =
new WelzlEncloser<>(TEST_PRECISION, new SphereGenerator());
EnclosingBall<Vector3D> ball = encloser.enclose(list);
@@ -80,24 +80,24 @@ public class WelzlEncloser3DTest {
public void testInfiniteLoop() {
// this test used to generate an infinite loop
List<Vector3D> list =
- Arrays.asList(Vector3D.of( -0.89227075512164380, -2.89317694645713900, 14.84572323743355500),
- Vector3D.of( -0.92099498940693580, -2.31086108263908940, 12.92071026467688300),
- Vector3D.of( -0.85227999411005200, -3.06314731441320730, 15.40163831651287000),
- Vector3D.of( -1.77399413020785970, -3.65630391378114260, 14.13190097751873400),
- Vector3D.of( 0.33157833272465354, -2.22813591757792160, 14.21225234159008200),
- Vector3D.of( -1.53065579165484400, -1.65692084770139570, 14.61483055714788500),
- Vector3D.of( -1.08457093941217140, -1.96100325935602980, 13.09265170575555000),
- Vector3D.of( 0.30029469589708850, -3.05470831395667370, 14.56352400426342600),
- Vector3D.of( -0.95007443938638460, -1.86810946486118360, 15.14491234340057000),
- Vector3D.of( -1.89661503804130830, -2.17004080885185860, 14.81235128513927000),
- Vector3D.of( -0.72193328761607530, -1.44513142833618270, 14.52355724218561800),
- Vector3D.of( -0.26895980939606550, -3.69512371522084140, 14.72272846327652000),
- Vector3D.of( -1.53501693431786170, -3.25055166611021900, 15.15509062584274800),
- Vector3D.of( -0.71727553535519410, -3.62284279460799100, 13.26256700929380700),
- Vector3D.of( -0.30220950676137365, -3.25410412500779070, 13.13682612771606000),
- Vector3D.of( -0.04543996608267075, -1.93081853923797750, 14.79497997883171400),
- Vector3D.of( -1.53348892951571640, -3.66688919703524900, 14.73095600812074200),
- Vector3D.of( -0.98034899533935820, -3.34004481162763960, 13.03245014017556800));
+ Arrays.asList(Vector3D.of(-0.89227075512164380, -2.89317694645713900, 14.84572323743355500),
+ Vector3D.of(-0.92099498940693580, -2.31086108263908940, 12.92071026467688300),
+ Vector3D.of(-0.85227999411005200, -3.06314731441320730, 15.40163831651287000),
+ Vector3D.of(-1.77399413020785970, -3.65630391378114260, 14.13190097751873400),
+ Vector3D.of(0.33157833272465354, -2.22813591757792160, 14.21225234159008200),
+ Vector3D.of(-1.53065579165484400, -1.65692084770139570, 14.61483055714788500),
+ Vector3D.of(-1.08457093941217140, -1.96100325935602980, 13.09265170575555000),
+ Vector3D.of(0.30029469589708850, -3.05470831395667370, 14.56352400426342600),
+ Vector3D.of(-0.95007443938638460, -1.86810946486118360, 15.14491234340057000),
+ Vector3D.of(-1.89661503804130830, -2.17004080885185860, 14.81235128513927000),
+ Vector3D.of(-0.72193328761607530, -1.44513142833618270, 14.52355724218561800),
+ Vector3D.of(-0.26895980939606550, -3.69512371522084140, 14.72272846327652000),
+ Vector3D.of(-1.53501693431786170, -3.25055166611021900, 15.15509062584274800),
+ Vector3D.of(-0.71727553535519410, -3.62284279460799100, 13.26256700929380700),
+ Vector3D.of(-0.30220950676137365, -3.25410412500779070, 13.13682612771606000),
+ Vector3D.of(-0.04543996608267075, -1.93081853923797750, 14.79497997883171400),
+ Vector3D.of(-1.53348892951571640, -3.66688919703524900, 14.73095600812074200),
+ Vector3D.of(-0.98034899533935820, -3.34004481162763960, 13.03245014017556800));
WelzlEncloser<Vector3D> encloser =
new WelzlEncloser<>(TEST_PRECISION, new SphereGenerator());
@@ -108,7 +108,7 @@ public class WelzlEncloser3DTest {
@Test
public void testLargeSamples() {
final UniformRandomProvider random = RandomSource.create(RandomSource.WELL_1024_A,
- 0x35ddecfc78131e1dl);
+ 0x35ddecfc78131e1dL);
final UnitSphereSampler sr = new UnitSphereSampler(3, random);
for (int k = 0; k < 50; ++k) {
@@ -163,27 +163,27 @@ public class WelzlEncloser3DTest {
WelzlEncloser<Vector3D> encloser =
new WelzlEncloser<>(TEST_PRECISION, new SphereGenerator());
- EnclosingBall<Vector3D> Sphere = encloser.enclose(points);
+ EnclosingBall<Vector3D> sphere = encloser.enclose(points);
// all points are enclosed
for (Vector3D v : points) {
- Assert.assertTrue(Sphere.contains(v, 1.0e-10));
+ Assert.assertTrue(sphere.contains(v, 1.0e-10));
}
for (Vector3D v : points) {
boolean inSupport = false;
- for (Vector3D s : Sphere.getSupport()) {
+ for (Vector3D s : sphere.getSupport()) {
if (v == s) {
inSupport = true;
}
}
if (inSupport) {
// points on the support should be outside of reduced ball
- Assert.assertFalse(Sphere.contains(v, -0.001));
+ Assert.assertFalse(sphere.contains(v, -0.001));
}
}
- return Sphere;
+ return sphere;
}
diff --git a/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/euclidean/threed/enclosing/SphereGeneratorTest.java b/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/euclidean/threed/enclosing/SphereGeneratorTest.java
index e6ccaf6..cbfc932 100644
--- a/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/euclidean/threed/enclosing/SphereGeneratorTest.java
+++ b/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/euclidean/threed/enclosing/SphereGeneratorTest.java
@@ -91,8 +91,8 @@ public class SphereGeneratorTest {
Assert.assertTrue(v == sphere.getSupport()[i++]);
}
Assert.assertTrue(sphere.contains(Vector3D.of(2, 0.9, 0)));
- Assert.assertFalse(sphere.contains(Vector3D.of(0.9, 0, 0)));
- Assert.assertFalse(sphere.contains(Vector3D.of(3.1, 0, 0)));
+ Assert.assertFalse(sphere.contains(Vector3D.of(0.9, 0, 0)));
+ Assert.assertFalse(sphere.contains(Vector3D.of(3.1, 0, 0)));
Assert.assertTrue(sphere.contains(Vector3D.of(2.0, -0.499, 0)));
Assert.assertFalse(sphere.contains(Vector3D.of(2.0, -0.501, 0)));
Assert.assertTrue(sphere.contains(Vector3D.of(2.0, 3.0 / 4.0, -1.249)));
@@ -103,9 +103,9 @@ public class SphereGeneratorTest {
@Test
public void testSupport4Points() {
- List<Vector3D> support = Arrays.asList(Vector3D.of(17, 14, 18),
- Vector3D.of(11, 14, 22),
- Vector3D.of( 2, 22, 17),
+ List<Vector3D> support = Arrays.asList(Vector3D.of(17, 14, 18),
+ Vector3D.of(11, 14, 22),
+ Vector3D.of(2, 22, 17),
Vector3D.of(22, 11, -10));
EnclosingBall<Vector3D> sphere = new SphereGenerator().ballOnSupport(support);
Assert.assertEquals(25.0, sphere.getRadius(), 1.0e-10);
@@ -115,18 +115,18 @@ public class SphereGeneratorTest {
Assert.assertEquals(25.0, v.distance(sphere.getCenter()), 1.0e-10);
Assert.assertTrue(v == sphere.getSupport()[i++]);
}
- Assert.assertTrue(sphere.contains (Vector3D.of(-22.999, 2, 2)));
+ Assert.assertTrue(sphere.contains(Vector3D.of(-22.999, 2, 2)));
Assert.assertFalse(sphere.contains(Vector3D.of(-23.001, 2, 2)));
- Assert.assertTrue(sphere.contains (Vector3D.of( 26.999, 2, 2)));
- Assert.assertFalse(sphere.contains(Vector3D.of( 27.001, 2, 2)));
- Assert.assertTrue(sphere.contains (Vector3D.of(2, -22.999, 2)));
+ Assert.assertTrue(sphere.contains(Vector3D.of(26.999, 2, 2)));
+ Assert.assertFalse(sphere.contains(Vector3D.of(27.001, 2, 2)));
+ Assert.assertTrue(sphere.contains(Vector3D.of(2, -22.999, 2)));
Assert.assertFalse(sphere.contains(Vector3D.of(2, -23.001, 2)));
- Assert.assertTrue(sphere.contains (Vector3D.of(2, 26.999, 2)));
- Assert.assertFalse(sphere.contains(Vector3D.of(2, 27.001, 2)));
- Assert.assertTrue(sphere.contains (Vector3D.of(2, 2, -22.999)));
+ Assert.assertTrue(sphere.contains(Vector3D.of(2, 26.999, 2)));
+ Assert.assertFalse(sphere.contains(Vector3D.of(2, 27.001, 2)));
+ Assert.assertTrue(sphere.contains(Vector3D.of(2, 2, -22.999)));
Assert.assertFalse(sphere.contains(Vector3D.of(2, 2, -23.001)));
- Assert.assertTrue(sphere.contains (Vector3D.of(2, 2, 26.999)));
- Assert.assertFalse(sphere.contains(Vector3D.of(2, 2, 27.001)));
+ Assert.assertTrue(sphere.contains(Vector3D.of(2, 2, 26.999)));
+ Assert.assertFalse(sphere.contains(Vector3D.of(2, 2, 27.001)));
Assert.assertEquals(0.0, Vector3D.of(2.0, 2.0, 2.0).distance(sphere.getCenter()), 1.0e-10);
Assert.assertEquals(4, sphere.getSupportSize());
}
@@ -134,7 +134,7 @@ public class SphereGeneratorTest {
@Test
public void testRandom() {
final UniformRandomProvider random = RandomSource.create(RandomSource.WELL_1024_A,
- 0xd015982e9f31ee04l);
+ 0xd015982e9f31ee04L);
final UnitSphereSampler sr = new UnitSphereSampler(3, random);
for (int i = 0; i < 100; ++i) {
double d = 25 * random.nextDouble();
@@ -152,29 +152,29 @@ public class SphereGeneratorTest {
@Test
public void testDegeneratedCase() {
- final List<Vector3D> support =
+ final List<Vector3D> support =
Arrays.asList(Vector3D.of(Math.scalb(-8039905610797991.0, -50), // -7.140870659936730
Math.scalb(-4663475464714142.0, -48), // -16.567993074240455
- Math.scalb( 6592658872616184.0, -49)), // 11.710914678204503
+ Math.scalb(6592658872616184.0, -49)), // 11.710914678204503
Vector3D.of(Math.scalb(-8036658568968473.0, -50), // -7.137986707455888
Math.scalb(-4664256346424880.0, -48), // -16.570767323375720
- Math.scalb( 6591357011730307.0, -49)), // 11.708602108715928)
+ Math.scalb(6591357011730307.0, -49)), // 11.708602108715928)
Vector3D.of(Math.scalb(-8037820142977230.0, -50), // -7.139018392423351
Math.scalb(-4665280434237813.0, -48), // -16.574405614157020
- Math.scalb( 6592435966112099.0, -49)), // 11.710518716711425
+ Math.scalb(6592435966112099.0, -49)), // 11.710518716711425
Vector3D.of(Math.scalb(-8038007803611611.0, -50), // -7.139185068549035
Math.scalb(-4664291215918380.0, -48), // -16.570891204702250
- Math.scalb( 6595270610894208.0, -49))); // 11.715554057357394
+ Math.scalb(6595270610894208.0, -49))); // 11.715554057357394
EnclosingBall<Vector3D> sphere = new SphereGenerator().ballOnSupport(support);
// the following values have been computed using Emacs calc with exact arithmetic from the
// rational representation corresponding to the scalb calls (i.e. -8039905610797991/2^50, ...)
// The results were converted to decimal representation rounded to 1.0e-30 when writing the reference
// values in this test
- Assert.assertEquals( 0.003616820213530053297575846168, sphere.getRadius(), 1.0e-20);
- Assert.assertEquals( -7.139325643360503322823511839511, sphere.getCenter().getX(), 1.0e-20);
+ Assert.assertEquals(0.003616820213530053297575846168, sphere.getRadius(), 1.0e-20);
+ Assert.assertEquals(-7.139325643360503322823511839511, sphere.getCenter().getX(), 1.0e-20);
Assert.assertEquals(-16.571096474251747245361467833760, sphere.getCenter().getY(), 1.0e-20);
- Assert.assertEquals( 11.711945804096960876521111630800, sphere.getCenter().getZ(), 1.0e-20);
+ Assert.assertEquals(11.711945804096960876521111630800, sphere.getCenter().getZ(), 1.0e-20);
for (Vector3D v : support) {
Assert.assertTrue(sphere.contains(v, 1.0e-14));
diff --git a/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/euclidean/twod/enclosing/DiskGeneratorTest.java b/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/euclidean/twod/enclosing/DiskGeneratorTest.java
index 375260f..5d80681 100644
--- a/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/euclidean/twod/enclosing/DiskGeneratorTest.java
+++ b/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/euclidean/twod/enclosing/DiskGeneratorTest.java
@@ -101,7 +101,7 @@ public class DiskGeneratorTest {
@Test
public void testRandom() {
final UniformRandomProvider random = RandomSource.create(RandomSource.WELL_1024_A,
- 0x12faa818373ffe90l);
+ 0x12faa818373ffe90L);
final UnitSphereSampler sr = new UnitSphereSampler(2, random);
for (int i = 0; i < 500; ++i) {
double d = 25 * random.nextDouble();
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/EuclideanTestUtils.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/EuclideanTestUtils.java
index f74aaf8..8eecb51 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/EuclideanTestUtils.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/EuclideanTestUtils.java
@@ -26,17 +26,20 @@ import org.junit.Assert;
/**
* Class containing various euclidean-related test utilities.
*/
-public class EuclideanTestUtils {
+public final class EuclideanTestUtils {
+
+ // no instantiation
+ private EuclideanTestUtils() {}
/** Callback interface for {@link #permute(double, double, double, PermuteCallback2D)}. */
@FunctionalInterface
- public static interface PermuteCallback2D {
+ public interface PermuteCallback2D {
void accept(double x, double y);
}
/** Callback interface for {@link #permute(double, double, double, PermuteCallback3D)} */
@FunctionalInterface
- public static interface PermuteCallback3D {
+ public interface PermuteCallback3D {
void accept(double x, double y, double z);
}
@@ -198,7 +201,7 @@ public class EuclideanTestUtils {
* @param loc
* @param pts
*/
- public static void assertRegionLocation(Region<Vector1D> region, RegionLocation loc, Vector1D ... pts) {
+ public static void assertRegionLocation(Region<Vector1D> region, RegionLocation loc, Vector1D... pts) {
for (Vector1D pt : pts) {
Assert.assertEquals("Unexpected region location for point " + pt, loc, region.classify(pt));
}
@@ -210,7 +213,7 @@ public class EuclideanTestUtils {
* @param loc
* @param pts
*/
- public static void assertRegionLocation(Region<Vector2D> region, RegionLocation loc, Vector2D ... pts) {
+ public static void assertRegionLocation(Region<Vector2D> region, RegionLocation loc, Vector2D... pts) {
for (Vector2D pt : pts) {
Assert.assertEquals("Unexpected region location for point " + pt, loc, region.classify(pt));
}
@@ -222,7 +225,7 @@ public class EuclideanTestUtils {
* @param loc
* @param pts
*/
- public static void assertRegionLocation(Region<Vector3D> region, RegionLocation loc, Vector3D ... pts) {
+ public static void assertRegionLocation(Region<Vector3D> region, RegionLocation loc, Vector3D... pts) {
for (Vector3D pt : pts) {
Assert.assertEquals("Unexpected region location for point " + pt, loc, region.classify(pt));
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/internal/MatricesTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/internal/MatricesTest.java
index a16b721..a60a1a3 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/internal/MatricesTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/internal/MatricesTest.java
@@ -57,12 +57,12 @@ public class MatricesTest {
Assert.assertEquals(1, Matrices.determinant(
1, 0, 0,
0, 1, 0,
- 0 , 0, 1), EPS);
+ 0, 0, 1), EPS);
Assert.assertEquals(-1, Matrices.determinant(
-1, 0, 0,
0, -1, 0,
- 0 , 0, -1), EPS);
+ 0, 0, -1), EPS);
Assert.assertEquals(0, Matrices.determinant(
1, 2, 3,
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/AffineTransformMatrix1DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/AffineTransformMatrix1DTest.java
index 7bb748b..7b9087e 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/AffineTransformMatrix1DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/AffineTransformMatrix1DTest.java
@@ -35,7 +35,7 @@ public class AffineTransformMatrix1DTest {
Assert.assertTrue(transform.preservesOrientation());
double[] result = transform.toArray();
- Assert.assertArrayEquals(new double[] { 1, 2 }, result, 0.0);
+ Assert.assertArrayEquals(new double[] {1, 2}, result, 0.0);
}
@@ -54,7 +54,7 @@ public class AffineTransformMatrix1DTest {
// assert
Assert.assertTrue(transform.preservesOrientation());
- double[] expected = { 1, 0 };
+ double[] expected = {1, 0};
Assert.assertArrayEquals(expected, transform.toArray(), 0.0);
}
@@ -66,7 +66,7 @@ public class AffineTransformMatrix1DTest {
// assert
Assert.assertTrue(transform.preservesOrientation());
- double[] expected = { 1, 2 };
+ double[] expected = {1, 2};
Assert.assertArrayEquals(expected, transform.toArray(), 0.0);
}
@@ -78,7 +78,7 @@ public class AffineTransformMatrix1DTest {
// assert
Assert.assertTrue(transform.preservesOrientation());
- double[] expected = { 1, 5 };
+ double[] expected = {1, 5};
Assert.assertArrayEquals(expected, transform.toArray(), 0.0);
}
@@ -93,7 +93,7 @@ public class AffineTransformMatrix1DTest {
// assert
Assert.assertTrue(result.preservesOrientation());
- double[] expected = { 2, 14 };
+ double[] expected = {2, 14};
Assert.assertArrayEquals(expected, result.toArray(), 0.0);
}
@@ -108,7 +108,7 @@ public class AffineTransformMatrix1DTest {
// assert
Assert.assertTrue(result.preservesOrientation());
- double[] expected = { 2, 17 };
+ double[] expected = {2, 17};
Assert.assertArrayEquals(expected, result.toArray(), 0.0);
}
@@ -120,7 +120,7 @@ public class AffineTransformMatrix1DTest {
// assert
Assert.assertTrue(transform.preservesOrientation());
- double[] expected = { 4, 0 };
+ double[] expected = {4, 0};
Assert.assertArrayEquals(expected, transform.toArray(), 0.0);
}
@@ -132,7 +132,7 @@ public class AffineTransformMatrix1DTest {
// assert
Assert.assertTrue(transform.preservesOrientation());
- double[] expected = { 7, 0 };
+ double[] expected = {7, 0};
Assert.assertArrayEquals(expected, transform.toArray(), 0.0);
}
@@ -147,7 +147,7 @@ public class AffineTransformMatrix1DTest {
// assert
Assert.assertTrue(result.preservesOrientation());
- double[] expected = { 8, 40 };
+ double[] expected = {8, 40};
Assert.assertArrayEquals(expected, result.toArray(), 0.0);
}
@@ -162,7 +162,7 @@ public class AffineTransformMatrix1DTest {
// assert
Assert.assertTrue(result.preservesOrientation());
- double[] expected = { 14, 70 };
+ double[] expected = {14, 70};
Assert.assertArrayEquals(expected, result.toArray(), 0.0);
}
@@ -172,7 +172,7 @@ public class AffineTransformMatrix1DTest {
AffineTransformMatrix1D transform = AffineTransformMatrix1D.identity();
// act/assert
- runWithCoordinates((x) -> {
+ runWithCoordinates(x -> {
Vector1D v = Vector1D.of(x);
EuclideanTestUtils.assertCoordinatesEqual(v, transform.apply(v), EPS);
@@ -188,7 +188,7 @@ public class AffineTransformMatrix1DTest {
.translate(translation);
// act/assert
- runWithCoordinates((x) -> {
+ runWithCoordinates(x -> {
Vector1D vec = Vector1D.of(x);
Vector1D expectedVec = vec.add(translation);
@@ -206,7 +206,7 @@ public class AffineTransformMatrix1DTest {
.scale(factor);
// act/assert
- runWithCoordinates((x) -> {
+ runWithCoordinates(x -> {
Vector1D vec = Vector1D.of(x);
Vector1D expectedVec = Vector1D.of(factor.getX() * x);
@@ -228,7 +228,7 @@ public class AffineTransformMatrix1DTest {
// act/assert
EuclideanTestUtils.assertCoordinatesEqual(Vector1D.of(-5), transform.apply(Vector1D.of(1)), EPS);
- runWithCoordinates((x) -> {
+ runWithCoordinates(x -> {
Vector1D vec = Vector1D.of(x);
Vector1D expectedVec = Vector1D.of(
@@ -250,7 +250,7 @@ public class AffineTransformMatrix1DTest {
.translate(translation);
// act/assert
- runWithCoordinates((x) -> {
+ runWithCoordinates(x -> {
Vector1D vec = Vector1D.of(x);
Vector1D expectedVec = Vector1D.of(
@@ -267,7 +267,7 @@ public class AffineTransformMatrix1DTest {
AffineTransformMatrix1D transform = AffineTransformMatrix1D.identity();
// act/assert
- runWithCoordinates((x) -> {
+ runWithCoordinates(x -> {
Vector1D v = Vector1D.of(x);
EuclideanTestUtils.assertCoordinatesEqual(v, transform.applyVector(v), EPS);
@@ -283,7 +283,7 @@ public class AffineTransformMatrix1DTest {
.translate(translation);
// act/assert
- runWithCoordinates((x) -> {
+ runWithCoordinates(x -> {
Vector1D vec = Vector1D.of(x);
EuclideanTestUtils.assertCoordinatesEqual(vec, transform.applyVector(vec), EPS);
@@ -299,7 +299,7 @@ public class AffineTransformMatrix1DTest {
.scale(factor);
// act/assert
- runWithCoordinates((x) -> {
+ runWithCoordinates(x -> {
Vector1D vec = Vector1D.of(x);
Vector1D expectedVec = Vector1D.of(factor.getX() * x);
@@ -321,7 +321,7 @@ public class AffineTransformMatrix1DTest {
.scale(scale);
// act/assert
- runWithCoordinates((x) -> {
+ runWithCoordinates(x -> {
Vector1D p2 = Vector1D.of(x);
Vector1D input = p1.subtract(p2);
@@ -337,7 +337,7 @@ public class AffineTransformMatrix1DTest {
AffineTransformMatrix1D transform = AffineTransformMatrix1D.identity();
// act/assert
- runWithCoordinates((x) -> {
+ runWithCoordinates(x -> {
Vector1D v = Vector1D.of(x);
EuclideanTestUtils.assertCoordinatesEqual(v.normalize(), transform.applyDirection(v), EPS);
@@ -353,7 +353,7 @@ public class AffineTransformMatrix1DTest {
.translate(translation);
// act/assert
- runWithCoordinates((x) -> {
+ runWithCoordinates(x -> {
Vector1D vec = Vector1D.of(x);
EuclideanTestUtils.assertCoordinatesEqual(vec.normalize(), transform.applyDirection(vec), EPS);
@@ -369,7 +369,7 @@ public class AffineTransformMatrix1DTest {
.scale(factor);
// act/assert
- runWithCoordinates((x) -> {
+ runWithCoordinates(x -> {
Vector1D vec = Vector1D.of(x);
Vector1D expectedVec = Vector1D.of(factor.getX() * x).normalize();
@@ -391,7 +391,7 @@ public class AffineTransformMatrix1DTest {
.scale(scale);
// act/assert
- runWithCoordinates((x) -> {
+ runWithCoordinates(x -> {
Vector1D p2 = Vector1D.of(x);
Vector1D input = p1.subtract(p2);
@@ -446,7 +446,7 @@ public class AffineTransformMatrix1DTest {
// assert
double[] arr = result.toArray();
- Assert.assertArrayEquals(new double[] { 26, 31 }, arr, EPS);
+ Assert.assertArrayEquals(new double[] {26, 31}, arr, EPS);
}
@Test
@@ -465,7 +465,7 @@ public class AffineTransformMatrix1DTest {
AffineTransformMatrix1D transform = d.multiply(c).multiply(b).multiply(a);
// assert
- runWithCoordinates((x) -> {
+ runWithCoordinates(x -> {
Vector1D vec = Vector1D.of(x);
Vector1D expectedVec = vec
@@ -488,7 +488,7 @@ public class AffineTransformMatrix1DTest {
// assert
double[] arr = result.toArray();
- Assert.assertArrayEquals(new double[] { 26, 31 }, arr, EPS);
+ Assert.assertArrayEquals(new double[] {26, 31}, arr, EPS);
}
@Test
@@ -507,7 +507,7 @@ public class AffineTransformMatrix1DTest {
AffineTransformMatrix1D transform = a.premultiply(b).premultiply(c).premultiply(d);
// assert
- runWithCoordinates((x) -> {
+ runWithCoordinates(x -> {
Vector1D vec = Vector1D.of(x);
Vector1D expectedVec = vec
@@ -525,7 +525,7 @@ public class AffineTransformMatrix1DTest {
AffineTransformMatrix1D inverse = AffineTransformMatrix1D.identity().inverse();
// assert
- double[] expected = { 1, 0 };
+ double[] expected = {1, 0};
Assert.assertArrayEquals(expected, inverse.toArray(), 0.0);
}
@@ -540,7 +540,7 @@ public class AffineTransformMatrix1DTest {
AffineTransformMatrix1D result = inv.multiply(a);
// assert
- double[] expected = { 1, 0 };
+ double[] expected = {1, 0};
Assert.assertArrayEquals(expected, result.toArray(), EPS);
}
@@ -553,7 +553,7 @@ public class AffineTransformMatrix1DTest {
AffineTransformMatrix1D inverse = transform.inverse();
// assert
- double[] expected = { 1, -3 };
+ double[] expected = {1, -3};
Assert.assertArrayEquals(expected, inverse.toArray(), 0.0);
}
@@ -566,7 +566,7 @@ public class AffineTransformMatrix1DTest {
AffineTransformMatrix1D inverse = transform.inverse();
// assert
- double[] expected = { 0.1, 0 };
+ double[] expected = {0.1, 0};
Assert.assertArrayEquals(expected, inverse.toArray(), 0.0);
}
@@ -579,7 +579,7 @@ public class AffineTransformMatrix1DTest {
Vector1D v4 = Vector1D.of(-2);
// act/assert
- runWithCoordinates((x) -> {
+ runWithCoordinates(x -> {
AffineTransformMatrix1D transform = AffineTransformMatrix1D
.createTranslation(x)
.scale(2)
@@ -667,7 +667,7 @@ public class AffineTransformMatrix1DTest {
}
@FunctionalInterface
- private static interface Coordinate1DTest {
+ private interface Coordinate1DTest {
void run(double x);
}
@@ -681,8 +681,7 @@ public class AffineTransformMatrix1DTest {
runWithCoordinates(test, -1e2, 1e2, 5, skipZero);
}
- private static void runWithCoordinates(Coordinate1DTest test, double min, double max, double step, boolean skipZero)
- {
+ private static void runWithCoordinates(Coordinate1DTest test, double min, double max, double step, boolean skipZero) {
for (double x = min; x <= max; x += step) {
if (!skipZero || x != 0.0) {
test.run(x);
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/FunctionTransform1DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/FunctionTransform1DTest.java
index 779b23a..a268a84 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/FunctionTransform1DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/FunctionTransform1DTest.java
@@ -133,13 +133,13 @@ public class FunctionTransform1DTest {
@Test
public void testToMatrix() {
// act/assert
- Assert.assertArrayEquals(new double[] { 1, 0 },
+ Assert.assertArrayEquals(new double[] {1, 0},
FunctionTransform1D.identity().toMatrix().toArray(), TEST_EPS);
- Assert.assertArrayEquals(new double[] { 1, 2 },
+ Assert.assertArrayEquals(new double[] {1, 2},
FunctionTransform1D.from(v -> v.add(Vector1D.of(2))).toMatrix().toArray(), TEST_EPS);
- Assert.assertArrayEquals(new double[] { 3, 0 },
+ Assert.assertArrayEquals(new double[] {3, 0},
FunctionTransform1D.from(v -> v.multiply(3)).toMatrix().toArray(), TEST_EPS);
- Assert.assertArrayEquals(new double[] { 3, 6 },
+ Assert.assertArrayEquals(new double[] {3, 6},
FunctionTransform1D.from(v -> v.add(Vector1D.of(2)).multiply(3)).toMatrix().toArray(), TEST_EPS);
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/IntervalTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/IntervalTest.java
index 8b6f12a..46ec589 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/IntervalTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/IntervalTest.java
@@ -72,9 +72,9 @@ public class IntervalTest {
GeometryTestUtils.assertThrows(() -> Interval.of(Double.NaN, Double.NaN, TEST_PRECISION), excType);
GeometryTestUtils.assertThrows(
- () -> Interval.of(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, TEST_PRECISION), excType);
+ () -> Interval.of(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, TEST_PRECISION), excType);
GeometryTestUtils.assertThrows(
- () -> Interval.of(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, TEST_PRECISION), excType);
+ () -> Interval.of(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, TEST_PRECISION), excType);
}
@Test
@@ -92,9 +92,9 @@ public class IntervalTest {
// act/assert
GeometryTestUtils.assertThrows(
- () -> Interval.of(Vector1D.of(1), Vector1D.of(Double.NaN), TEST_PRECISION), excType);
+ () -> Interval.of(Vector1D.of(1), Vector1D.of(Double.NaN), TEST_PRECISION), excType);
GeometryTestUtils.assertThrows(
- () -> Interval.of(Vector1D.of(Double.POSITIVE_INFINITY), Vector1D.of(Double.POSITIVE_INFINITY), TEST_PRECISION), excType);
+ () -> Interval.of(Vector1D.of(Double.POSITIVE_INFINITY), Vector1D.of(Double.POSITIVE_INFINITY), TEST_PRECISION), excType);
}
@Test
@@ -142,34 +142,34 @@ public class IntervalTest {
// act/assert
GeometryTestUtils.assertThrows(
- () -> Interval.of(
- OrientedPoint.fromLocationAndDirection(1, false, TEST_PRECISION),
- OrientedPoint.fromLocationAndDirection(1, false, TEST_PRECISION)), excType);
+ () -> Interval.of(
+ OrientedPoint.fromLocationAndDirection(1, false, TEST_PRECISION),
+ OrientedPoint.fromLocationAndDirection(1, false, TEST_PRECISION)), excType);
GeometryTestUtils.assertThrows(
- () -> Interval.of(
- OrientedPoint.fromLocationAndDirection(2, false, TEST_PRECISION),
- OrientedPoint.fromLocationAndDirection(1, true, TEST_PRECISION)), excType);
+ () -> Interval.of(
+ OrientedPoint.fromLocationAndDirection(2, false, TEST_PRECISION),
+ OrientedPoint.fromLocationAndDirection(1, true, TEST_PRECISION)), excType);
GeometryTestUtils.assertThrows(
- () -> Interval.of(
- OrientedPoint.fromLocationAndDirection(Double.POSITIVE_INFINITY, false, TEST_PRECISION),
- OrientedPoint.fromLocationAndDirection(Double.POSITIVE_INFINITY, true, TEST_PRECISION)), excType);
+ () -> Interval.of(
+ OrientedPoint.fromLocationAndDirection(Double.POSITIVE_INFINITY, false, TEST_PRECISION),
+ OrientedPoint.fromLocationAndDirection(Double.POSITIVE_INFINITY, true, TEST_PRECISION)), excType);
GeometryTestUtils.assertThrows(
- () -> Interval.of(
- OrientedPoint.fromLocationAndDirection(Double.NaN, false, TEST_PRECISION),
- OrientedPoint.fromLocationAndDirection(1, true, TEST_PRECISION)), excType);
+ () -> Interval.of(
+ OrientedPoint.fromLocationAndDirection(Double.NaN, false, TEST_PRECISION),
+ OrientedPoint.fromLocationAndDirection(1, true, TEST_PRECISION)), excType);
GeometryTestUtils.assertThrows(
- () -> Interval.of(
- OrientedPoint.fromLocationAndDirection(1, false, TEST_PRECISION),
- OrientedPoint.fromLocationAndDirection(Double.NaN, true, TEST_PRECISION)), excType);
+ () -> Interval.of(
+ OrientedPoint.fromLocationAndDirection(1, false, TEST_PRECISION),
+ OrientedPoint.fromLocationAndDirection(Double.NaN, true, TEST_PRECISION)), excType);
GeometryTestUtils.assertThrows(
- () -> Interval.of(
- OrientedPoint.fromLocationAndDirection(Double.NaN, false, TEST_PRECISION),
- OrientedPoint.fromLocationAndDirection(Double.NaN, true, TEST_PRECISION)), excType);
+ () -> Interval.of(
+ OrientedPoint.fromLocationAndDirection(Double.NaN, false, TEST_PRECISION),
+ OrientedPoint.fromLocationAndDirection(Double.NaN, true, TEST_PRECISION)), excType);
}
@Test
@@ -187,11 +187,11 @@ public class IntervalTest {
// act/assert
GeometryTestUtils.assertThrows(
- () -> Interval.point(Double.NEGATIVE_INFINITY, TEST_PRECISION), excType);
+ () -> Interval.point(Double.NEGATIVE_INFINITY, TEST_PRECISION), excType);
GeometryTestUtils.assertThrows(
- () -> Interval.point(Double.POSITIVE_INFINITY, TEST_PRECISION), excType);
+ () -> Interval.point(Double.POSITIVE_INFINITY, TEST_PRECISION), excType);
GeometryTestUtils.assertThrows(
- () -> Interval.point(Double.NaN, TEST_PRECISION), excType);
+ () -> Interval.point(Double.NaN, TEST_PRECISION), excType);
}
@Test
@@ -212,9 +212,9 @@ public class IntervalTest {
// act/assert
GeometryTestUtils.assertThrows(
- () -> Interval.min(Double.POSITIVE_INFINITY, TEST_PRECISION), excType);
+ () -> Interval.min(Double.POSITIVE_INFINITY, TEST_PRECISION), excType);
GeometryTestUtils.assertThrows(
- () -> Interval.min(Double.NaN, TEST_PRECISION), excType);
+ () -> Interval.min(Double.NaN, TEST_PRECISION), excType);
}
@Test
@@ -235,9 +235,9 @@ public class IntervalTest {
// act/assert
GeometryTestUtils.assertThrows(
- () -> Interval.max(Double.NEGATIVE_INFINITY, TEST_PRECISION), excType);
+ () -> Interval.max(Double.NEGATIVE_INFINITY, TEST_PRECISION), excType);
GeometryTestUtils.assertThrows(
- () -> Interval.max(Double.NaN, TEST_PRECISION), excType);
+ () -> Interval.max(Double.NaN, TEST_PRECISION), excType);
}
@Test
@@ -621,7 +621,7 @@ public class IntervalTest {
@Test
public void testTransform() {
// arrange
- Transform1D transform = FunctionTransform1D.from((p) -> Vector1D.of(2.0 * p.getX()));
+ Transform1D transform = FunctionTransform1D.from(p -> Vector1D.of(2.0 * p.getX()));
// act/assert
checkInterval(Interval.of(-1, 2, TEST_PRECISION).transform(transform), -2, 4);
@@ -865,7 +865,7 @@ public class IntervalTest {
Assert.assertEquals(RegionLocation.INSIDE, full.classify(Double.POSITIVE_INFINITY));
}
- private static void checkContains(Interval interval, boolean contains, double ... points) {
+ private static void checkContains(Interval interval, boolean contains, double... points) {
for (double x : points) {
String msg = "Unexpected contains status for point " + x;
@@ -874,7 +874,7 @@ public class IntervalTest {
}
}
- private static void checkClassify(Interval interval, RegionLocation loc, double ... points) {
+ private static void checkClassify(Interval interval, RegionLocation loc, double... points) {
for (double x : points) {
String msg = "Unexpected location for point " + x;
@@ -883,7 +883,7 @@ public class IntervalTest {
}
}
- private static void checkClassify(RegionBSPTree1D tree, RegionLocation loc, double ... points) {
+ private static void checkClassify(RegionBSPTree1D tree, RegionLocation loc, double... points) {
for (double x : points) {
String msg = "Unexpected location for point " + x;
@@ -927,15 +927,13 @@ public class IntervalTest {
if (finiteMin) {
Assert.assertEquals(min, interval.getMinBoundary().getLocation(), TEST_EPS);
- }
- else {
+ } else {
Assert.assertNull(interval.getMinBoundary());
}
if (finiteMax) {
Assert.assertEquals(max, interval.getMaxBoundary().getLocation(), TEST_EPS);
- }
- else {
+ } else {
Assert.assertNull(interval.getMaxBoundary());
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/OrientedPointTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/OrientedPointTest.java
index dc7b2fe..87038e9 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/OrientedPointTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/OrientedPointTest.java
@@ -116,8 +116,8 @@ public class OrientedPointTest {
// act/assert
GeometryTestUtils.assertThrows(
- () -> pt.transform(zeroScale),
- IllegalArgumentException.class, "Oriented point direction cannot be zero");
+ () -> pt.transform(zeroScale),
+ IllegalArgumentException.class, "Oriented point direction cannot be zero");
}
@Test
@@ -371,11 +371,11 @@ public class OrientedPointTest {
// act/assert
GeometryTestUtils.assertThrows(
- () -> OrientedPoint.fromPointAndDirection(Vector1D.of(2.0), Vector1D.of(0.09), precision),
- IllegalArgumentException.class, "Oriented point direction cannot be zero");
+ () -> OrientedPoint.fromPointAndDirection(Vector1D.of(2.0), Vector1D.of(0.09), precision),
+ IllegalArgumentException.class, "Oriented point direction cannot be zero");
GeometryTestUtils.assertThrows(
- () -> OrientedPoint.fromPointAndDirection(Vector1D.of(2.0), Vector1D.of(-0.09), precision),
- IllegalArgumentException.class, "Oriented point direction cannot be zero");
+ () -> OrientedPoint.fromPointAndDirection(Vector1D.of(2.0), Vector1D.of(-0.09), precision),
+ IllegalArgumentException.class, "Oriented point direction cannot be zero");
}
@Test
@@ -585,15 +585,15 @@ public class OrientedPointTest {
// act/assert
GeometryTestUtils.assertThrows(
- () -> builder.add(OrientedPoint.createPositiveFacing(2e-3, precision).span()),
- IllegalArgumentException.class);
+ () -> builder.add(OrientedPoint.createPositiveFacing(2e-3, precision).span()),
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(
- () -> builder.add(OrientedPoint.createNegativeFacing(2e-3, precision).span()),
- IllegalArgumentException.class);
+ () -> builder.add(OrientedPoint.createNegativeFacing(2e-3, precision).span()),
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(
- () -> builder.add((SubHyperplane<Vector1D>) OrientedPoint.createPositiveFacing(2e-3, precision).span()),
- IllegalArgumentException.class);
+ () -> builder.add((SubHyperplane<Vector1D>) OrientedPoint.createPositiveFacing(2e-3, precision).span()),
+ IllegalArgumentException.class);
}
@Test
@@ -621,7 +621,7 @@ public class OrientedPointTest {
Assert.assertSame(precision, pt.getPrecision());
}
- private static void assertClassify(HyperplaneLocation expected, OrientedPoint pt, double ... locations) {
+ private static void assertClassify(HyperplaneLocation expected, OrientedPoint pt, double... locations) {
for (double location : locations) {
String msg = "Unexpected classification for location " + location;
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/RegionBSPTree1DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/RegionBSPTree1DTest.java
index 25804c4..54dd532 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/RegionBSPTree1DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/RegionBSPTree1DTest.java
@@ -86,7 +86,7 @@ public class RegionBSPTree1DTest {
// act/assert
checkClassify(tree, RegionLocation.OUTSIDE, Double.NEGATIVE_INFINITY);
- checkClassify(tree, RegionLocation.OUTSIDE,-2.0);
+ checkClassify(tree, RegionLocation.OUTSIDE, -2.0);
checkClassify(tree, RegionLocation.INSIDE, 0.0);
checkClassify(tree, RegionLocation.BOUNDARY, 9.0 - 1e-16);
checkClassify(tree, RegionLocation.BOUNDARY, 9.0 + 1e-16);
@@ -129,7 +129,7 @@ public class RegionBSPTree1DTest {
// act/assert
checkContains(tree, false, Double.NEGATIVE_INFINITY);
- checkContains(tree, false,-2.0);
+ checkContains(tree, false, -2.0);
checkContains(tree, true, 0.0);
checkContains(tree, true, 9.0 - 1e-16);
checkContains(tree, true, 9.0 + 1e-16);
@@ -1194,7 +1194,7 @@ public class RegionBSPTree1DTest {
Assert.assertEquals(2, tree.toIntervals().size());
}
- private static void checkClassify(RegionBSPTree1D tree, RegionLocation loc, double ... points) {
+ private static void checkClassify(RegionBSPTree1D tree, RegionLocation loc, double... points) {
for (double x : points) {
String msg = "Unexpected location for point " + x;
@@ -1203,7 +1203,7 @@ public class RegionBSPTree1DTest {
}
}
- private static void checkContains(RegionBSPTree1D tree, boolean contains, double ... points) {
+ private static void checkContains(RegionBSPTree1D tree, boolean contains, double... points) {
for (double x : points) {
String msg = "Unexpected contains status for point " + x;
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/Vector1DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/Vector1DTest.java
index 604c177..4f23c9f 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/Vector1DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/Vector1DTest.java
@@ -203,8 +203,7 @@ public class Vector1DTest {
checkVector(Vector1D.Unit.PLUS.withNorm(2.5), 2.5);
checkVector(Vector1D.Unit.MINUS.withNorm(3.14), -3.14);
- for (double mag = -10.0; mag <= 10.0; ++mag)
- {
+ for (double mag = -10.0; mag <= 10.0; ++mag) {
Assert.assertEquals(Math.abs(mag), v.withNorm(mag).norm(), TEST_TOLERANCE);
}
}
@@ -695,7 +694,7 @@ public class Vector1DTest {
5, Vector1D.of(7)), 41);
checkVector(Vector1D.linearCombination(
2, Vector1D.of(3),
- -5, Vector1D.of(7)),-29);
+ -5, Vector1D.of(7)), -29);
}
@Test
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/AffineTransformMatrix3DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/AffineTransformMatrix3DTest.java
index 9b206e8..f3f0c0e 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/AffineTransformMatrix3DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/AffineTransformMatrix3DTest.java
@@ -33,9 +33,9 @@ public class AffineTransformMatrix3DTest {
public void testOf() {
// arrange
double[] arr = {
- 1, 2, 3, 4,
- 5, 6, 7, 8,
- 9, 10, 11, 12
+ 1, 2, 3, 4,
+ 5, 6, 7, 8,
+ 9, 10, 11, 12
};
// act
@@ -66,9 +66,9 @@ public class AffineTransformMatrix3DTest {
// assert
Assert.assertArrayEquals(new double[] {
- 1, 4, 7, 0,
- 2, 5, 8, 0,
- 3, 6, 9, 0
+ 1, 4, 7, 0,
+ 2, 5, 8, 0,
+ 3, 6, 9, 0
}, transform.toArray(), 0.0);
}
@@ -85,9 +85,9 @@ public class AffineTransformMatrix3DTest {
// assert
Assert.assertArrayEquals(new double[] {
- 1, 4, 7, 10,
- 2, 5, 8, 11,
- 3, 6, 9, 12
+ 1, 4, 7, 10,
+ 2, 5, 8, 11,
+ 3, 6, 9, 12
}, transform.toArray(), 0.0);
}
@@ -98,9 +98,9 @@ public class AffineTransformMatrix3DTest {
// assert
double[] expected = {
- 1, 0, 0, 0,
- 0, 1, 0, 0,
- 0, 0, 1, 0
+ 1, 0, 0, 0,
+ 0, 1, 0, 0,
+ 0, 0, 1, 0
};
Assert.assertArrayEquals(expected, transform.toArray(), 0.0);
}
@@ -112,9 +112,9 @@ public class AffineTransformMatrix3DTest {
// assert
double[] expected = {
- 1, 0, 0, 2,
- 0, 1, 0, 3,
- 0, 0, 1, 4
+ 1, 0, 0, 2,
+ 0, 1, 0, 3,
+ 0, 0, 1, 4
};
Assert.assertArrayEquals(expected, transform.toArray(), 0.0);
}
@@ -126,9 +126,9 @@ public class AffineTransformMatrix3DTest {
// assert
double[] expected = {
- 1, 0, 0, 5,
- 0, 1, 0, 6,
- 0, 0, 1, 7
+ 1, 0, 0, 5,
+ 0, 1, 0, 6,
+ 0, 0, 1, 7
};
Assert.assertArrayEquals(expected, transform.toArray(), 0.0);
}
@@ -140,9 +140,9 @@ public class AffineTransformMatrix3DTest {
// assert
double[] expected = {
- 2, 0, 0, 0,
- 0, 3, 0, 0,
- 0, 0, 4, 0
+ 2, 0, 0, 0,
+ 0, 3, 0, 0,
+ 0, 0, 4, 0
};
Assert.assertArrayEquals(expected, transform.toArray(), 0.0);
}
@@ -161,9 +161,9 @@ public class AffineTransformMatrix3DTest {
// assert
double[] expected = {
- 2, 0, 0, 14,
- 0, 3, 0, 16,
- 0, 0, 4, 18
+ 2, 0, 0, 14,
+ 0, 3, 0, 16,
+ 0, 0, 4, 18
};
Assert.assertArrayEquals(expected, result.toArray(), 0.0);
}
@@ -182,9 +182,9 @@ public class AffineTransformMatrix3DTest {
// assert
double[] expected = {
- 2, 0, 0, 17,
- 0, 3, 0, 19,
- 0, 0, 4, 21
+ 2, 0, 0, 17,
+ 0, 3, 0, 19,
+ 0, 0, 4, 21
};
Assert.assertArrayEquals(expected, result.toArray(), 0.0);
}
@@ -196,9 +196,9 @@ public class AffineTransformMatrix3DTest {
// assert
double[] expected = {
- 4, 0, 0, 0,
- 0, 5, 0, 0,
- 0, 0, 6, 0
+ 4, 0, 0, 0,
+ 0, 5, 0, 0,
+ 0, 0, 6, 0
};
Assert.assertArrayEquals(expected, transform.toArray(), 0.0);
}
@@ -210,9 +210,9 @@ public class AffineTransformMatrix3DTest {
// assert
double[] expected = {
- 7, 0, 0, 0,
- 0, 7, 0, 0,
- 0, 0, 7, 0
+ 7, 0, 0, 0,
+ 0, 7, 0, 0,
+ 0, 0, 7, 0
};
Assert.assertArrayEquals(expected, transform.toArray(), 0.0);
}
@@ -231,9 +231,9 @@ public class AffineTransformMatrix3DTest {
// assert
double[] expected = {
- 8, 0, 0, 40,
- 0, 15, 0, 55,
- 0, 0, 24, 72
+ 8, 0, 0, 40,
+ 0, 15, 0, 55,
+ 0, 0, 24, 72
};
Assert.assertArrayEquals(expected, result.toArray(), 0.0);
}
@@ -252,9 +252,9 @@ public class AffineTransformMatrix3DTest {
// assert
double[] expected = {
- 14, 0, 0, 70,
- 0, 24, 0, 88,
- 0, 0, 36, 108
+ 14, 0, 0, 70,
+ 0, 24, 0, 88,
+ 0, 0, 36, 108
};
Assert.assertArrayEquals(expected, result.toArray(), 0.0);
}
@@ -273,9 +273,9 @@ public class AffineTransformMatrix3DTest {
// assert
double[] expected = {
- 20, 0, 0, 100,
- 0, 30, 0, 110,
- 0, 0, 40, 120
+ 20, 0, 0, 100,
+ 0, 30, 0, 110,
+ 0, 0, 40, 120
};
Assert.assertArrayEquals(expected, result.toArray(), 0.0);
}
@@ -291,9 +291,9 @@ public class AffineTransformMatrix3DTest {
// assert
double[] expected = {
- 0, -1, 0, 3,
- 1, 0, 0, 1,
- 0, 0, 1, 0
+ 0, -1, 0, 3,
+ 1, 0, 0, 1,
+ 0, 0, 1, 0
};
Assert.assertArrayEquals(expected, result.toArray(), EPS);
}
@@ -314,9 +314,9 @@ public class AffineTransformMatrix3DTest {
// assert
double[] expected = {
- -5, -6, -7, -8,
- 1, 2, 3, 4,
- 9, 10, 11, 12
+ -5, -6, -7, -8,
+ 1, 2, 3, 4,
+ 9, 10, 11, 12
};
Assert.assertArrayEquals(expected, result.toArray(), EPS);
}
@@ -338,9 +338,9 @@ public class AffineTransformMatrix3DTest {
// assert
double[] expected = {
- -5, -6, -7, -5,
- 1, 2, 3, 5,
- 9, 10, 11, 12
+ -5, -6, -7, -5,
+ 1, 2, 3, 5,
+ 9, 10, 11, 12
};
Assert.assertArrayEquals(expected, result.toArray(), EPS);
}
@@ -649,9 +649,9 @@ public class AffineTransformMatrix3DTest {
// assert
double[] arr = result.toArray();
Assert.assertArrayEquals(new double[] {
- 110, 116, 122, 132,
- 314, 332, 350, 376,
- 518, 548, 578, 620
+ 110, 116, 122, 132,
+ 314, 332, 350, 376,
+ 518, 548, 578, 620
}, arr, EPS);
}
@@ -787,9 +787,9 @@ public class AffineTransformMatrix3DTest {
// assert
double[] arr = result.toArray();
Assert.assertArrayEquals(new double[] {
- 110, 116, 122, 132,
- 314, 332, 350, 376,
- 518, 548, 578, 620
+ 110, 116, 122, 132,
+ 314, 332, 350, 376,
+ 518, 548, 578, 620
}, arr, EPS);
}
@@ -828,9 +828,9 @@ public class AffineTransformMatrix3DTest {
// assert
double[] expected = {
- 1, 0, 0, 0,
- 0, 1, 0, 0,
- 0, 0, 1, 0
+ 1, 0, 0, 0,
+ 0, 1, 0, 0,
+ 0, 0, 1, 0
};
Assert.assertArrayEquals(expected, inverse.toArray(), 0.0);
}
@@ -851,9 +851,9 @@ public class AffineTransformMatrix3DTest {
// assert
double[] expected = {
- 1, 0, 0, 0,
- 0, 1, 0, 0,
- 0, 0, 1, 0
+ 1, 0, 0, 0,
+ 0, 1, 0, 0,
+ 0, 0, 1, 0
};
Assert.assertArrayEquals(expected, result.toArray(), EPS);
}
@@ -868,9 +868,9 @@ public class AffineTransformMatrix3DTest {
// assert
double[] expected = {
- 1, 0, 0, -1,
- 0, 1, 0, 2,
- 0, 0, 1, -4
+ 1, 0, 0, -1,
+ 0, 1, 0, 2,
+ 0, 0, 1, -4
};
Assert.assertArrayEquals(expected, inverse.toArray(), 0.0);
}
@@ -885,9 +885,9 @@ public class AffineTransformMatrix3DTest {
// assert
double[] expected = {
- 0.1, 0, 0, 0,
- 0, -0.5, 0, 0,
- 0, 0, 0.25, 0
+ 0.1, 0, 0, 0,
+ 0, -0.5, 0, 0,
+ 0, 0, 0.25, 0
};
Assert.assertArrayEquals(expected, inverse.toArray(), 0.0);
}
@@ -905,9 +905,9 @@ public class AffineTransformMatrix3DTest {
// assert
double[] expected = {
- 0, 1, 0, -1,
- -1, 0, 0, 3,
- 0, 0, 1, 0
+ 0, 1, 0, -1,
+ -1, 0, 0, 3,
+ 0, 0, 1, 0
};
Assert.assertArrayEquals(expected, inverse.toArray(), EPS);
}
@@ -1009,13 +1009,13 @@ public class AffineTransformMatrix3DTest {
Assert.assertEquals(orig, same);
double[] temp;
- for (int i=0; i<values.length; ++i) {
- temp = values.clone();
- temp[i] = 0;
+ for (int i = 0; i < values.length; ++i) {
+ temp = values.clone();
+ temp[i] = 0;
- int modified = AffineTransformMatrix3D.of(temp).hashCode();
+ int modified = AffineTransformMatrix3D.of(temp).hashCode();
- Assert.assertNotEquals(orig, modified);
+ Assert.assertNotEquals(orig, modified);
}
}
@@ -1037,13 +1037,13 @@ public class AffineTransformMatrix3DTest {
Assert.assertFalse(a.equals(new Object()));
double[] temp;
- for (int i=0; i<values.length; ++i) {
- temp = values.clone();
- temp[i] = 0;
+ for (int i = 0; i < values.length; ++i) {
+ temp = values.clone();
+ temp[i] = 0;
- AffineTransformMatrix3D modified = AffineTransformMatrix3D.of(temp);
+ AffineTransformMatrix3D modified = AffineTransformMatrix3D.of(temp);
- Assert.assertFalse(a.equals(modified));
+ Assert.assertFalse(a.equals(modified));
}
}
@@ -1060,9 +1060,10 @@ public class AffineTransformMatrix3DTest {
String result = a.toString();
// assert
- Assert.assertEquals("[ 1.0, 2.0, 3.0, 4.0; "
- + "5.0, 6.0, 7.0, 8.0; "
- + "9.0, 10.0, 11.0, 12.0 ]", result);
+ Assert.assertEquals(
+ "[ 1.0, 2.0, 3.0, 4.0; " +
+ "5.0, 6.0, 7.0, 8.0; " +
+ "9.0, 10.0, 11.0, 12.0 ]", result);
}
/**
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/ConvexSubPlaneTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/ConvexSubPlaneTest.java
index a3ff41c..1c90c3b 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/ConvexSubPlaneTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/ConvexSubPlaneTest.java
@@ -640,19 +640,19 @@ public class ConvexSubPlaneTest {
EuclideanTestUtils.assertCoordinatesEqual(origin, plane.getNormal().multiply(-offset), TEST_EPS);
}
- private static void checkPoints(ConvexSubPlane sp, RegionLocation loc, Vector3D ... pts) {
+ private static void checkPoints(ConvexSubPlane sp, RegionLocation loc, Vector3D... pts) {
for (Vector3D pt : pts) {
Assert.assertEquals("Unexpected subplane location for point " + pt, loc, sp.classify(pt));
}
}
- private static void checkVertices(ConvexSubPlane sp, Vector3D ... pts) {
+ private static void checkVertices(ConvexSubPlane sp, Vector3D... pts) {
List<Vector3D> actual = sp.getPlane().toSpace(
sp.getSubspaceRegion().getBoundaryPaths().get(0).getVertices());
Assert.assertEquals(pts.length, actual.size());
- for (int i=0; i<pts.length; ++i) {
+ for (int i = 0; i < pts.length; ++i) {
EuclideanTestUtils.assertCoordinatesEqual(pts[i], actual.get(i), TEST_EPS);
}
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/ConvexVolumeTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/ConvexVolumeTest.java
index ed062a2..461e9c4 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/ConvexVolumeTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/ConvexVolumeTest.java
@@ -20,7 +20,6 @@ import java.util.Arrays;
import java.util.List;
import org.apache.commons.geometry.core.GeometryTestUtils;
-import org.apache.commons.geometry.core.Region;
import org.apache.commons.geometry.core.RegionLocation;
import org.apache.commons.geometry.core.Transform;
import org.apache.commons.geometry.core.partitioning.Split;
@@ -76,12 +75,12 @@ public class ConvexVolumeTest {
Assert.assertEquals(6, tree.getBoundarySize(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(0.5, 0.5, 0.5), tree.getBarycenter(), TEST_EPS);
- checkClassify(tree, RegionLocation.OUTSIDE,
+ EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.OUTSIDE,
Vector3D.of(-1, 0.5, 0.5), Vector3D.of(2, 0.5, 0.5),
Vector3D.of(0.5, -1, 0.5), Vector3D.of(0.5, 2, 0.5),
Vector3D.of(0.5, 0.5, -1), Vector3D.of(0.5, 0.5, 2));
- checkClassify(tree, RegionLocation.BOUNDARY, Vector3D.ZERO);
- checkClassify(tree, RegionLocation.INSIDE, Vector3D.of(0.5, 0.5, 0.5));
+ EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.BOUNDARY, Vector3D.ZERO);
+ EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.INSIDE, Vector3D.of(0.5, 0.5, 0.5));
}
@Test
@@ -108,9 +107,9 @@ public class ConvexVolumeTest {
Assert.assertEquals(1, vol.getBoundaries().size());
GeometryTestUtils.assertPositiveInfinity(vol.getBoundarySize());
- checkClassify(vol, RegionLocation.OUTSIDE, Vector3D.of(0, 0, 1));
- checkClassify(vol, RegionLocation.BOUNDARY, Vector3D.of(0, 0, 0));
- checkClassify(vol, RegionLocation.INSIDE, Vector3D.of(0, 0, -1));
+ EuclideanTestUtils.assertRegionLocation(vol, RegionLocation.OUTSIDE, Vector3D.of(0, 0, 1));
+ EuclideanTestUtils.assertRegionLocation(vol, RegionLocation.BOUNDARY, Vector3D.of(0, 0, 0));
+ EuclideanTestUtils.assertRegionLocation(vol, RegionLocation.INSIDE, Vector3D.of(0, 0, -1));
}
@Test
@@ -128,12 +127,12 @@ public class ConvexVolumeTest {
Assert.assertEquals(6, vol.getBoundaries().size());
Assert.assertEquals(28, vol.getBoundarySize(), TEST_EPS);
- checkClassify(vol, RegionLocation.INSIDE, Vector3D.of(1, 1, 1));
+ EuclideanTestUtils.assertRegionLocation(vol, RegionLocation.INSIDE, Vector3D.of(1, 1, 1));
- checkClassify(vol, RegionLocation.BOUNDARY,
+ EuclideanTestUtils.assertRegionLocation(vol, RegionLocation.BOUNDARY,
Vector3D.of(0.5, 0, -1), Vector3D.of(1.5, 2, 3));
- checkClassify(vol, RegionLocation.OUTSIDE,
+ EuclideanTestUtils.assertRegionLocation(vol, RegionLocation.OUTSIDE,
Vector3D.of(0, 1, 1), Vector3D.of(2, 1, 1),
Vector3D.of(1, -1, 1), Vector3D.of(1, 3, 1),
Vector3D.of(1, 1, -2), Vector3D.of(1, 1, 4));
@@ -214,15 +213,9 @@ public class ConvexVolumeTest {
Plane.fromPointAndNormal(center.add(Vector3D.of(0, -yDelta, 0)), Vector3D.Unit.MINUS_Y, TEST_PRECISION),
Plane.fromPointAndNormal(center.add(Vector3D.of(0, 0, zDelta)), Vector3D.Unit.PLUS_Z, TEST_PRECISION),
- Plane.fromPointAndNormal(center.add(Vector3D.of( 0, 0, -zDelta)), Vector3D.Unit.MINUS_Z, TEST_PRECISION)
+ Plane.fromPointAndNormal(center.add(Vector3D.of(0, 0, -zDelta)), Vector3D.Unit.MINUS_Z, TEST_PRECISION)
);
return ConvexVolume.fromBounds(planes);
}
-
- private static void checkClassify(Region<Vector3D> region, RegionLocation loc, Vector3D ... pts) {
- for (Vector3D pt : pts) {
- Assert.assertEquals("Unexpected location for point " + pt, loc, region.classify(pt));
- }
- }
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/FunctionTransform3DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/FunctionTransform3DTest.java
index da1e25e..7c7a8ba 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/FunctionTransform3DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/FunctionTransform3DTest.java
@@ -138,29 +138,25 @@ public class FunctionTransform3DTest {
public void testToMatrix() {
// act/assert
Assert.assertArrayEquals(new double[] {
- 1, 0, 0, 0,
- 0, 1, 0, 0,
- 0, 0, 1, 0
- },
- FunctionTransform3D.identity().toMatrix().toArray(), TEST_EPS);
+ 1, 0, 0, 0,
+ 0, 1, 0, 0,
+ 0, 0, 1, 0
+ }, FunctionTransform3D.identity().toMatrix().toArray(), TEST_EPS);
Assert.assertArrayEquals(new double[] {
- 1, 0, 0, 2,
- 0, 1, 0, 3,
- 0, 0, 1, -4
- },
- FunctionTransform3D.from(v -> v.add(Vector3D.of(2, 3, -4))).toMatrix().toArray(), TEST_EPS);
+ 1, 0, 0, 2,
+ 0, 1, 0, 3,
+ 0, 0, 1, -4
+ }, FunctionTransform3D.from(v -> v.add(Vector3D.of(2, 3, -4))).toMatrix().toArray(), TEST_EPS);
Assert.assertArrayEquals(new double[] {
- 3, 0, 0, 0,
- 0, 3, 0, 0,
- 0, 0, 3, 0
- },
- FunctionTransform3D.from(v -> v.multiply(3)).toMatrix().toArray(), TEST_EPS);
+ 3, 0, 0, 0,
+ 0, 3, 0, 0,
+ 0, 0, 3, 0
+ }, FunctionTransform3D.from(v -> v.multiply(3)).toMatrix().toArray(), TEST_EPS);
Assert.assertArrayEquals(new double[] {
- 3, 0, 0, 6,
- 0, 3, 0, 9,
- 0, 0, 3, 12
- },
- FunctionTransform3D.from(v -> v.add(Vector3D.of(2, 3, 4)).multiply(3)).toMatrix().toArray(), TEST_EPS);
+ 3, 0, 0, 6,
+ 0, 3, 0, 9,
+ 0, 0, 3, 12
+ }, FunctionTransform3D.from(v -> v.add(Vector3D.of(2, 3, 4)).multiply(3)).toMatrix().toArray(), TEST_EPS);
}
@Test
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Line3DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Line3DTest.java
index 3d75c04..4d0ada1 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Line3DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Line3DTest.java
@@ -228,7 +228,7 @@ public class Line3DTest {
Vector3D u = l.getDirection().orthogonal();
Vector3D v = l.getDirection().cross(u);
for (double alpha = 0; alpha < 2 * Math.PI; alpha += 0.3) {
- Assert.assertTrue(! l.contains(p1.add(Vector3D.linearCombination(Math.cos(alpha), u,
+ Assert.assertTrue(!l.contains(p1.add(Vector3D.linearCombination(Math.cos(alpha), u,
Math.sin(alpha), v))));
}
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/PlaneTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/PlaneTest.java
index 1f750b8..ed5f027 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/PlaneTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/PlaneTest.java
@@ -471,7 +471,7 @@ public class PlaneTest {
Vector3D p1 = Vector3D.of(1.2, 3.4, -5.8);
Vector3D p2 = Vector3D.of(3.4, -5.8, 1.2);
Vector3D p3 = Vector3D.of(-2.0, 4.3, 0.7);
- Plane planeA = Plane.fromPoints(p1, p2, p3, TEST_PRECISION);
+ Plane planeA = Plane.fromPoints(p1, p2, p3, TEST_PRECISION);
// act/assert
Assert.assertTrue(planeA.contains(planeA));
@@ -537,7 +537,8 @@ public class PlaneTest {
Plane parallelPlane = Plane.fromPointAndNormal(Vector3D.of(0, 0, 1), Vector3D.of(0, 0, 1), TEST_PRECISION);
Plane parallelPlane2 = Plane.fromPointAndNormal(Vector3D.of(0, 0, 2), Vector3D.of(0, 0, 1), TEST_PRECISION);
Plane parallelPlane3 = Plane.fromPointAndNormal(Vector3D.ZERO, Vector3D.of(0, 0, 1), TEST_PRECISION).reverse();
- Plane nonParallelPlane = Plane.fromPointAndPlaneVectors(Vector3D.of(0, 0, 1), Vector3D.of(1, 1.5, 1), Vector3D.of(0,1,1), TEST_PRECISION);
+ Plane nonParallelPlane = Plane.fromPointAndPlaneVectors(Vector3D.of(0, 0, 1),
+ Vector3D.of(1, 1.5, 1), Vector3D.of(0, 1, 1), TEST_PRECISION);
Plane reversedPlane = plane.reverse();
// act/assert
@@ -567,7 +568,7 @@ public class PlaneTest {
Line3D projected = plane.project(line);
// assert
- Line3D expectedProjection = Line3D.fromPoints(Vector3D.of(1, 0, 1),Vector3D.of(2, 0, 1), TEST_PRECISION);
+ Line3D expectedProjection = Line3D.fromPoints(Vector3D.of(1, 0, 1), Vector3D.of(2, 0, 1), TEST_PRECISION);
Assert.assertEquals(expectedProjection, projected);
Assert.assertTrue(plane.contains(projected));
@@ -1112,7 +1113,7 @@ public class PlaneTest {
List<T> result = new ArrayList<>(size);
- for (int i=0; i<size; ++i) {
+ for (int i = 0; i < size; ++i) {
result.add(list.get((i + shift) % size));
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/RegionBSPTree3DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/RegionBSPTree3DTest.java
index 970a7ee..63397b0 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/RegionBSPTree3DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/RegionBSPTree3DTest.java
@@ -23,7 +23,6 @@ import java.util.Arrays;
import java.util.List;
import org.apache.commons.geometry.core.GeometryTestUtils;
-import org.apache.commons.geometry.core.Region;
import org.apache.commons.geometry.core.RegionLocation;
import org.apache.commons.geometry.core.partitioning.Split;
import org.apache.commons.geometry.core.partitioning.SplitLocation;
@@ -79,7 +78,7 @@ public class RegionBSPTree3DTest {
Assert.assertEquals(0.0, tree.getSize(), TEST_EPS);
Assert.assertEquals(0, tree.getBoundarySize(), TEST_EPS);
- checkClassify(tree, RegionLocation.OUTSIDE,
+ EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.OUTSIDE,
Vector3D.of(-Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE),
Vector3D.of(-100, -100, -100),
Vector3D.of(0, 0, 0),
@@ -100,7 +99,7 @@ public class RegionBSPTree3DTest {
GeometryTestUtils.assertPositiveInfinity(tree.getSize());
Assert.assertEquals(0, tree.getBoundarySize(), TEST_EPS);
- checkClassify(tree, RegionLocation.INSIDE,
+ EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.INSIDE,
Vector3D.of(-Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE),
Vector3D.of(-100, -100, -100),
Vector3D.of(0, 0, 0),
@@ -165,11 +164,11 @@ public class RegionBSPTree3DTest {
EuclideanTestUtils.assertPositiveInfinity(tree.getBoundarySize());
Assert.assertNull(tree.getBarycenter());
- checkClassify(tree, RegionLocation.INSIDE,
+ EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.INSIDE,
Vector3D.of(-Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE),
Vector3D.of(-100, -100, -100));
- checkClassify(tree, RegionLocation.BOUNDARY, Vector3D.of(0, 0, 0));
- checkClassify(tree, RegionLocation.OUTSIDE,
+ EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.BOUNDARY, Vector3D.of(0, 0, 0));
+ EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.OUTSIDE,
Vector3D.of(100, 100, 100),
Vector3D.of(Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE));
}
@@ -200,9 +199,9 @@ public class RegionBSPTree3DTest {
GeometryTestUtils.assertPositiveInfinity(tree.getBoundarySize());
Assert.assertNull(tree.getBarycenter());
- checkClassify(tree, RegionLocation.OUTSIDE, Vector3D.of(0, 0, 1));
- checkClassify(tree, RegionLocation.BOUNDARY, Vector3D.ZERO);
- checkClassify(tree, RegionLocation.INSIDE, Vector3D.of(0, 0, -1));
+ EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.OUTSIDE, Vector3D.of(0, 0, 1));
+ EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.BOUNDARY, Vector3D.ZERO);
+ EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.INSIDE, Vector3D.of(0, 0, -1));
}
@Test
@@ -226,12 +225,12 @@ public class RegionBSPTree3DTest {
Assert.assertEquals(6, tree.getBoundarySize(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(0.5, 0.5, 0.5), tree.getBarycenter(), TEST_EPS);
- checkClassify(tree, RegionLocation.OUTSIDE,
+ EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.OUTSIDE,
Vector3D.of(-1, 0.5, 0.5), Vector3D.of(2, 0.5, 0.5),
Vector3D.of(0.5, -1, 0.5), Vector3D.of(0.5, 2, 0.5),
Vector3D.of(0.5, 0.5, -1), Vector3D.of(0.5, 0.5, 2));
- checkClassify(tree, RegionLocation.BOUNDARY, Vector3D.ZERO);
- checkClassify(tree, RegionLocation.INSIDE, Vector3D.of(0.5, 0.5, 0.5));
+ EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.BOUNDARY, Vector3D.ZERO);
+ EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.INSIDE, Vector3D.of(0.5, 0.5, 0.5));
}
@Test
@@ -437,12 +436,12 @@ public class RegionBSPTree3DTest {
Assert.assertEquals(6, tree.getBoundarySize(), TEST_EPS);
Assert.assertNull(tree.getBarycenter());
- checkClassify(tree, RegionLocation.INSIDE,
+ EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.INSIDE,
Vector3D.of(-Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE),
Vector3D.of(-100, -100, -100),
Vector3D.of(100, 100, 100),
Vector3D.of(Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE));
- checkClassify(tree, RegionLocation.OUTSIDE,
+ EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.OUTSIDE,
Vector3D.of(0, 0, 0));
}
@@ -461,7 +460,7 @@ public class RegionBSPTree3DTest {
Assert.assertEquals(6.0, tree.getBoundarySize(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.ZERO, tree.getBarycenter(), TEST_EPS);
- checkClassify(tree, RegionLocation.OUTSIDE,
+ EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.OUTSIDE,
Vector3D.of(-1, 0, 0),
Vector3D.of(1, 0, 0),
Vector3D.of(0, -1, 0),
@@ -478,7 +477,7 @@ public class RegionBSPTree3DTest {
Vector3D.of(-1, -1, 1),
Vector3D.of(-1, -1, -1));
- checkClassify(tree, RegionLocation.BOUNDARY,
+ EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.BOUNDARY,
Vector3D.of(0.5, 0, 0),
Vector3D.of(-0.5, 0, 0),
Vector3D.of(0, 0.5, 0),
@@ -495,7 +494,7 @@ public class RegionBSPTree3DTest {
Vector3D.of(-0.5, -0.5, 0.5),
Vector3D.of(-0.5, -0.5, -0.5));
- checkClassify(tree, RegionLocation.INSIDE,
+ EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.INSIDE,
Vector3D.of(0, 0, 0),
Vector3D.of(0.4, 0.4, 0.4),
@@ -527,12 +526,12 @@ public class RegionBSPTree3DTest {
Assert.assertEquals(12.0, tree.getBoundarySize(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(1, 0, 0), tree.getBarycenter(), TEST_EPS);
- checkClassify(tree, RegionLocation.OUTSIDE,
+ EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.OUTSIDE,
Vector3D.of(-1, 0, 0),
Vector3D.of(1, 0, 0),
Vector3D.of(3, 0, 0));
- checkClassify(tree, RegionLocation.INSIDE,
+ EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.INSIDE,
Vector3D.of(0, 0, 0),
Vector3D.of(2, 0, 0));
}
@@ -556,11 +555,11 @@ public class RegionBSPTree3DTest {
Assert.assertEquals(10.0, tree.getBoundarySize(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(0.5, 0, 0), tree.getBarycenter(), TEST_EPS);
- checkClassify(tree, RegionLocation.OUTSIDE,
+ EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.OUTSIDE,
Vector3D.of(-1, 0, 0),
Vector3D.of(2, 0, 0));
- checkClassify(tree, RegionLocation.INSIDE,
+ EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.INSIDE,
Vector3D.of(0, 0, 0),
Vector3D.of(1, 0, 0));
}
@@ -588,11 +587,11 @@ public class RegionBSPTree3DTest {
Assert.assertEquals(10.0, tree.getBoundarySize(), eps);
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(0.5 + 5.208e-8, 0, 0), tree.getBarycenter(), TEST_EPS);
- checkClassify(tree, RegionLocation.OUTSIDE,
+ EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.OUTSIDE,
Vector3D.of(-1, 0, 0),
Vector3D.of(2, 0, 0));
- checkClassify(tree, RegionLocation.INSIDE,
+ EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.INSIDE,
Vector3D.of(0, 0, 0),
Vector3D.of(1, 0, 0));
}
@@ -617,13 +616,13 @@ public class RegionBSPTree3DTest {
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(0.5, 0.5, 0), tree.getBarycenter(), TEST_EPS);
- checkClassify(tree, RegionLocation.OUTSIDE,
+ EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.OUTSIDE,
Vector3D.of(-1, 0, 0),
Vector3D.of(1, 0, 0),
Vector3D.of(0, 1, 0),
Vector3D.of(2, 1, 0));
- checkClassify(tree, RegionLocation.INSIDE,
+ EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.INSIDE,
Vector3D.of(0, 0, 0),
Vector3D.of(1, 1, 0));
}
@@ -647,13 +646,13 @@ public class RegionBSPTree3DTest {
Assert.assertEquals(12.0, tree.getBoundarySize(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(0.5, 0.5, 0.5), tree.getBarycenter(), TEST_EPS);
- checkClassify(tree, RegionLocation.OUTSIDE,
+ EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.OUTSIDE,
Vector3D.of(-1, 0, 0),
Vector3D.of(1, 0, 0),
Vector3D.of(0, 1, 1),
Vector3D.of(2, 1, 1));
- checkClassify(tree, RegionLocation.INSIDE,
+ EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.INSIDE,
Vector3D.of(0, 0, 0),
Vector3D.of(1, 1, 1));
}
@@ -680,14 +679,14 @@ public class RegionBSPTree3DTest {
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(1.5, 2.5, 3.5), tree.getBarycenter(), TEST_EPS);
double third = 1.0 / 3.0;
- checkClassify(tree, RegionLocation.BOUNDARY,
+ EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.BOUNDARY,
vertex1, vertex2, vertex3, vertex4,
Vector3D.linearCombination(third, vertex1, third, vertex2, third, vertex3),
Vector3D.linearCombination(third, vertex2, third, vertex3, third, vertex4),
Vector3D.linearCombination(third, vertex3, third, vertex4, third, vertex1),
Vector3D.linearCombination(third, vertex4, third, vertex1, third, vertex2)
);
- checkClassify(tree, RegionLocation.OUTSIDE,
+ EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.OUTSIDE,
Vector3D.of(1, 2, 4),
Vector3D.of(2, 2, 3),
Vector3D.of(2, 3, 4),
@@ -713,7 +712,7 @@ public class RegionBSPTree3DTest {
Assert.assertEquals(sphereSurface(radius), tree.getBoundarySize(), approximationTolerance);
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(1, 2, 3), tree.getBarycenter(), TEST_EPS);
- checkClassify(tree, RegionLocation.OUTSIDE,
+ EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.OUTSIDE,
Vector3D.of(-0.1, 2, 3),
Vector3D.of(2.1, 2, 3),
Vector3D.of(1, 0.9, 3),
@@ -722,7 +721,7 @@ public class RegionBSPTree3DTest {
Vector3D.of(1, 2, 4.1),
Vector3D.of(1.6, 2.6, 3.6));
- checkClassify(tree, RegionLocation.INSIDE,
+ EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.INSIDE,
Vector3D.of(1, 2, 3),
Vector3D.of(0.1, 2, 3),
Vector3D.of(1.9, 2, 3),
@@ -792,7 +791,7 @@ public class RegionBSPTree3DTest {
Assert.assertEquals(cubeSurface(size) - circleSurface(radius) + (0.5 * sphereSurface(radius)),
result.getBoundarySize(), tolerance);
- checkClassify(result, RegionLocation.OUTSIDE,
+ EuclideanTestUtils.assertRegionLocation(result, RegionLocation.OUTSIDE,
Vector3D.of(-0.1, 0.5, 0.5),
Vector3D.of(1.1, 0.5, 0.5),
Vector3D.of(0.5, -0.1, 0.5),
@@ -800,7 +799,7 @@ public class RegionBSPTree3DTest {
Vector3D.of(0.5, 0.5, -0.1),
Vector3D.of(0.5, 0.5, 1.6));
- checkClassify(result, RegionLocation.INSIDE,
+ EuclideanTestUtils.assertRegionLocation(result, RegionLocation.INSIDE,
Vector3D.of(0.1, 0.5, 0.5),
Vector3D.of(0.9, 0.5, 0.5),
Vector3D.of(0.5, 0.1, 0.5),
@@ -832,7 +831,7 @@ public class RegionBSPTree3DTest {
Assert.assertEquals(sphereSurface(radius), result.getBoundarySize(), tolerance);
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.ZERO, result.getBarycenter(), TEST_EPS);
- checkClassify(result, RegionLocation.OUTSIDE,
+ EuclideanTestUtils.assertRegionLocation(result, RegionLocation.OUTSIDE,
Vector3D.of(-1.1, 0, 0),
Vector3D.of(1.1, 0, 0),
Vector3D.of(0, -1.1, 0),
@@ -840,7 +839,7 @@ public class RegionBSPTree3DTest {
Vector3D.of(0, 0, -1.1),
Vector3D.of(0, 0, 1.1));
- checkClassify(result, RegionLocation.INSIDE,
+ EuclideanTestUtils.assertRegionLocation(result, RegionLocation.INSIDE,
Vector3D.of(-0.9, 0, 0),
Vector3D.of(0.9, 0, 0),
Vector3D.of(0, -0.9, 0),
@@ -869,11 +868,11 @@ public class RegionBSPTree3DTest {
Assert.assertFalse(result.isEmpty());
Assert.assertFalse(result.isFull());
- Assert.assertEquals((sphereVolume(radius) * 0.5), result.getSize(), tolerance);
+ Assert.assertEquals(sphereVolume(radius) * 0.5, result.getSize(), tolerance);
Assert.assertEquals(circleSurface(radius) + (0.5 * sphereSurface(radius)),
result.getBoundarySize(), tolerance);
- checkClassify(result, RegionLocation.OUTSIDE,
+ EuclideanTestUtils.assertRegionLocation(result, RegionLocation.OUTSIDE,
Vector3D.of(-0.1, 0.5, 1.0),
Vector3D.of(1.1, 0.5, 1.0),
Vector3D.of(0.5, -0.1, 1.0),
@@ -881,7 +880,7 @@ public class RegionBSPTree3DTest {
Vector3D.of(0.5, 0.5, 0.4),
Vector3D.of(0.5, 0.5, 1.1));
- checkClassify(result, RegionLocation.INSIDE,
+ EuclideanTestUtils.assertRegionLocation(result, RegionLocation.INSIDE,
Vector3D.of(0.1, 0.5, 0.9),
Vector3D.of(0.9, 0.5, 0.9),
Vector3D.of(0.5, 0.1, 0.9),
@@ -912,7 +911,7 @@ public class RegionBSPTree3DTest {
Assert.assertEquals(sphereSurface(radius), result.getBoundarySize(), tolerance);
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.ZERO, result.getBarycenter(), TEST_EPS);
- checkClassify(result, RegionLocation.OUTSIDE,
+ EuclideanTestUtils.assertRegionLocation(result, RegionLocation.OUTSIDE,
Vector3D.of(-1.1, 0, 0),
Vector3D.of(1.1, 0, 0),
Vector3D.of(0, -1.1, 0),
@@ -920,7 +919,7 @@ public class RegionBSPTree3DTest {
Vector3D.of(0, 0, -1.1),
Vector3D.of(0, 0, 1.1));
- checkClassify(result, RegionLocation.INSIDE,
+ EuclideanTestUtils.assertRegionLocation(result, RegionLocation.INSIDE,
Vector3D.of(-0.9, 0, 0),
Vector3D.of(0.9, 0, 0),
Vector3D.of(0, -0.9, 0),
@@ -952,18 +951,18 @@ public class RegionBSPTree3DTest {
Assert.assertEquals((2 * cubeVolume(size)) - (2 * cubeVolume(size * 0.5)), result.getSize(), TEST_EPS);
Assert.assertEquals(2 * cubeSurface(size), result.getBoundarySize(), TEST_EPS);
- checkClassify(result, RegionLocation.OUTSIDE,
+ EuclideanTestUtils.assertRegionLocation(result, RegionLocation.OUTSIDE,
Vector3D.of(-0.1, -0.1, -0.1),
Vector3D.of(0.75, 0.75, 0.75),
Vector3D.of(1.6, 1.6, 1.6));
- checkClassify(result, RegionLocation.BOUNDARY,
+ EuclideanTestUtils.assertRegionLocation(result, RegionLocation.BOUNDARY,
Vector3D.of(0, 0, 0),
Vector3D.of(0.5, 0.5, 0.5),
Vector3D.of(1, 1, 1),
Vector3D.of(1.5, 1.5, 1.5));
- checkClassify(result, RegionLocation.INSIDE,
+ EuclideanTestUtils.assertRegionLocation(result, RegionLocation.INSIDE,
Vector3D.of(0.1, 0.1, 0.1),
Vector3D.of(0.4, 0.4, 0.4),
Vector3D.of(1.1, 1.1, 1.1),
@@ -993,7 +992,7 @@ public class RegionBSPTree3DTest {
Assert.assertEquals(cubeSurface(size) + (sphereSurface(radius)),
result.getBoundarySize(), tolerance);
- checkClassify(result, RegionLocation.OUTSIDE,
+ EuclideanTestUtils.assertRegionLocation(result, RegionLocation.OUTSIDE,
Vector3D.of(-0.1, 0.5, 0.5),
Vector3D.of(1.1, 0.5, 0.5),
Vector3D.of(0.5, -0.1, 0.5),
@@ -1002,7 +1001,7 @@ public class RegionBSPTree3DTest {
Vector3D.of(0.5, 0.5, 1.6),
Vector3D.of(0.5, 0.5, 0.9));
- checkClassify(result, RegionLocation.INSIDE,
+ EuclideanTestUtils.assertRegionLocation(result, RegionLocation.INSIDE,
Vector3D.of(0.1, 0.5, 0.5),
Vector3D.of(0.9, 0.5, 0.5),
Vector3D.of(0.5, 0.1, 0.5),
@@ -1032,7 +1031,7 @@ public class RegionBSPTree3DTest {
Assert.assertEquals(0.0, result.getBoundarySize(), TEST_EPS);
Assert.assertNull(result.getBarycenter());
- checkClassify(result, RegionLocation.OUTSIDE,
+ EuclideanTestUtils.assertRegionLocation(result, RegionLocation.OUTSIDE,
Vector3D.of(-1.1, 0, 0),
Vector3D.of(1.1, 0, 0),
Vector3D.of(0, -1.1, 0),
@@ -1071,7 +1070,7 @@ public class RegionBSPTree3DTest {
Assert.assertEquals(cubeSurface(size) - circleSurface(radius) + (0.5 * sphereSurface(radius)),
result.getBoundarySize(), tolerance);
- checkClassify(result, RegionLocation.OUTSIDE,
+ EuclideanTestUtils.assertRegionLocation(result, RegionLocation.OUTSIDE,
Vector3D.of(-0.1, 0.5, 1.0),
Vector3D.of(1.1, 0.5, 1.0),
Vector3D.of(0.5, -0.1, 1.0),
@@ -1079,7 +1078,7 @@ public class RegionBSPTree3DTest {
Vector3D.of(0.5, 0.5, -0.1),
Vector3D.of(0.5, 0.5, 0.6));
- checkClassify(result, RegionLocation.INSIDE,
+ EuclideanTestUtils.assertRegionLocation(result, RegionLocation.INSIDE,
Vector3D.of(0.1, 0.5, 0.4),
Vector3D.of(0.9, 0.5, 0.4),
Vector3D.of(0.5, 0.1, 0.4),
@@ -1108,7 +1107,7 @@ public class RegionBSPTree3DTest {
Assert.assertEquals(0.0, result.getBoundarySize(), TEST_EPS);
Assert.assertNull(result.getBarycenter());
- checkClassify(result, RegionLocation.OUTSIDE,
+ EuclideanTestUtils.assertRegionLocation(result, RegionLocation.OUTSIDE,
Vector3D.of(-1.1, 0, 0),
Vector3D.of(1.1, 0, 0),
Vector3D.of(0, -1.1, 0),
@@ -1152,7 +1151,7 @@ public class RegionBSPTree3DTest {
Assert.assertEquals(cubeSurface(size) - (3.0 * circleSurface(radius)) + (1.5 * sphereSurface(radius)),
result.getBoundarySize(), tolerance);
- checkClassify(result, RegionLocation.OUTSIDE,
+ EuclideanTestUtils.assertRegionLocation(result, RegionLocation.OUTSIDE,
Vector3D.of(-0.1, 0.5, 0.5),
Vector3D.of(1.1, 0.5, 0.5),
Vector3D.of(0.5, 0.4, 0.5),
@@ -1160,7 +1159,7 @@ public class RegionBSPTree3DTest {
Vector3D.of(0.5, 0.5, -0.1),
Vector3D.of(0.5, 0.5, 1.6));
- checkClassify(result, RegionLocation.INSIDE,
+ EuclideanTestUtils.assertRegionLocation(result, RegionLocation.INSIDE,
Vector3D.of(0.1, 0.5, 0.1),
Vector3D.of(0.9, 0.5, 0.1),
Vector3D.of(0.5, 0.4, 0.1),
@@ -1297,7 +1296,7 @@ public class RegionBSPTree3DTest {
// act
Assert.assertEquals(2 + 2 + 6 + 6 + 24 + 24, tree.getSize(), TEST_EPS);
- checkClassify(tree, RegionLocation.INSIDE,
+ EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.INSIDE,
Vector3D.of(1, 0.5, 0.5),
Vector3D.of(-0.5, -1, -1.5),
@@ -1307,7 +1306,7 @@ public class RegionBSPTree3DTest {
Vector3D.of(0, 0, 15),
Vector3D.of(0, 0, 20));
- checkClassify(tree, RegionLocation.BOUNDARY,
+ EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.BOUNDARY,
Vector3D.of(-1, -1.5, 13),
Vector3D.of(1, 1.5, 17),
@@ -1354,11 +1353,11 @@ public class RegionBSPTree3DTest {
// assert
Assert.assertEquals(8 + 27, tree.getSize(), TEST_EPS);
- checkClassify(tree, RegionLocation.INSIDE,
+ EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.INSIDE,
Vector3D.of(2, 1, 1),
Vector3D.of(-2, -3, -4));
- checkClassify(tree, RegionLocation.BOUNDARY,
+ EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.BOUNDARY,
Vector3D.of(-3.5, -4.5, -5.5),
Vector3D.of(-0.5, -1.5, -2.5));
}
@@ -1382,36 +1381,36 @@ public class RegionBSPTree3DTest {
@Test
public void testBuilder_addIndexedFacets_triangles() {
// arrange
- Vector3D vertices[] = {
- Vector3D.ZERO,
- Vector3D.of(1, 0, 0),
- Vector3D.of(1, 1, 0),
- Vector3D.of(0, 1, 0),
-
- Vector3D.of(0, 0, 1),
- Vector3D.of(1, 0, 1),
- Vector3D.of(1, 1, 1),
- Vector3D.of(0, 1, 1)
+ Vector3D[] vertices = {
+ Vector3D.ZERO,
+ Vector3D.of(1, 0, 0),
+ Vector3D.of(1, 1, 0),
+ Vector3D.of(0, 1, 0),
+
+ Vector3D.of(0, 0, 1),
+ Vector3D.of(1, 0, 1),
+ Vector3D.of(1, 1, 1),
+ Vector3D.of(0, 1, 1)
};
int[][] facets = {
- { 0, 3, 2 },
- { 0, 2, 1 },
+ {0, 3, 2},
+ {0, 2, 1},
- { 4, 5, 6 },
- { 4, 6, 7 },
+ {4, 5, 6},
+ {4, 6, 7},
- { 5, 1, 2 },
- { 5, 2, 6 },
+ {5, 1, 2},
+ {5, 2, 6},
- { 4, 7, 3 },
- { 4, 3, 0 },
+ {4, 7, 3},
+ {4, 3, 0},
- { 4, 0, 1 },
- { 4, 1, 5 },
+ {4, 0, 1},
+ {4, 1, 5},
- { 7, 6, 2 },
- { 7, 2, 3 }
+ {7, 6, 2},
+ {7, 2, 3}
};
// act
@@ -1447,12 +1446,12 @@ public class RegionBSPTree3DTest {
};
int[][] facets = {
- { 0, 2, 3, 1 },
- { 4, 5, 3, 2 },
- { 0, 1, 7, 6 },
- { 4, 6, 7, 5 },
- { 0, 6, 4, 2 },
- { 1, 3, 5, 7 }
+ {0, 2, 3, 1},
+ {4, 5, 3, 2},
+ {0, 1, 7, 6},
+ {4, 6, 7, 5},
+ {0, 6, 4, 2},
+ {1, 3, 5, 7}
};
// act
@@ -1469,8 +1468,8 @@ public class RegionBSPTree3DTest {
Assert.assertTrue(Double.isFinite(tree.getBoundarySize()));
Assert.assertNotNull(tree.getBarycenter());
- checkClassify(tree, RegionLocation.INSIDE, Vector3D.of(0, 1.5, 0.5));
- checkClassify(tree, RegionLocation.OUTSIDE, Vector3D.of(0, 0.5, 0.5));
+ EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.INSIDE, Vector3D.of(0, 1.5, 0.5));
+ EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.OUTSIDE, Vector3D.of(0, 0.5, 0.5));
}
@Test
@@ -1489,22 +1488,22 @@ public class RegionBSPTree3DTest {
.withVertexList(p0, p1, p2, p3)
.addIndexedFacet(0, 2, 1)
.addIndexedFacets(new int[][] {
- { 0, 1, 3 },
- { 0, 3, 2 }
+ {0, 1, 3},
+ {0, 3, 2}
})
.build();
// assert
Assert.assertEquals(0.5 / 3.0, tree.getSize(), TEST_EPS);
- checkClassify(tree, RegionLocation.INSIDE, Vector3D.of(0.25, 0.25, 0.25));
+ EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.INSIDE, Vector3D.of(0.25, 0.25, 0.25));
}
// GEOMETRY-59
@Test
public void testSlightlyConcavePrism() {
// arrange
- Vector3D vertices[] = {
+ Vector3D[] vertices = {
Vector3D.of(0, 0, 0),
Vector3D.of(2, 1e-7, 0),
Vector3D.of(4, 0, 0),
@@ -1515,13 +1514,13 @@ public class RegionBSPTree3DTest {
Vector3D.of(2, 2, 2)
};
- int facets[][] = {
- { 4, 5, 6, 7 },
- { 3, 2, 1, 0 },
- { 0, 1, 5, 4 },
- { 1, 2, 6, 5 },
- { 2, 3, 7, 6 },
- { 3, 0, 4, 7 }
+ int[][] facets = {
+ {4, 5, 6, 7},
+ {3, 2, 1, 0},
+ {0, 1, 5, 4},
+ {1, 2, 6, 5},
+ {2, 3, 7, 6},
+ {3, 0, 4, 7}
};
// act
@@ -1534,8 +1533,8 @@ public class RegionBSPTree3DTest {
Assert.assertFalse(tree.isFull());
Assert.assertFalse(tree.isEmpty());
- checkClassify(tree, RegionLocation.INSIDE, Vector3D.of(2, 1, 1));
- checkClassify(tree, RegionLocation.OUTSIDE,
+ EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.INSIDE, Vector3D.of(2, 1, 1));
+ EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.OUTSIDE,
Vector3D.of(2, 1, 3), Vector3D.of(2, 1, -3),
Vector3D.of(2, -1, 1), Vector3D.of(2, 3, 1),
Vector3D.of(-1, 1, 1), Vector3D.of(4, 1, 1));
@@ -1568,14 +1567,14 @@ public class RegionBSPTree3DTest {
Vector3D norm;
vAngle = -0.5 * vDelta;
- for (int v=0; v<stacks; ++v) {
+ for (int v = 0; v < stacks; ++v) {
vAngle += vDelta;
stackRadius = Math.sin(vAngle) * adjustedRadius;
stackHeight = Math.cos(vAngle) * adjustedRadius;
hAngle = -0.5 * hDelta;
- for (int h=0; h<slices; ++h) {
+ for (int h = 0; h < slices; ++h) {
hAngle += hDelta;
x = Math.cos(hAngle) * stackRadius;
@@ -1602,31 +1601,23 @@ public class RegionBSPTree3DTest {
EuclideanTestUtils.assertCoordinatesEqual(expectedNormal, sub.getPlane().getNormal(), TEST_EPS);
}
- private static void checkClassify(Region<Vector3D> region, RegionLocation loc, Vector3D ... points) {
- for (Vector3D point : points) {
- String msg = "Unexpected location for point " + point;
-
- Assert.assertEquals(msg, loc, region.classify(point));
- }
- }
-
- private double cubeVolume(double size) {
+ private static double cubeVolume(double size) {
return size * size * size;
}
- private double cubeSurface(double size) {
+ private static double cubeSurface(double size) {
return 6.0 * size * size;
}
- private double sphereVolume(double radius) {
+ private static double sphereVolume(double radius) {
return 4.0 * Math.PI * radius * radius * radius / 3.0;
}
- private double sphereSurface(double radius) {
+ private static double sphereSurface(double radius) {
return 4.0 * Math.PI * radius * radius;
}
- private double circleSurface(double radius) {
+ private static double circleSurface(double radius) {
return Math.PI * radius * radius;
}
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/SphericalCoordinatesTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/SphericalCoordinatesTest.java
index 2acd8d2..e429723 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/SphericalCoordinatesTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/SphericalCoordinatesTest.java
@@ -81,7 +81,7 @@ public class SphericalCoordinatesTest {
}
private void checkOfWithAngleWrapAround(double radius, double azimuth, double polar) {
- for (int i=-4; i<=4; ++i) {
+ for (int i = -4; i <= 4; ++i) {
checkSpherical(
SphericalCoordinates.of(radius, azimuth + (i * PlaneAngleRadians.TWO_PI), polar + (-i * PlaneAngleRadians.TWO_PI)),
radius, azimuth, polar);
@@ -327,7 +327,7 @@ public class SphericalCoordinatesTest {
Pattern pattern = Pattern.compile("\\(1.{0,2}, 2.{0,2}, 3.{0,2}\\)");
// act
- String str = sph.toString();;
+ String str = sph.toString();
// assert
Assert.assertTrue("Expected string " + str + " to match regex " + pattern,
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/SubPlaneTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/SubPlaneTest.java
index b50bf51..d40811e 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/SubPlaneTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/SubPlaneTest.java
@@ -471,7 +471,7 @@ public class SubPlaneTest {
}, IllegalArgumentException.class);
}
- private static void checkPoints(SubPlane sp, RegionLocation loc, Vector3D ... pts) {
+ private static void checkPoints(SubPlane sp, RegionLocation loc, Vector3D... pts) {
for (Vector3D pt : pts) {
Assert.assertEquals("Unexpected subplane location for point " + pt, loc, sp.classify(pt));
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Vector3DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Vector3DTest.java
index 793b3e5..d58a14d 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Vector3DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Vector3DTest.java
@@ -287,8 +287,7 @@ public class Vector3DTest {
checkVector(Vector3D.Unit.MINUS_Y.withNorm(3.14), 0.0, -3.14, 0.0);
checkVector(Vector3D.Unit.PLUS_Z.withNorm(-1.1), 0.0, 0.0, -1.1);
- for (double mag = -10.0; mag <= 10.0; ++mag)
- {
+ for (double mag = -10.0; mag <= 10.0; ++mag) {
Assert.assertEquals(Math.abs(mag), v.withNorm(mag).norm(), EPS);
}
}
@@ -576,7 +575,7 @@ public class Vector3DTest {
checkVector(Vector3D.of(2, 1, -4).cross(Vector3D.of(3, 1, -1)), 3, -10, -1);
double invSqrt6 = 1 / Math.sqrt(6);
- checkVector(Vector3D.of(1, 1, 1).cross(Vector3D.of(-1, 0, 1)).normalize(), invSqrt6, - 2 * invSqrt6, invSqrt6);
+ checkVector(Vector3D.of(1, 1, 1).cross(Vector3D.of(-1, 0, 1)).normalize(), invSqrt6, -2 * invSqrt6, invSqrt6);
}
@Test
@@ -588,15 +587,15 @@ public class Vector3DTest {
// instead of the correct [0.0006913, -0.0001254, -0.0007909]
// arrange
- final Vector3D u1 = Vector3D.of(-1321008684645961.0 / 268435456.0,
- -5774608829631843.0 / 268435456.0,
- -7645843051051357.0 / 8589934592.0);
- final Vector3D u2 = Vector3D.of( 1796571811118507.0 / 2147483648.0,
- 7853468008299307.0 / 2147483648.0,
+ final Vector3D u1 = Vector3D.of(-1321008684645961.0 / 268435456.0,
+ -5774608829631843.0 / 268435456.0,
+ -7645843051051357.0 / 8589934592.0);
+ final Vector3D u2 = Vector3D.of(1796571811118507.0 / 2147483648.0,
+ 7853468008299307.0 / 2147483648.0,
2599586637357461.0 / 17179869184.0);
final Vector3D u3 = Vector3D.of(12753243807587107.0 / 18446744073709551616.0,
-2313766922703915.0 / 18446744073709551616.0,
- -227970081415313.0 / 288230376151711744.0);
+ -227970081415313.0 / 288230376151711744.0);
// act
Vector3D cNaive = Vector3D.of(u1.getY() * u2.getZ() - u1.getZ() * u2.getY(),
@@ -613,7 +612,7 @@ public class Vector3DTest {
public void testCrossProduct_accuracy() {
// we compare accurate versus naive cross product implementations
// on regular vectors (i.e. not extreme cases like in the previous test)
- UniformRandomProvider random = RandomSource.create(RandomSource.WELL_1024_A, 885362227452043215l);
+ UniformRandomProvider random = RandomSource.create(RandomSource.WELL_1024_A, 885362227452043215L);
for (int i = 0; i < 10000; ++i) {
// arrange
double ux = 10000 * random.nextDouble();
@@ -703,7 +702,7 @@ public class Vector3DTest {
Assert.assertEquals(132, v1.distanceSq(v3), EPS);
Assert.assertEquals(132, v3.distanceSq(v1), EPS);
- }
+ }
@Test
public void testDotProduct() {
@@ -749,7 +748,7 @@ public class Vector3DTest {
public void testDotProduct_accuracy() {
// we compare accurate versus naive dot product implementations
// on regular vectors (i.e. not extreme cases like in the previous test)
- UniformRandomProvider random = RandomSource.create(RandomSource.WELL_1024_A, 553267312521321237l);
+ UniformRandomProvider random = RandomSource.create(RandomSource.WELL_1024_A, 553267312521321237L);
for (int i = 0; i < 10000; ++i) {
// arrange
double ux = 10000 * random.nextDouble();
@@ -895,8 +894,7 @@ public class Vector3DTest {
// base is pi/2 (which means that the projection is the zero vector)
if (angle < PlaneAngleRadians.PI_OVER_TWO) {
Assert.assertEquals(0.0, proj.angle(base), eps);
- }
- else if (angle > PlaneAngleRadians.PI_OVER_TWO) {
+ } else if (angle > PlaneAngleRadians.PI_OVER_TWO) {
Assert.assertEquals(PlaneAngleRadians.PI, proj.angle(base), eps);
}
@@ -1161,18 +1159,18 @@ public class Vector3DTest {
@Test
public void testOf_arrayArg() {
// act/assert
- checkVector(Vector3D.of(new double[] { 1, 2, 3 }), 1, 2, 3);
- checkVector(Vector3D.of(new double[] { -1, -2, -3 }), -1, -2, -3);
- checkVector(Vector3D.of(new double[] { Math.PI, Double.NaN, Double.POSITIVE_INFINITY }),
+ checkVector(Vector3D.of(new double[] {1, 2, 3}), 1, 2, 3);
+ checkVector(Vector3D.of(new double[] {-1, -2, -3}), -1, -2, -3);
+ checkVector(Vector3D.of(new double[] {Math.PI, Double.NaN, Double.POSITIVE_INFINITY}),
Math.PI, Double.NaN, Double.POSITIVE_INFINITY);
- checkVector(Vector3D.of(new double[] { Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, Math.E}),
+ checkVector(Vector3D.of(new double[] {Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, Math.E}),
Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, Math.E);
}
@Test(expected = IllegalArgumentException.class)
public void testOf_arrayArg_invalidDimensions() {
// act/assert
- Vector3D.of(new double[] { 0.0, 0.0 });
+ Vector3D.of(new double[] {0.0, 0.0});
}
@Test
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/rotation/AxisAngleSequenceTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/rotation/AxisAngleSequenceTest.java
index e470a7d..05a3e6e 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/rotation/AxisAngleSequenceTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/rotation/AxisAngleSequenceTest.java
@@ -43,7 +43,7 @@ public class AxisAngleSequenceTest {
double[] angles = seq.getAngles();
// assert
- Assert.assertArrayEquals(new double[] { 1, 2, 3 }, angles, 0.0);
+ Assert.assertArrayEquals(new double[] {1, 2, 3}, angles, 0.0);
}
@Test
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/rotation/AxisSequenceTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/rotation/AxisSequenceTest.java
index 25bf641..060eb2e 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/rotation/AxisSequenceTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/rotation/AxisSequenceTest.java
@@ -44,7 +44,7 @@ public class AxisSequenceTest {
Assert.assertEquals(a2, axes.getAxis2());
Assert.assertEquals(a3, axes.getAxis3());
- Assert.assertArrayEquals(new Vector3D[] { a1, a2, a3 }, axes.toArray());
+ Assert.assertArrayEquals(new Vector3D[] {a1, a2, a3}, axes.toArray());
}
private Vector3D getAxisForName(String name) {
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/rotation/QuaternionRotationTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/rotation/QuaternionRotationTest.java
index 636971e..0be0763 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/rotation/QuaternionRotationTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/rotation/QuaternionRotationTest.java
@@ -125,8 +125,7 @@ public class QuaternionRotationTest {
}
@Test
- public void testGetAxis()
- {
+ public void testGetAxis() {
// act/assert
checkVector(QuaternionRotation.of(0, 1, 0, 0).getAxis(), 1, 0, 0);
checkVector(QuaternionRotation.of(0, -1, 0, 0).getAxis(), -1, 0, 0);
@@ -394,7 +393,7 @@ public class QuaternionRotationTest {
QuaternionRotation q2 = QuaternionRotation.fromAxisAngle(PLUS_DIAGONAL, oneThird * PlaneAngleRadians.PI);
QuaternionRotation q3 = QuaternionRotation.fromAxisAngle(MINUS_DIAGONAL, 0.4 * PlaneAngleRadians.PI);
QuaternionRotation q4 = QuaternionRotation.fromAxisAngle(PLUS_DIAGONAL, 0.3 * PlaneAngleRadians.PI);
- QuaternionRotation q5 = QuaternionRotation.fromAxisAngle(MINUS_DIAGONAL, - oneThird * PlaneAngleRadians.PI);
+ QuaternionRotation q5 = QuaternionRotation.fromAxisAngle(MINUS_DIAGONAL, -oneThird * PlaneAngleRadians.PI);
// act
QuaternionRotation result = q1.multiply(q2).multiply(q3).multiply(q4).multiply(q5);
@@ -421,7 +420,7 @@ public class QuaternionRotationTest {
assertRotationEquals(StandardRotations.PLUS_DIAGONAL_TWO_THIRDS_PI, result);
- assertRotationEquals((v) -> {
+ assertRotationEquals(v -> {
Vector3D temp = StandardRotations.PLUS_Y_HALF_PI.apply(v);
return StandardRotations.PLUS_X_HALF_PI.apply(temp);
}, result);
@@ -438,7 +437,7 @@ public class QuaternionRotationTest {
QuaternionRotation result = q3.multiply(q2).multiply(q1);
// assert
- assertRotationEquals((v) -> {
+ assertRotationEquals(v -> {
Vector3D temp = StandardRotations.PLUS_X_HALF_PI.apply(v);
temp = StandardRotations.Y_PI.apply(temp);
return StandardRotations.MINUS_Z_HALF_PI.apply(temp);
@@ -456,7 +455,7 @@ public class QuaternionRotationTest {
UniformRandomProvider rand = RandomSource.create(RandomSource.JDK, 2L);
// act
- for (int i=0; i<slices; ++i) {
+ for (int i = 0; i < slices; ++i) {
double angle = rand.nextDouble();
QuaternionRotation forward = QuaternionRotation.fromAxisAngle(PLUS_DIAGONAL, angle);
QuaternionRotation backward = QuaternionRotation.fromAxisAngle(PLUS_DIAGONAL, delta - angle);
@@ -495,7 +494,7 @@ public class QuaternionRotationTest {
QuaternionRotation q2 = QuaternionRotation.fromAxisAngle(PLUS_DIAGONAL, oneThird * PlaneAngleRadians.PI);
QuaternionRotation q3 = QuaternionRotation.fromAxisAngle(MINUS_DIAGONAL, 0.4 * PlaneAngleRadians.PI);
QuaternionRotation q4 = QuaternionRotation.fromAxisAngle(PLUS_DIAGONAL, 0.3 * PlaneAngleRadians.PI);
- QuaternionRotation q5 = QuaternionRotation.fromAxisAngle(MINUS_DIAGONAL, - oneThird * PlaneAngleRadians.PI);
+ QuaternionRotation q5 = QuaternionRotation.fromAxisAngle(MINUS_DIAGONAL, -oneThird * PlaneAngleRadians.PI);
// act
QuaternionRotation result = q1.premultiply(q2).premultiply(q3).premultiply(q4).premultiply(q5);
@@ -522,7 +521,7 @@ public class QuaternionRotationTest {
assertRotationEquals(StandardRotations.PLUS_DIAGONAL_TWO_THIRDS_PI, result);
- assertRotationEquals((v) -> {
+ assertRotationEquals(v -> {
Vector3D temp = StandardRotations.PLUS_Y_HALF_PI.apply(v);
return StandardRotations.PLUS_X_HALF_PI.apply(temp);
}, result);
@@ -539,7 +538,7 @@ public class QuaternionRotationTest {
QuaternionRotation result = q1.premultiply(q2).premultiply(q3);
// assert
- assertRotationEquals((v) -> {
+ assertRotationEquals(v -> {
Vector3D temp = StandardRotations.PLUS_X_HALF_PI.apply(v);
temp = StandardRotations.Y_PI.apply(temp);
return StandardRotations.MINUS_Z_HALF_PI.apply(temp);
@@ -595,8 +594,8 @@ public class QuaternionRotationTest {
// act/assert
// test each rotation against all of the others (including itself)
- for (int i=0; i<rotations.length; ++i) {
- for (int j=0; j<rotations.length; ++j) {
+ for (int i = 0; i < rotations.length; ++i) {
+ for (int j = 0; j < rotations.length; ++j) {
checkSlerpCombination(rotations[i], rotations[j]);
}
}
@@ -823,8 +822,8 @@ public class QuaternionRotationTest {
public void testAxisAngleSequenceConversion_relative_eulerSingularities() {
// arrange
double[] eulerSingularities = {
- 0.0,
- PlaneAngleRadians.PI
+ 0.0,
+ PlaneAngleRadians.PI
};
double angle1 = 0.1;
@@ -833,7 +832,7 @@ public class QuaternionRotationTest {
AxisReferenceFrame frame = AxisReferenceFrame.RELATIVE;
for (AxisSequence axes : getAxes(AxisSequenceType.EULER)) {
- for (int i=0; i<eulerSingularities.length; ++i) {
+ for (int i = 0; i < eulerSingularities.length; ++i) {
double singularityAngle = eulerSingularities[i];
@@ -860,8 +859,8 @@ public class QuaternionRotationTest {
public void testAxisAngleSequenceConversion_absolute_eulerSingularities() {
// arrange
double[] eulerSingularities = {
- 0.0,
- PlaneAngleRadians.PI
+ 0.0,
+ PlaneAngleRadians.PI
};
double angle1 = 0.1;
@@ -870,7 +869,7 @@ public class QuaternionRotationTest {
AxisReferenceFrame frame = AxisReferenceFrame.ABSOLUTE;
for (AxisSequence axes : getAxes(AxisSequenceType.EULER)) {
- for (int i=0; i<eulerSingularities.length; ++i) {
+ for (int i = 0; i < eulerSingularities.length; ++i) {
double singularityAngle = eulerSingularities[i];
@@ -897,8 +896,8 @@ public class QuaternionRotationTest {
public void testAxisAngleSequenceConversion_relative_taitBryanSingularities() {
// arrange
double[] taitBryanSingularities = {
- -PlaneAngleRadians.PI_OVER_TWO,
- PlaneAngleRadians.PI_OVER_TWO
+ -PlaneAngleRadians.PI_OVER_TWO,
+ PlaneAngleRadians.PI_OVER_TWO
};
double angle1 = 0.1;
@@ -907,7 +906,7 @@ public class QuaternionRotationTest {
AxisReferenceFrame frame = AxisReferenceFrame.RELATIVE;
for (AxisSequence axes : getAxes(AxisSequenceType.TAIT_BRYAN)) {
- for (int i=0; i<taitBryanSingularities.length; ++i) {
+ for (int i = 0; i < taitBryanSingularities.length; ++i) {
double singularityAngle = taitBryanSingularities[i];
@@ -934,8 +933,8 @@ public class QuaternionRotationTest {
public void testAxisAngleSequenceConversion_absolute_taitBryanSingularities() {
// arrange
double[] taitBryanSingularities = {
- -PlaneAngleRadians.PI_OVER_TWO,
- PlaneAngleRadians.PI_OVER_TWO
+ -PlaneAngleRadians.PI_OVER_TWO,
+ PlaneAngleRadians.PI_OVER_TWO
};
double angle1 = 0.1;
@@ -944,7 +943,7 @@ public class QuaternionRotationTest {
AxisReferenceFrame frame = AxisReferenceFrame.ABSOLUTE;
for (AxisSequence axes : getAxes(AxisSequenceType.TAIT_BRYAN)) {
- for (int i=0; i<taitBryanSingularities.length; ++i) {
+ for (int i = 0; i < taitBryanSingularities.length; ++i) {
double singularityAngle = taitBryanSingularities[i];
@@ -1576,8 +1575,8 @@ public class QuaternionRotationTest {
}
private static void checkQuaternion(QuaternionRotation qrot, double w, double x, double y, double z) {
- String msg = "Expected"
- + " quaternion to equal " + SimpleTupleFormat.getDefault().format(w, x, y, z) + " but was " + qrot;
+ String msg = "Expected" +
+ " quaternion to equal " + SimpleTupleFormat.getDefault().format(w, x, y, z) + " but was " + qrot;
Assert.assertEquals(msg, w, qrot.getQuaternion().getW(), EPS);
Assert.assertEquals(msg, x, qrot.getQuaternion().getX(), EPS);
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/rotation/StandardRotations.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/rotation/StandardRotations.java
index 1b94378..f1b2986 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/rotation/StandardRotations.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/rotation/StandardRotations.java
@@ -24,43 +24,46 @@ import org.apache.commons.geometry.euclidean.threed.Vector3D;
* A collection of standard vector rotation operators implemented as
* {@link UnaryOperator}s. These can be used to test rotation algorithms.
*/
-public class StandardRotations {
+public final class StandardRotations {
/** The identity rotation; the input vector is returned unchanged. */
- public static UnaryOperator<Vector3D> IDENTITY = (v) -> v;
+ public static final UnaryOperator<Vector3D> IDENTITY = v -> v;
/** Rotates {@code pi/2} around the {@code +x} axis */
- public static UnaryOperator<Vector3D> PLUS_X_HALF_PI = (v) -> Vector3D.of(v.getX(), -v.getZ(), v.getY());
+ public static final UnaryOperator<Vector3D> PLUS_X_HALF_PI = v -> Vector3D.of(v.getX(), -v.getZ(), v.getY());
/** Rotates {@code pi/2} around the {@code -x} axis */
- public static UnaryOperator<Vector3D> MINUS_X_HALF_PI = (v) -> Vector3D.of(v.getX(), v.getZ(), -v.getY());
+ public static final UnaryOperator<Vector3D> MINUS_X_HALF_PI = v -> Vector3D.of(v.getX(), v.getZ(), -v.getY());
/** Rotates {@code pi} around the {@code x} axis (+x and -x are the same) */
- public static UnaryOperator<Vector3D> X_PI = (v) -> Vector3D.of(v.getX(), -v.getY(), -v.getZ());
+ public static final UnaryOperator<Vector3D> X_PI = v -> Vector3D.of(v.getX(), -v.getY(), -v.getZ());
/** Rotates {@code pi/2} around the {@code +y} axis */
- public static UnaryOperator<Vector3D> PLUS_Y_HALF_PI = (v) -> Vector3D.of(v.getZ(), v.getY(), -v.getX());
+ public static final UnaryOperator<Vector3D> PLUS_Y_HALF_PI = v -> Vector3D.of(v.getZ(), v.getY(), -v.getX());
/** Rotates {@code pi/2} around the {@code -y} axis */
- public static UnaryOperator<Vector3D> MINUS_Y_HALF_PI = (v) -> Vector3D.of(-v.getZ(), v.getY(), v.getX());
+ public static final UnaryOperator<Vector3D> MINUS_Y_HALF_PI = v -> Vector3D.of(-v.getZ(), v.getY(), v.getX());
/** Rotates {@code pi} around the {@code y} axis (+y and -y are the same) */
- public static UnaryOperator<Vector3D> Y_PI = (v) -> Vector3D.of(-v.getX(), v.getY(), -v.getZ());
+ public static final UnaryOperator<Vector3D> Y_PI = v -> Vector3D.of(-v.getX(), v.getY(), -v.getZ());
/** Rotates {@code pi/2} around the {@code -y} axis */
- public static UnaryOperator<Vector3D> PLUS_Z_HALF_PI = (v) -> Vector3D.of(-v.getY(), v.getX(), v.getZ());
+ public static final UnaryOperator<Vector3D> PLUS_Z_HALF_PI = v -> Vector3D.of(-v.getY(), v.getX(), v.getZ());
/** Rotates {@code pi/2} around the {@code -y} axis */
- public static UnaryOperator<Vector3D> MINUS_Z_HALF_PI = (v) -> Vector3D.of(v.getY(), -v.getX(), v.getZ());
+ public static final UnaryOperator<Vector3D> MINUS_Z_HALF_PI = v -> Vector3D.of(v.getY(), -v.getX(), v.getZ());
/** Rotates {@code pi} around the {@code y} axis (+y and -y are the same) */
- public static UnaryOperator<Vector3D> Z_PI = (v) -> Vector3D.of(-v.getX(), -v.getY(), v.getZ());
+ public static final UnaryOperator<Vector3D> Z_PI = v -> Vector3D.of(-v.getX(), -v.getY(), v.getZ());
/** Rotates {@code 2pi/3} around the {@code (1, 1, 1)} axis */
- public static UnaryOperator<Vector3D> PLUS_DIAGONAL_TWO_THIRDS_PI = (v) ->
+ public static final UnaryOperator<Vector3D> PLUS_DIAGONAL_TWO_THIRDS_PI = v ->
Vector3D.of(v.getZ(), v.getX(), v.getY());
/** Rotates {@code 2pi/3} around the {@code (-1, -1, -1)} axis */
- public static UnaryOperator<Vector3D> MINUS_DIAGONAL_TWO_THIRDS_PI = (v) ->
+ public static final UnaryOperator<Vector3D> MINUS_DIAGONAL_TWO_THIRDS_PI = v ->
Vector3D.of(v.getY(), v.getZ(), v.getX());
+
+ /** Private constructor. */
+ private StandardRotations() {}
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/AbstractSegmentConnectorTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/AbstractSegmentConnectorTest.java
index 9a9681c..0120706 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/AbstractSegmentConnectorTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/AbstractSegmentConnectorTest.java
@@ -533,22 +533,21 @@ public class AbstractSegmentConnectorTest {
return segments;
}
- private static void assertFinitePath(Polyline path, Vector2D ... vertices)
- {
+ private static void assertFinitePath(Polyline path, Vector2D... vertices) {
Assert.assertFalse(path.isInfinite());
Assert.assertTrue(path.isFinite());
assertPathVertices(path, vertices);
}
- private static void assertPathVertices(Polyline path, Vector2D ... vertices) {
+ private static void assertPathVertices(Polyline path, Vector2D... vertices) {
List<Vector2D> expectedVertices = Arrays.asList(vertices);
List<Vector2D> actualVertices = path.getVertices();
String msg = "Expected path vertices to equal " + expectedVertices + " but was " + actualVertices;
Assert.assertEquals(msg, expectedVertices.size(), actualVertices.size());
- for (int i=0; i<expectedVertices.size(); ++i) {
+ for (int i = 0; i < expectedVertices.size(); ++i) {
EuclideanTestUtils.assertCoordinatesEqual(expectedVertices.get(i), actualVertices.get(i), TEST_EPS);
}
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/AffineTransformMatrix2DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/AffineTransformMatrix2DTest.java
index 88c3a6c..86f89cb 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/AffineTransformMatrix2DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/AffineTransformMatrix2DTest.java
@@ -30,8 +30,8 @@ public class AffineTransformMatrix2DTest {
public void testOf() {
// arrange
double[] arr = {
- 1, 2, 3,
- 4, 5, 6
+ 1, 2, 3,
+ 4, 5, 6
};
// act
@@ -61,8 +61,8 @@ public class AffineTransformMatrix2DTest {
// assert
Assert.assertArrayEquals(new double[] {
- 1, 3, 0,
- 2, 4, 0
+ 1, 3, 0,
+ 2, 4, 0
}, transform.toArray(), 0.0);
}
@@ -78,8 +78,8 @@ public class AffineTransformMatrix2DTest {
// assert
Assert.assertArrayEquals(new double[] {
- 1, 3, 5,
- 2, 4, 6
+ 1, 3, 5,
+ 2, 4, 6
}, transform.toArray(), 0.0);
}
@@ -90,8 +90,8 @@ public class AffineTransformMatrix2DTest {
// assert
double[] expected = {
- 1, 0, 0,
- 0, 1, 0
+ 1, 0, 0,
+ 0, 1, 0
};
Assert.assertArrayEquals(expected, transform.toArray(), 0.0);
}
@@ -103,8 +103,8 @@ public class AffineTransformMatrix2DTest {
// assert
double[] expected = {
- 1, 0, 2,
- 0, 1, 3
+ 1, 0, 2,
+ 0, 1, 3
};
Assert.assertArrayEquals(expected, transform.toArray(), 0.0);
}
@@ -116,8 +116,8 @@ public class AffineTransformMatrix2DTest {
// assert
double[] expected = {
- 1, 0, 5,
- 0, 1, 6
+ 1, 0, 5,
+ 0, 1, 6
};
Assert.assertArrayEquals(expected, transform.toArray(), 0.0);
}
@@ -129,8 +129,8 @@ public class AffineTransformMatrix2DTest {
// assert
double[] expected = {
- 2, 0, 0,
- 0, 3, 0
+ 2, 0, 0,
+ 0, 3, 0
};
Assert.assertArrayEquals(expected, transform.toArray(), 0.0);
}
@@ -148,8 +148,8 @@ public class AffineTransformMatrix2DTest {
// assert
double[] expected = {
- 2, 0, 14,
- 0, 3, 16
+ 2, 0, 14,
+ 0, 3, 16
};
Assert.assertArrayEquals(expected, result.toArray(), 0.0);
}
@@ -167,8 +167,8 @@ public class AffineTransformMatrix2DTest {
// assert
double[] expected = {
- 2, 0, 17,
- 0, 3, 19
+ 2, 0, 17,
+ 0, 3, 19
};
Assert.assertArrayEquals(expected, result.toArray(), 0.0);
}
@@ -180,8 +180,8 @@ public class AffineTransformMatrix2DTest {
// assert
double[] expected = {
- 4, 0, 0,
- 0, 5, 0
+ 4, 0, 0,
+ 0, 5, 0
};
Assert.assertArrayEquals(expected, transform.toArray(), 0.0);
}
@@ -193,8 +193,8 @@ public class AffineTransformMatrix2DTest {
// assert
double[] expected = {
- 7, 0, 0,
- 0, 7, 0
+ 7, 0, 0,
+ 0, 7, 0
};
Assert.assertArrayEquals(expected, transform.toArray(), 0.0);
}
@@ -212,8 +212,8 @@ public class AffineTransformMatrix2DTest {
// assert
double[] expected = {
- 8, 0, 40,
- 0, 15, 55
+ 8, 0, 40,
+ 0, 15, 55
};
Assert.assertArrayEquals(expected, result.toArray(), 0.0);
}
@@ -231,8 +231,8 @@ public class AffineTransformMatrix2DTest {
// assert
double[] expected = {
- 14, 0, 70,
- 0, 24, 88
+ 14, 0, 70,
+ 0, 24, 88
};
Assert.assertArrayEquals(expected, result.toArray(), 0.0);
}
@@ -250,8 +250,8 @@ public class AffineTransformMatrix2DTest {
// assert
double[] expected = {
- 20, 0, 100,
- 0, 30, 110
+ 20, 0, 100,
+ 0, 30, 110
};
Assert.assertArrayEquals(expected, result.toArray(), 0.0);
}
@@ -267,8 +267,8 @@ public class AffineTransformMatrix2DTest {
double cos = Math.cos(angle);
double[] expected = {
- cos, -sin, 0,
- sin, cos, 0
+ cos, -sin, 0,
+ sin, cos, 0
};
Assert.assertArrayEquals(expected, transform.toArray(), EPS);
}
@@ -285,8 +285,8 @@ public class AffineTransformMatrix2DTest {
double cos = Math.cos(angle);
double[] expected = {
- cos, -sin, -cos + 2*sin + 1,
- sin, cos, -sin - 2*cos + 2
+ cos, -sin, -cos + (2 * sin) + 1,
+ sin, cos, -sin - (2 * cos) + 2
};
Assert.assertArrayEquals(expected, transform.toArray(), EPS);
}
@@ -304,8 +304,8 @@ public class AffineTransformMatrix2DTest {
// assert
double[] expected = {
- -4, -5, -6,
- 1, 2, 3
+ -4, -5, -6,
+ 1, 2, 3
};
Assert.assertArrayEquals(expected, result.toArray(), EPS);
}
@@ -325,8 +325,8 @@ public class AffineTransformMatrix2DTest {
// assert
double[] expected = {
- -4, -5, -3,
- 1, 2, 4
+ -4, -5, -3,
+ 1, 2, 4
};
Assert.assertArrayEquals(expected, result.toArray(), EPS);
}
@@ -701,8 +701,8 @@ public class AffineTransformMatrix2DTest {
// assert
double[] arr = result.toArray();
Assert.assertArrayEquals(new double[] {
- 47, 50, 56,
- 167, 178, 196
+ 47, 50, 56,
+ 167, 178, 196
}, arr, EPS);
}
@@ -752,8 +752,8 @@ public class AffineTransformMatrix2DTest {
// assert
double[] arr = result.toArray();
Assert.assertArrayEquals(new double[] {
- 47, 50, 56,
- 167, 178, 196
+ 47, 50, 56,
+ 167, 178, 196
}, arr, EPS);
}
@@ -792,8 +792,8 @@ public class AffineTransformMatrix2DTest {
// assert
double[] expected = {
- 1, 0, 0,
- 0, 1, 0
+ 1, 0, 0,
+ 0, 1, 0
};
Assert.assertArrayEquals(expected, inverse.toArray(), 0.0);
}
@@ -813,8 +813,8 @@ public class AffineTransformMatrix2DTest {
// assert
double[] expected = {
- 1, 0, 0,
- 0, 1, 0
+ 1, 0, 0,
+ 0, 1, 0
};
Assert.assertArrayEquals(expected, result.toArray(), EPS);
}
@@ -829,8 +829,8 @@ public class AffineTransformMatrix2DTest {
// assert
double[] expected = {
- 1, 0, -1,
- 0, 1, 2
+ 1, 0, -1,
+ 0, 1, 2
};
Assert.assertArrayEquals(expected, inverse.toArray(), 0.0);
}
@@ -845,8 +845,8 @@ public class AffineTransformMatrix2DTest {
// assert
double[] expected = {
- 0.1, 0, 0,
- 0, -0.5, 0
+ 0.1, 0, 0,
+ 0, -0.5, 0
};
Assert.assertArrayEquals(expected, inverse.toArray(), 0.0);
}
@@ -861,8 +861,8 @@ public class AffineTransformMatrix2DTest {
// assert
double[] expected = {
- 0, 1, 0,
- -1, 0, 0
+ 0, 1, 0,
+ -1, 0, 0
};
Assert.assertArrayEquals(expected, inverse.toArray(), EPS);
}
@@ -878,8 +878,8 @@ public class AffineTransformMatrix2DTest {
// assert
double[] expected = {
- 0, 1, -1,
- -1, 0, 3
+ 0, 1, -1,
+ -1, 0, 3
};
Assert.assertArrayEquals(expected, inverse.toArray(), EPS);
}
@@ -973,13 +973,13 @@ public class AffineTransformMatrix2DTest {
Assert.assertEquals(orig, same);
double[] temp;
- for (int i=0; i<values.length; ++i) {
- temp = values.clone();
- temp[i] = 0;
+ for (int i = 0; i < values.length; ++i) {
+ temp = values.clone();
+ temp[i] = 0;
- int modified = AffineTransformMatrix2D.of(temp).hashCode();
+ int modified = AffineTransformMatrix2D.of(temp).hashCode();
- Assert.assertNotEquals(orig, modified);
+ Assert.assertNotEquals(orig, modified);
}
}
@@ -1000,13 +1000,13 @@ public class AffineTransformMatrix2DTest {
Assert.assertFalse(a.equals(new Object()));
double[] temp;
- for (int i=0; i<values.length; ++i) {
- temp = values.clone();
- temp[i] = 0;
+ for (int i = 0; i < values.length; ++i) {
+ temp = values.clone();
+ temp[i] = 0;
- AffineTransformMatrix2D modified = AffineTransformMatrix2D.of(temp);
+ AffineTransformMatrix2D modified = AffineTransformMatrix2D.of(temp);
- Assert.assertFalse(a.equals(modified));
+ Assert.assertFalse(a.equals(modified));
}
}
@@ -1022,12 +1022,13 @@ public class AffineTransformMatrix2DTest {
String result = a.toString();
// assert
- Assert.assertEquals("[ 1.0, 2.0, 3.0; "
- + "5.0, 6.0, 7.0 ]", result);
+ Assert.assertEquals(
+ "[ 1.0, 2.0, 3.0; " +
+ "5.0, 6.0, 7.0 ]", result);
}
@FunctionalInterface
- private static interface Coordinate2DTest {
+ private interface Coordinate2DTest {
void run(double x, double y);
}
@@ -1037,8 +1038,7 @@ public class AffineTransformMatrix2DTest {
runWithCoordinates(test, -1e2, 1e2, 5);
}
- private static void runWithCoordinates(Coordinate2DTest test, double min, double max, double step)
- {
+ private static void runWithCoordinates(Coordinate2DTest test, double min, double max, double step) {
for (double x = min; x <= max; x += step) {
for (double y = min; y <= max; y += step) {
test.run(x, y);
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/ConvexAreaTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/ConvexAreaTest.java
index c961f28..339af22 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/ConvexAreaTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/ConvexAreaTest.java
@@ -141,9 +141,9 @@ public class ConvexAreaTest {
Assert.assertEquals(6, transformed.getBoundarySize(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(1.5, 3), transformed.getBarycenter(), TEST_EPS);
- checkRegion(transformed, RegionLocation.BOUNDARY,
+ EuclideanTestUtils.assertRegionLocation(transformed, RegionLocation.BOUNDARY,
Vector2D.of(1, 2), Vector2D.of(2, 2), Vector2D.of(2, 4), Vector2D.of(1, 4));
- checkRegion(transformed, RegionLocation.INSIDE, transformed.getBarycenter());
+ EuclideanTestUtils.assertRegionLocation(transformed, RegionLocation.INSIDE, transformed.getBarycenter());
}
@Test
@@ -169,9 +169,9 @@ public class ConvexAreaTest {
Assert.assertEquals(6, transformed.getBoundarySize(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(-1.5, 3), transformed.getBarycenter(), TEST_EPS);
- checkRegion(transformed, RegionLocation.BOUNDARY,
+ EuclideanTestUtils.assertRegionLocation(transformed, RegionLocation.BOUNDARY,
Vector2D.of(-1, 2), Vector2D.of(-2, 2), Vector2D.of(-2, 4), Vector2D.of(-1, 4));
- checkRegion(transformed, RegionLocation.INSIDE, transformed.getBarycenter());
+ EuclideanTestUtils.assertRegionLocation(transformed, RegionLocation.INSIDE, transformed.getBarycenter());
}
@Test
@@ -197,9 +197,9 @@ public class ConvexAreaTest {
Assert.assertEquals(6, transformed.getBoundarySize(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(-1.5, -3), transformed.getBarycenter(), TEST_EPS);
- checkRegion(transformed, RegionLocation.BOUNDARY,
+ EuclideanTestUtils.assertRegionLocation(transformed, RegionLocation.BOUNDARY,
Vector2D.of(-1, -2), Vector2D.of(-2, -2), Vector2D.of(-2, -4), Vector2D.of(-1, -4));
- checkRegion(transformed, RegionLocation.INSIDE, transformed.getBarycenter());
+ EuclideanTestUtils.assertRegionLocation(transformed, RegionLocation.INSIDE, transformed.getBarycenter());
}
@Test
@@ -393,7 +393,7 @@ public class ConvexAreaTest {
Assert.assertNull(minus.getBarycenter());
List<Segment> minusSegments = minus.getBoundaries();
- Assert.assertEquals(1,minusSegments.size());
+ Assert.assertEquals(1, minusSegments.size());
Assert.assertEquals(splitter, minusSegments.get(0).getLine());
ConvexArea plus = split.getPlus();
@@ -775,7 +775,7 @@ public class ConvexAreaTest {
Vector2D.of(1, 1),
Vector2D.Unit.PLUS_X,
Vector2D.ZERO
- ),TEST_PRECISION);
+ ), TEST_PRECISION);
}, IllegalArgumentException.class);
}
@@ -892,7 +892,7 @@ public class ConvexAreaTest {
Vector2D.Unit.PLUS_Y,
Vector2D.of(1, 1),
Vector2D.Unit.PLUS_X
- ),TEST_PRECISION);
+ ), TEST_PRECISION);
}, IllegalArgumentException.class);
}
@@ -909,7 +909,7 @@ public class ConvexAreaTest {
public void testFromPath_infinite() {
// act
ConvexArea area = ConvexArea.fromPath(Polyline.fromVertices(
- Arrays.asList(Vector2D.ZERO, Vector2D.Unit.PLUS_X),TEST_PRECISION));
+ Arrays.asList(Vector2D.ZERO, Vector2D.Unit.PLUS_X), TEST_PRECISION));
// assert
Assert.assertFalse(area.isFull());
@@ -919,9 +919,9 @@ public class ConvexAreaTest {
GeometryTestUtils.assertPositiveInfinity(area.getSize());
Assert.assertNull(area.getBarycenter());
- checkRegion(area, RegionLocation.INSIDE, Vector2D.Unit.PLUS_Y);
- checkRegion(area, RegionLocation.BOUNDARY, Vector2D.ZERO);
- checkRegion(area, RegionLocation.OUTSIDE, Vector2D.Unit.MINUS_Y);
+ EuclideanTestUtils.assertRegionLocation(area, RegionLocation.INSIDE, Vector2D.Unit.PLUS_Y);
+ EuclideanTestUtils.assertRegionLocation(area, RegionLocation.BOUNDARY, Vector2D.ZERO);
+ EuclideanTestUtils.assertRegionLocation(area, RegionLocation.OUTSIDE, Vector2D.Unit.MINUS_Y);
}
@Test
@@ -933,7 +933,7 @@ public class ConvexAreaTest {
Vector2D.Unit.PLUS_X,
Vector2D.of(1, 1),
Vector2D.Unit.PLUS_Y
- ),TEST_PRECISION));
+ ), TEST_PRECISION));
// assert
Assert.assertFalse(area.isFull());
@@ -954,7 +954,7 @@ public class ConvexAreaTest {
Vector2D.Unit.PLUS_Y,
Vector2D.of(1, 1),
Vector2D.Unit.PLUS_X
- ),TEST_PRECISION));
+ ), TEST_PRECISION));
}, IllegalArgumentException.class);
}
@@ -987,9 +987,9 @@ public class ConvexAreaTest {
Assert.assertEquals(1, segments.size());
Assert.assertSame(line, segments.get(0).getLine());
- checkRegion(area, RegionLocation.INSIDE, Vector2D.of(-1, 1), Vector2D.of(0, 2));
- checkRegion(area, RegionLocation.BOUNDARY, Vector2D.of(0, 1), Vector2D.of(2, 5));
- checkRegion(area, RegionLocation.OUTSIDE, Vector2D.ZERO, Vector2D.of(2, 3));
+ EuclideanTestUtils.assertRegionLocation(area, RegionLocation.INSIDE, Vector2D.of(-1, 1), Vector2D.of(0, 2));
+ EuclideanTestUtils.assertRegionLocation(area, RegionLocation.BOUNDARY, Vector2D.of(0, 1), Vector2D.of(2, 5));
+ EuclideanTestUtils.assertRegionLocation(area, RegionLocation.OUTSIDE, Vector2D.ZERO, Vector2D.of(2, 3));
}
@Test
@@ -1012,10 +1012,10 @@ public class ConvexAreaTest {
List<Segment> segments = area.getBoundaries();
Assert.assertEquals(2, segments.size());
- checkRegion(area, RegionLocation.INSIDE, Vector2D.of(-1, -1));
- checkRegion(area, RegionLocation.BOUNDARY,
+ EuclideanTestUtils.assertRegionLocation(area, RegionLocation.INSIDE, Vector2D.of(-1, -1));
+ EuclideanTestUtils.assertRegionLocation(area, RegionLocation.BOUNDARY,
Vector2D.ZERO, Vector2D.of(-1, 0), Vector2D.of(0, -1));
- checkRegion(area, RegionLocation.OUTSIDE,
+ EuclideanTestUtils.assertRegionLocation(area, RegionLocation.OUTSIDE,
Vector2D.of(-1, 1), Vector2D.of(1, 1), Vector2D.of(1, -1));
}
@@ -1040,10 +1040,10 @@ public class ConvexAreaTest {
List<Segment> segments = area.getBoundaries();
Assert.assertEquals(3, segments.size());
- checkRegion(area, RegionLocation.INSIDE, Vector2D.of(-0.5, -0.5));
- checkRegion(area, RegionLocation.BOUNDARY,
+ EuclideanTestUtils.assertRegionLocation(area, RegionLocation.INSIDE, Vector2D.of(-0.5, -0.5));
+ EuclideanTestUtils.assertRegionLocation(area, RegionLocation.BOUNDARY,
Vector2D.ZERO, Vector2D.of(-1, 0), Vector2D.of(0, -1));
- checkRegion(area, RegionLocation.OUTSIDE,
+ EuclideanTestUtils.assertRegionLocation(area, RegionLocation.OUTSIDE,
Vector2D.of(-1, 1), Vector2D.of(1, 1), Vector2D.of(1, -1), Vector2D.of(-2, -2));
}
@@ -1066,12 +1066,12 @@ public class ConvexAreaTest {
List<Segment> segments = area.getBoundaries();
Assert.assertEquals(4, segments.size());
- checkRegion(area, RegionLocation.INSIDE, Vector2D.of(0.5, 0.5));
- checkRegion(area, RegionLocation.BOUNDARY,
+ EuclideanTestUtils.assertRegionLocation(area, RegionLocation.INSIDE, Vector2D.of(0.5, 0.5));
+ EuclideanTestUtils.assertRegionLocation(area, RegionLocation.BOUNDARY,
Vector2D.ZERO, Vector2D.of(1, 1),
Vector2D.of(0.5, 0), Vector2D.of(0.5, 1),
Vector2D.of(0, 0.5), Vector2D.of(1, 0.5));
- checkRegion(area, RegionLocation.OUTSIDE,
+ EuclideanTestUtils.assertRegionLocation(area, RegionLocation.OUTSIDE,
Vector2D.of(-1, -1), Vector2D.of(2, 2));
}
@@ -1098,12 +1098,12 @@ public class ConvexAreaTest {
List<Segment> segments = area.getBoundaries();
Assert.assertEquals(4, segments.size());
- checkRegion(area, RegionLocation.INSIDE, Vector2D.of(0.5, 0.5));
- checkRegion(area, RegionLocation.BOUNDARY,
+ EuclideanTestUtils.assertRegionLocation(area, RegionLocation.INSIDE, Vector2D.of(0.5, 0.5));
+ EuclideanTestUtils.assertRegionLocation(area, RegionLocation.BOUNDARY,
Vector2D.ZERO, Vector2D.of(1, 1),
Vector2D.of(0.5, 0), Vector2D.of(0.5, 1),
Vector2D.of(0, 0.5), Vector2D.of(1, 0.5));
- checkRegion(area, RegionLocation.OUTSIDE,
+ EuclideanTestUtils.assertRegionLocation(area, RegionLocation.OUTSIDE,
Vector2D.of(-1, -1), Vector2D.of(2, 2));
}
@@ -1128,12 +1128,12 @@ public class ConvexAreaTest {
List<Segment> segments = area.getBoundaries();
Assert.assertEquals(4, segments.size());
- checkRegion(area, RegionLocation.INSIDE, Vector2D.of(0.5, 0.5));
- checkRegion(area, RegionLocation.BOUNDARY,
+ EuclideanTestUtils.assertRegionLocation(area, RegionLocation.INSIDE, Vector2D.of(0.5, 0.5));
+ EuclideanTestUtils.assertRegionLocation(area, RegionLocation.BOUNDARY,
Vector2D.ZERO, Vector2D.of(1, 1),
Vector2D.of(0.5, 0), Vector2D.of(0.5, 1),
Vector2D.of(0, 0.5), Vector2D.of(1, 0.5));
- checkRegion(area, RegionLocation.OUTSIDE,
+ EuclideanTestUtils.assertRegionLocation(area, RegionLocation.OUTSIDE,
Vector2D.of(-1, -1), Vector2D.of(2, 2));
}
@@ -1158,9 +1158,9 @@ public class ConvexAreaTest {
List<Segment> segments = area.getBoundaries();
Assert.assertEquals(1, segments.size());
- checkRegion(area, RegionLocation.BOUNDARY, Vector2D.of(0, 1), Vector2D.of(1, 1), Vector2D.of(-1, 1));
- checkRegion(area, RegionLocation.INSIDE, Vector2D.of(0, 2), Vector2D.of(1, 2), Vector2D.of(-1, 2));
- checkRegion(area, RegionLocation.OUTSIDE, Vector2D.of(0, 0), Vector2D.of(1, 0), Vector2D.of(-1, 0));
+ EuclideanTestUtils.assertRegionLocation(area, RegionLocation.BOUNDARY, Vector2D.of(0, 1), Vector2D.of(1, 1), Vector2D.of(-1, 1));
+ EuclideanTestUtils.assertRegionLocation(area, RegionLocation.INSIDE, Vector2D.of(0, 2), Vector2D.of(1, 2), Vector2D.of(-1, 2));
+ EuclideanTestUtils.assertRegionLocation(area, RegionLocation.OUTSIDE, Vector2D.of(0, 0), Vector2D.of(1, 0), Vector2D.of(-1, 0));
}
@Test
@@ -1188,12 +1188,6 @@ public class ConvexAreaTest {
}, IllegalArgumentException.class);
}
- private static void checkRegion(ConvexArea area, RegionLocation loc, Vector2D ... pts) {
- for (Vector2D pt : pts) {
- Assert.assertEquals("Unexpected region location for point " + pt, loc, area.classify(pt));
- }
- }
-
private static List<Line> createSquareBoundingLines(final Vector2D lowerLeft, final double width, final double height) {
final Vector2D lowerRight = Vector2D.of(lowerLeft.getX() + width, lowerLeft.getY());
final Vector2D upperRight = Vector2D.of(lowerLeft.getX() + width, lowerLeft.getY() + height);
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/FunctionTransform2DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/FunctionTransform2DTest.java
index 17cfd90..848553e 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/FunctionTransform2DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/FunctionTransform2DTest.java
@@ -135,25 +135,21 @@ public class FunctionTransform2DTest {
public void testToMatrix() {
// act/assert
Assert.assertArrayEquals(new double[] {
- 1, 0, 0,
- 0, 1, 0
- },
- FunctionTransform2D.identity().toMatrix().toArray(), TEST_EPS);
+ 1, 0, 0,
+ 0, 1, 0
+ }, FunctionTransform2D.identity().toMatrix().toArray(), TEST_EPS);
Assert.assertArrayEquals(new double[] {
- 1, 0, 2,
- 0, 1, 3
- },
- FunctionTransform2D.from(v -> v.add(Vector2D.of(2, 3))).toMatrix().toArray(), TEST_EPS);
+ 1, 0, 2,
+ 0, 1, 3
+ }, FunctionTransform2D.from(v -> v.add(Vector2D.of(2, 3))).toMatrix().toArray(), TEST_EPS);
Assert.assertArrayEquals(new double[] {
- 3, 0, 0,
- 0, 3, 0
- },
- FunctionTransform2D.from(v -> v.multiply(3)).toMatrix().toArray(), TEST_EPS);
+ 3, 0, 0,
+ 0, 3, 0
+ }, FunctionTransform2D.from(v -> v.multiply(3)).toMatrix().toArray(), TEST_EPS);
Assert.assertArrayEquals(new double[] {
- 3, 0, 6,
- 0, 3, 9
- },
- FunctionTransform2D.from(v -> v.add(Vector2D.of(2, 3)).multiply(3)).toMatrix().toArray(), TEST_EPS);
+ 3, 0, 6,
+ 0, 3, 9
+ }, FunctionTransform2D.from(v -> v.add(Vector2D.of(2, 3)).multiply(3)).toMatrix().toArray(), TEST_EPS);
}
@Test
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/InteriorAngleSegmentConnectorTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/InteriorAngleSegmentConnectorTest.java
index 88f4783..2853c57 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/InteriorAngleSegmentConnectorTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/InteriorAngleSegmentConnectorTest.java
@@ -309,8 +309,7 @@ public class InteriorAngleSegmentConnectorTest {
return segments;
}
- private static void assertInfinitePath(Polyline path, Segment start, Segment end,
- Vector2D ... vertices) {
+ private static void assertInfinitePath(Polyline path, Segment start, Segment end, Vector2D... vertices) {
Assert.assertTrue(path.isInfinite());
Assert.assertFalse(path.isFinite());
@@ -320,22 +319,21 @@ public class InteriorAngleSegmentConnectorTest {
assertPathVertices(path, vertices);
}
- private static void assertFinitePath(Polyline path, Vector2D ... vertices)
- {
+ private static void assertFinitePath(Polyline path, Vector2D... vertices) {
Assert.assertFalse(path.isInfinite());
Assert.assertTrue(path.isFinite());
assertPathVertices(path, vertices);
}
- private static void assertPathVertices(Polyline path, Vector2D ... vertices) {
+ private static void assertPathVertices(Polyline path, Vector2D... vertices) {
List<Vector2D> expectedVertices = Arrays.asList(vertices);
List<Vector2D> actualVertices = path.getVertices();
String msg = "Expected path vertices to equal " + expectedVertices + " but was " + actualVertices;
Assert.assertEquals(msg, expectedVertices.size(), actualVertices.size());
- for (int i=0; i<expectedVertices.size(); ++i) {
+ for (int i = 0; i < expectedVertices.size(); ++i) {
EuclideanTestUtils.assertCoordinatesEqual(expectedVertices.get(i), actualVertices.get(i), TEST_EPS);
}
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/LineTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/LineTest.java
index 551f0c8..66a232f 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/LineTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/LineTest.java
@@ -258,8 +258,8 @@ public class LineTest {
Line line = Line.fromPoints(Vector2D.of(-2, -2), Vector2D.of(2, 1), TEST_PRECISION);
// act/assert
- Assert.assertEquals(0.0, line.abscissa(Vector2D.of(-3, 4)), TEST_EPS);
- Assert.assertEquals(0.0, line.abscissa(Vector2D.of( 3, -4)), TEST_EPS);
+ Assert.assertEquals(0.0, line.abscissa(Vector2D.of(-3, 4)), TEST_EPS);
+ Assert.assertEquals(0.0, line.abscissa(Vector2D.of(3, -4)), TEST_EPS);
Assert.assertEquals(5.0, line.abscissa(Vector2D.of(7, -1)), TEST_EPS);
Assert.assertEquals(-5.0, line.abscissa(Vector2D.of(-1, -7)), TEST_EPS);
}
@@ -270,8 +270,8 @@ public class LineTest {
Line line = Line.fromPoints(Vector2D.of(2, 1), Vector2D.of(-2, -2), TEST_PRECISION);
// act/assert
- Assert.assertEquals(0.0, line.toSubspace(Vector2D.of(-3, 4)).getX(), TEST_EPS);
- Assert.assertEquals(0.0, line.toSubspace(Vector2D.of( 3, -4)).getX(), TEST_EPS);
+ Assert.assertEquals(0.0, line.toSubspace(Vector2D.of(-3, 4)).getX(), TEST_EPS);
+ Assert.assertEquals(0.0, line.toSubspace(Vector2D.of(3, -4)).getX(), TEST_EPS);
Assert.assertEquals(-5.0, line.toSubspace(Vector2D.of(7, -1)).getX(), TEST_EPS);
Assert.assertEquals(5.0, line.toSubspace(Vector2D.of(-1, -7)).getX(), TEST_EPS);
}
@@ -287,7 +287,7 @@ public class LineTest {
// act/assert
EuclideanTestUtils.assertCoordinatesEqual(Vector2D.ZERO, line.toSpace(Vector1D.of(0)), TEST_EPS);
- for (int i=0; i<100; ++i) {
+ for (int i = 0; i < 100; ++i) {
EuclideanTestUtils.assertCoordinatesEqual(dir.multiply(i), line.toSpace(Vector1D.of(i)), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(dir.multiply(-i), line.toSpace(Vector1D.of(-i)), TEST_EPS);
}
@@ -314,7 +314,7 @@ public class LineTest {
// act/assert
EuclideanTestUtils.assertCoordinatesEqual(origin, line.toSpace(Vector1D.of(0)), TEST_EPS);
- for (int i=0; i<100; ++i) {
+ for (int i = 0; i < 100; ++i) {
EuclideanTestUtils.assertCoordinatesEqual(origin.add(dir.multiply(i)), line.toSpace(Vector1D.of(i)), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(origin.add(dir.multiply(-i)), line.toSpace(Vector1D.of(-i)), TEST_EPS);
}
@@ -902,7 +902,7 @@ public class LineTest {
Vector2D offset1 = Vector2D.of(0.1, 0);
Vector2D offset2 = Vector2D.of(0, -0.1);
Vector2D v;
- for (double t=-2; t<=2; t+=0.1) {
+ for (double t = -2; t <= 2; t += 0.1) {
v = p1.lerp(p2, t);
Assert.assertTrue(line.contains(v));
@@ -1106,14 +1106,14 @@ public class LineTest {
SubspaceTransform st = line.subspaceTransform(transform);
// assert
- for (double x=-5.0; x<=5.0; x+=1) {
+ for (double x = -5.0; x <= 5.0; x += 1) {
Vector1D subPt = Vector1D.of(x);
Vector2D expected = transform.apply(line.toSpace(subPt));
Vector2D actual = st.getLine().toSpace(
st.getTransform().apply(subPt));
EuclideanTestUtils.assertCoordinatesEqual(expected, actual, TEST_EPS);
- };
+ }
});
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/PolarCoordinatesTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/PolarCoordinatesTest.java
index 4dc08c0..9654286 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/PolarCoordinatesTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/PolarCoordinatesTest.java
@@ -315,7 +315,7 @@ public class PolarCoordinatesTest {
Pattern pattern = Pattern.compile("\\(1.{0,2}, 2.{0,2}\\)");
// act
- String str = polar.toString();;
+ String str = polar.toString();
// assert
Assert.assertTrue("Expected string " + str + " to match regex " + pattern,
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/RegionBSPTree2DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/RegionBSPTree2DTest.java
index e377a44..d9e5fef 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/RegionBSPTree2DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/RegionBSPTree2DTest.java
@@ -44,7 +44,7 @@ public class RegionBSPTree2DTest {
new EpsilonDoublePrecisionContext(TEST_EPS);
private static final Comparator<Segment> SEGMENT_COMPARATOR =
- (a, b) -> Vector2D.COORDINATE_ASCENDING_ORDER.compare(a.getStartPoint(), b.getStartPoint());
+ (a, b) -> Vector2D.COORDINATE_ASCENDING_ORDER.compare(a.getStartPoint(), b.getStartPoint());
private static final Line X_AXIS = Line.fromPoints(Vector2D.ZERO, Vector2D.Unit.PLUS_X, TEST_PRECISION);
@@ -1187,15 +1187,13 @@ public class RegionBSPTree2DTest {
if (expectedStart != null) {
EuclideanTestUtils.assertCoordinatesEqual(expectedStart, actual.getStartPoint(), TEST_EPS);
- }
- else {
+ } else {
Assert.assertNull(actual.getStartPoint());
}
if (expectedEnd != null) {
EuclideanTestUtils.assertCoordinatesEqual(expectedEnd, actual.getEndPoint(), TEST_EPS);
- }
- else {
+ } else {
Assert.assertNull(actual.getEndPoint());
}
}
@@ -1205,7 +1203,7 @@ public class RegionBSPTree2DTest {
EuclideanTestUtils.assertCoordinatesEqual(end, segment.getEndPoint(), TEST_EPS);
}
- private static void checkClassify(Region<Vector2D> region, RegionLocation loc, Vector2D ... points) {
+ private static void checkClassify(Region<Vector2D> region, RegionLocation loc, Vector2D... points) {
for (Vector2D point : points) {
String msg = "Unexpected location for point " + point;
@@ -1222,14 +1220,14 @@ public class RegionBSPTree2DTest {
* @param path
* @param vertices
*/
- private static void checkVertices(Polyline path, Vector2D ... vertices) {
+ private static void checkVertices(Polyline path, Vector2D... vertices) {
Assert.assertTrue("Line segment path is not finite", path.isFinite());
List<Vector2D> actual = path.getVertices();
Assert.assertEquals("Vertex lists have different lengths", vertices.length, actual.size());
- for (int i=0; i<vertices.length; ++i) {
+ for (int i = 0; i < vertices.length; ++i) {
EuclideanTestUtils.assertCoordinatesEqual(vertices[i], actual.get(i), TEST_EPS);
}
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/SegmentTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/SegmentTest.java
index 3c7a57c..d1a959d 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/SegmentTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/SegmentTest.java
@@ -412,7 +412,7 @@ public class SegmentTest {
Transform2D translation = AffineTransformMatrix2D.createTranslation(-1, 1);
Transform2D rotation = AffineTransformMatrix2D.createRotation(PlaneAngleRadians.PI_OVER_TWO);
Transform2D scale = AffineTransformMatrix2D.createScale(2, 3);
- Transform2D reflect = FunctionTransform2D.from((pt) -> Vector2D.of(pt.getX(), -pt.getY()));
+ Transform2D reflect = FunctionTransform2D.from(pt -> Vector2D.of(pt.getX(), -pt.getY()));
// act/assert
checkFiniteSegment(segment.transform(translation), Vector2D.of(-1, 2), Vector2D.of(1, 4));
@@ -430,7 +430,7 @@ public class SegmentTest {
Transform2D translation = AffineTransformMatrix2D.createTranslation(-1, 1);
Transform2D rotation = AffineTransformMatrix2D.createRotation(PlaneAngleRadians.PI_OVER_TWO);
Transform2D scale = AffineTransformMatrix2D.createScale(2, 3);
- Transform2D reflect = FunctionTransform2D.from((pt) -> Vector2D.of(pt.getX(), -pt.getY()));
+ Transform2D reflect = FunctionTransform2D.from(pt -> Vector2D.of(pt.getX(), -pt.getY()));
// act/assert
checkFiniteSegment(segment.transform(translation), Vector2D.of(-1, 2), Vector2D.of(-1, 2));
@@ -448,7 +448,7 @@ public class SegmentTest {
Transform2D translation = AffineTransformMatrix2D.createTranslation(-1, 1);
Transform2D rotation = AffineTransformMatrix2D.createRotation(PlaneAngleRadians.PI_OVER_TWO);
Transform2D scale = AffineTransformMatrix2D.createScale(2, 3);
- Transform2D reflect = FunctionTransform2D.from((pt) -> Vector2D.of(pt.getX(), -pt.getY()));
+ Transform2D reflect = FunctionTransform2D.from(pt -> Vector2D.of(pt.getX(), -pt.getY()));
// act/assert
Segment translated = segment.transform(translation);
@@ -489,7 +489,7 @@ public class SegmentTest {
Transform2D translation = AffineTransformMatrix2D.createTranslation(-1, 1);
Transform2D rotation = AffineTransformMatrix2D.createRotation(PlaneAngleRadians.PI_OVER_TWO);
Transform2D scale = AffineTransformMatrix2D.createScale(2, 3);
- Transform2D reflect = FunctionTransform2D.from((pt) -> Vector2D.of(pt.getX(), -pt.getY()));
+ Transform2D reflect = FunctionTransform2D.from(pt -> Vector2D.of(pt.getX(), -pt.getY()));
// act/assert
Segment translated = segment.transform(translation);
@@ -530,7 +530,7 @@ public class SegmentTest {
Transform2D translation = AffineTransformMatrix2D.createTranslation(-1, 1);
Transform2D rotation = AffineTransformMatrix2D.createRotation(PlaneAngleRadians.PI_OVER_TWO);
Transform2D scale = AffineTransformMatrix2D.createScale(2, 3);
- Transform2D reflect = FunctionTransform2D.from((pt) -> Vector2D.of(pt.getX(), -pt.getY()));
+ Transform2D reflect = FunctionTransform2D.from(pt -> Vector2D.of(pt.getX(), -pt.getY()));
// act/assert
Segment translated = segment.transform(translation);
@@ -837,7 +837,7 @@ public class SegmentTest {
Assert.assertEquals(0, path.getSegments().size());
}
- private static void checkClassify(Segment segment, RegionLocation loc, Vector2D ... points) {
+ private static void checkClassify(Segment segment, RegionLocation loc, Vector2D... points) {
for (Vector2D pt : points) {
String msg = "Unexpected location for point " + pt;
@@ -879,16 +879,14 @@ public class SegmentTest {
if (start == null) {
Assert.assertNull(segment.getStartPoint());
- }
- else {
+ } else {
EuclideanTestUtils.assertCoordinatesEqual(start, segment.getStartPoint(), TEST_EPS);
Assert.assertEquals(line.toSubspace(segment.getStartPoint()).getX(), segment.getSubspaceStart(), TEST_EPS);
}
if (end == null) {
Assert.assertNull(segment.getEndPoint());
- }
- else {
+ } else {
EuclideanTestUtils.assertCoordinatesEqual(end, segment.getEndPoint(), TEST_EPS);
Assert.assertEquals(line.toSubspace(segment.getEndPoint()).getX(), segment.getSubspaceEnd(), TEST_EPS);
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/SubLineTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/SubLineTest.java
index abd4686..8c5c203 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/SubLineTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/SubLineTest.java
@@ -44,15 +44,16 @@ public class SubLineTest {
private static final DoublePrecisionContext TEST_PRECISION =
new EpsilonDoublePrecisionContext(TEST_EPS);
- private Line line = Line.fromPointAndDirection(Vector2D.of(0, 1), Vector2D.Unit.PLUS_X, TEST_PRECISION);
+ private static final Line DEFAULT_TEST_LINE =
+ Line.fromPointAndDirection(Vector2D.of(0, 1), Vector2D.Unit.PLUS_X, TEST_PRECISION);
@Test
public void testCtor_lineOnly() {
// act
- SubLine sub = new SubLine(line);
+ SubLine sub = new SubLine(DEFAULT_TEST_LINE);
// assert
- Assert.assertSame(line, sub.getLine());
+ Assert.assertSame(DEFAULT_TEST_LINE, sub.getLine());
Assert.assertSame(TEST_PRECISION, sub.getPrecision());
Assert.assertFalse(sub.isFull());
@@ -64,10 +65,10 @@ public class SubLineTest {
@Test
public void testCtor_lineAndBoolean() {
// act
- SubLine sub = new SubLine(line, true);
+ SubLine sub = new SubLine(DEFAULT_TEST_LINE, true);
// assert
- Assert.assertSame(line, sub.getLine());
+ Assert.assertSame(DEFAULT_TEST_LINE, sub.getLine());
Assert.assertSame(TEST_PRECISION, sub.getPrecision());
Assert.assertTrue(sub.isFull());
@@ -82,10 +83,10 @@ public class SubLineTest {
RegionBSPTree1D tree = RegionBSPTree1D.full();
// act
- SubLine sub = new SubLine(line, tree);
+ SubLine sub = new SubLine(DEFAULT_TEST_LINE, tree);
// assert
- Assert.assertSame(line, sub.getLine());
+ Assert.assertSame(DEFAULT_TEST_LINE, sub.getLine());
Assert.assertSame(tree, sub.getSubspaceRegion());
Assert.assertSame(TEST_PRECISION, sub.getPrecision());
@@ -98,7 +99,7 @@ public class SubLineTest {
@Test
public void testToConvex_full() {
// arrange
- SubLine sub = new SubLine(line, true);
+ SubLine sub = new SubLine(DEFAULT_TEST_LINE, true);
// act
List<Segment> segments = sub.toConvex();
@@ -113,7 +114,7 @@ public class SubLineTest {
@Test
public void testToConvex_empty() {
// arrange
- SubLine sub = new SubLine(line, false);
+ SubLine sub = new SubLine(DEFAULT_TEST_LINE, false);
// act
List<Segment> segments = sub.toConvex();
@@ -125,7 +126,7 @@ public class SubLineTest {
@Test
public void testToConvex_finiteAndInfiniteSegments() {
// arrange
- SubLine sub = new SubLine(line, false);
+ SubLine sub = new SubLine(DEFAULT_TEST_LINE, false);
RegionBSPTree1D tree = sub.getSubspaceRegion();
tree.add(Interval.max(-2.0, TEST_PRECISION));
tree.add(Interval.of(-1, 2, TEST_PRECISION));
@@ -647,7 +648,7 @@ public class SubLineTest {
@Test
public void testToString() {
// arrange
- SubLine sub = new SubLine(line);
+ SubLine sub = new SubLine(DEFAULT_TEST_LINE);
// act
String str = sub.toString();
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Vector2DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Vector2DTest.java
index 51f03f7..f6de371 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Vector2DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Vector2DTest.java
@@ -467,7 +467,7 @@ public class Vector2DTest {
@Test
public void testOrthogonal_fullCircle() {
- for (double az = 0.0; az<=PlaneAngleRadians.TWO_PI; az += 0.25) {
+ for (double az = 0.0; az <= PlaneAngleRadians.TWO_PI; az += 0.25) {
// arrange
Vector2D v = PolarCoordinates.toCartesian(Math.PI, az);
@@ -680,7 +680,7 @@ public class Vector2DTest {
checkVector(v1.reject(Vector2D.Unit.PLUS_Y), 3.0, 0.0);
checkVector(v1.reject(Vector2D.Unit.MINUS_Y), 3.0, 0.0);
- checkVector(v2.reject(v1), (-32.0 / 25.0), (6.0 / 25.0) * 4.0);
+ checkVector(v2.reject(v1), -32.0 / 25.0, (6.0 / 25.0) * 4.0);
}
@Test
@@ -731,8 +731,7 @@ public class Vector2DTest {
// base is pi/2 (which means that the projection is the zero vector)
if (angle < PlaneAngleRadians.PI_OVER_TWO) {
Assert.assertEquals(0.0, proj.angle(base), eps);
- }
- else if (angle > PlaneAngleRadians.PI_OVER_TWO) {
+ } else if (angle > PlaneAngleRadians.PI_OVER_TWO) {
Assert.assertEquals(PlaneAngleRadians.PI, proj.angle(base), eps);
}
@@ -975,16 +974,16 @@ public class Vector2DTest {
@Test
public void testOf_arrayArg() {
// act/assert
- checkVector(Vector2D.of(new double[] { 0, 1 }), 0, 1);
- checkVector(Vector2D.of(new double[] { -1, -2 }), -1, -2);
- checkVector(Vector2D.of(new double[] { Math.PI, Double.NaN }), Math.PI, Double.NaN);
- checkVector(Vector2D.of(new double[] { Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY }), Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY);
+ checkVector(Vector2D.of(new double[] {0, 1}), 0, 1);
+ checkVector(Vector2D.of(new double[] {-1, -2}), -1, -2);
+ checkVector(Vector2D.of(new double[] {Math.PI, Double.NaN}), Math.PI, Double.NaN);
+ checkVector(Vector2D.of(new double[] {Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY}), Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY);
}
@Test(expected = IllegalArgumentException.class)
public void testOf_arrayArg_invalidDimensions() {
// act/assert
- Vector2D.of(new double[] {0.0 });
+ Vector2D.of(new double[] {0.0});
}
@Test
diff --git a/commons-geometry-hull/src/test/java/org/apache/commons/geometry/euclidean/twod/hull/ConvexHullGenerator2DAbstractTest.java b/commons-geometry-hull/src/test/java/org/apache/commons/geometry/euclidean/twod/hull/ConvexHullGenerator2DAbstractTest.java
index 1ced9c1..4cb630f 100644
--- a/commons-geometry-hull/src/test/java/org/apache/commons/geometry/euclidean/twod/hull/ConvexHullGenerator2DAbstractTest.java
+++ b/commons-geometry-hull/src/test/java/org/apache/commons/geometry/euclidean/twod/hull/ConvexHullGenerator2DAbstractTest.java
@@ -262,56 +262,58 @@ public abstract class ConvexHullGenerator2DAbstractTest {
List<Vector2D> points = new ArrayList<>();
- int[][] data = new int[][] { { -11, -1 }, { -11, 0 }, { -11, 1 },
- { -10, -3 }, { -10, -2 }, { -10, -1 }, { -10, 0 }, { -10, 1 },
- { -10, 2 }, { -10, 3 }, { -9, -4 }, { -9, -3 }, { -9, -2 },
- { -9, -1 }, { -9, 0 }, { -9, 1 }, { -9, 2 }, { -9, 3 },
- { -9, 4 }, { -8, -5 }, { -8, -4 }, { -8, -3 }, { -8, -2 },
- { -8, -1 }, { -8, 0 }, { -8, 1 }, { -8, 2 }, { -8, 3 },
- { -8, 4 }, { -8, 5 }, { -7, -6 }, { -7, -5 }, { -7, -4 },
- { -7, -3 }, { -7, -2 }, { -7, -1 }, { -7, 0 }, { -7, 1 },
- { -7, 2 }, { -7, 3 }, { -7, 4 }, { -7, 5 }, { -7, 6 },
- { -6, -7 }, { -6, -6 }, { -6, -5 }, { -6, -4 }, { -6, -3 },
- { -6, -2 }, { -6, -1 }, { -6, 0 }, { -6, 1 }, { -6, 2 },
- { -6, 3 }, { -6, 4 }, { -6, 5 }, { -6, 6 }, { -6, 7 },
- { -5, -7 }, { -5, -6 }, { -5, -5 }, { -5, -4 }, { -5, -3 },
- { -5, -2 }, { -5, 4 }, { -5, 5 }, { -5, 6 }, { -5, 7 },
- { -4, -7 }, { -4, -6 }, { -4, -5 }, { -4, -4 }, { -4, -3 },
- { -4, -2 }, { -4, 4 }, { -4, 5 }, { -4, 6 }, { -4, 7 },
- { -3, -8 }, { -3, -7 }, { -3, -6 }, { -3, -5 }, { -3, -4 },
- { -3, -3 }, { -3, -2 }, { -3, 4 }, { -3, 5 }, { -3, 6 },
- { -3, 7 }, { -3, 8 }, { -2, -8 }, { -2, -7 }, { -2, -6 },
- { -2, -5 }, { -2, -4 }, { -2, -3 }, { -2, -2 }, { -2, 4 },
- { -2, 5 }, { -2, 6 }, { -2, 7 }, { -2, 8 }, { -1, -8 },
- { -1, -7 }, { -1, -6 }, { -1, -5 }, { -1, -4 }, { -1, -3 },
- { -1, -2 }, { -1, 4 }, { -1, 5 }, { -1, 6 }, { -1, 7 },
- { -1, 8 }, { 0, -8 }, { 0, -7 }, { 0, -6 }, { 0, -5 },
- { 0, -4 }, { 0, -3 }, { 0, -2 }, { 0, 4 }, { 0, 5 }, { 0, 6 },
- { 0, 7 }, { 0, 8 }, { 1, -8 }, { 1, -7 }, { 1, -6 }, { 1, -5 },
- { 1, -4 }, { 1, -3 }, { 1, -2 }, { 1, -1 }, { 1, 0 }, { 1, 1 },
- { 1, 2 }, { 1, 3 }, { 1, 4 }, { 1, 5 }, { 1, 6 }, { 1, 7 },
- { 1, 8 }, { 2, -8 }, { 2, -7 }, { 2, -6 }, { 2, -5 },
- { 2, -4 }, { 2, -3 }, { 2, -2 }, { 2, -1 }, { 2, 0 }, { 2, 1 },
- { 2, 2 }, { 2, 3 }, { 2, 4 }, { 2, 5 }, { 2, 6 }, { 2, 7 },
- { 2, 8 }, { 3, -8 }, { 3, -7 }, { 3, -6 }, { 3, -5 },
- { 3, -4 }, { 3, -3 }, { 3, -2 }, { 3, -1 }, { 3, 0 }, { 3, 1 },
- { 3, 2 }, { 3, 3 }, { 3, 4 }, { 3, 5 }, { 3, 6 }, { 3, 7 },
- { 3, 8 }, { 4, -7 }, { 4, -6 }, { 4, -5 }, { 4, -4 },
- { 4, -3 }, { 4, -2 }, { 4, -1 }, { 4, 0 }, { 4, 1 }, { 4, 2 },
- { 4, 3 }, { 4, 4 }, { 4, 5 }, { 4, 6 }, { 4, 7 }, { 5, -7 },
- { 5, -6 }, { 5, -5 }, { 5, -4 }, { 5, -3 }, { 5, -2 },
- { 5, -1 }, { 5, 0 }, { 5, 1 }, { 5, 2 }, { 5, 3 }, { 5, 4 },
- { 5, 5 }, { 5, 6 }, { 5, 7 }, { 6, -7 }, { 6, -6 }, { 6, -5 },
- { 6, -4 }, { 6, -3 }, { 6, -2 }, { 6, -1 }, { 6, 0 }, { 6, 1 },
- { 6, 2 }, { 6, 3 }, { 6, 4 }, { 6, 5 }, { 6, 6 }, { 6, 7 },
- { 7, -6 }, { 7, -5 }, { 7, -4 }, { 7, -3 }, { 7, -2 },
- { 7, -1 }, { 7, 0 }, { 7, 1 }, { 7, 2 }, { 7, 3 }, { 7, 4 },
- { 7, 5 }, { 7, 6 }, { 8, -5 }, { 8, -4 }, { 8, -3 }, { 8, -2 },
- { 8, -1 }, { 8, 0 }, { 8, 1 }, { 8, 2 }, { 8, 3 }, { 8, 4 },
- { 8, 5 }, { 9, -4 }, { 9, -3 }, { 9, -2 }, { 9, -1 }, { 9, 0 },
- { 9, 1 }, { 9, 2 }, { 9, 3 }, { 9, 4 }, { 10, -3 }, { 10, -2 },
- { 10, -1 }, { 10, 0 }, { 10, 1 }, { 10, 2 }, { 10, 3 },
- { 11, -1 }, { 11, 0 }, { 11, 1 } };
+ int[][] data = new int[][] {
+ {-11, -1}, {-11, 0}, {-11, 1},
+ {-10, -3}, {-10, -2}, {-10, -1}, {-10, 0}, {-10, 1},
+ {-10, 2}, {-10, 3}, {-9, -4}, {-9, -3}, {-9, -2},
+ {-9, -1}, {-9, 0}, {-9, 1}, {-9, 2}, {-9, 3},
+ {-9, 4}, {-8, -5}, {-8, -4}, {-8, -3}, {-8, -2},
+ {-8, -1}, {-8, 0}, {-8, 1}, {-8, 2}, {-8, 3},
+ {-8, 4}, {-8, 5}, {-7, -6}, {-7, -5}, {-7, -4},
+ {-7, -3}, {-7, -2}, {-7, -1}, {-7, 0}, {-7, 1},
+ {-7, 2}, {-7, 3}, {-7, 4}, {-7, 5}, {-7, 6},
+ {-6, -7}, {-6, -6}, {-6, -5}, {-6, -4}, {-6, -3},
+ {-6, -2}, {-6, -1}, {-6, 0}, {-6, 1}, {-6, 2},
+ {-6, 3}, {-6, 4}, {-6, 5}, {-6, 6}, {-6, 7},
+ {-5, -7}, {-5, -6}, {-5, -5}, {-5, -4}, {-5, -3},
+ {-5, -2}, {-5, 4}, {-5, 5}, {-5, 6}, {-5, 7},
+ {-4, -7}, {-4, -6}, {-4, -5}, {-4, -4}, {-4, -3},
+ {-4, -2}, {-4, 4}, {-4, 5}, {-4, 6}, {-4, 7},
+ {-3, -8}, {-3, -7}, {-3, -6}, {-3, -5}, {-3, -4},
+ {-3, -3}, {-3, -2}, {-3, 4}, {-3, 5}, {-3, 6},
+ {-3, 7}, {-3, 8}, {-2, -8}, {-2, -7}, {-2, -6},
+ {-2, -5}, {-2, -4}, {-2, -3}, {-2, -2}, {-2, 4},
+ {-2, 5}, {-2, 6}, {-2, 7}, {-2, 8}, {-1, -8},
+ {-1, -7}, {-1, -6}, {-1, -5}, {-1, -4}, {-1, -3},
+ {-1, -2}, {-1, 4}, {-1, 5}, {-1, 6}, {-1, 7},
+ {-1, 8}, {0, -8}, {0, -7}, {0, -6}, {0, -5},
+ {0, -4}, {0, -3}, {0, -2}, {0, 4}, {0, 5}, {0, 6},
+ {0, 7}, {0, 8}, {1, -8}, {1, -7}, {1, -6}, {1, -5},
+ {1, -4}, {1, -3}, {1, -2}, {1, -1}, {1, 0}, {1, 1},
+ {1, 2}, {1, 3}, {1, 4}, {1, 5}, {1, 6}, {1, 7},
+ {1, 8}, {2, -8}, {2, -7}, {2, -6}, {2, -5},
+ {2, -4}, {2, -3}, {2, -2}, {2, -1}, {2, 0}, {2, 1},
+ {2, 2}, {2, 3}, {2, 4}, {2, 5}, {2, 6}, {2, 7},
+ {2, 8}, {3, -8}, {3, -7}, {3, -6}, {3, -5},
+ {3, -4}, {3, -3}, {3, -2}, {3, -1}, {3, 0}, {3, 1},
+ {3, 2}, {3, 3}, {3, 4}, {3, 5}, {3, 6}, {3, 7},
+ {3, 8}, {4, -7}, {4, -6}, {4, -5}, {4, -4},
+ {4, -3}, {4, -2}, {4, -1}, {4, 0}, {4, 1}, {4, 2},
+ {4, 3}, {4, 4}, {4, 5}, {4, 6}, {4, 7}, {5, -7},
+ {5, -6}, {5, -5}, {5, -4}, {5, -3}, {5, -2},
+ {5, -1}, {5, 0}, {5, 1}, {5, 2}, {5, 3}, {5, 4},
+ {5, 5}, {5, 6}, {5, 7}, {6, -7}, {6, -6}, {6, -5},
+ {6, -4}, {6, -3}, {6, -2}, {6, -1}, {6, 0}, {6, 1},
+ {6, 2}, {6, 3}, {6, 4}, {6, 5}, {6, 6}, {6, 7},
+ {7, -6}, {7, -5}, {7, -4}, {7, -3}, {7, -2},
+ {7, -1}, {7, 0}, {7, 1}, {7, 2}, {7, 3}, {7, 4},
+ {7, 5}, {7, 6}, {8, -5}, {8, -4}, {8, -3}, {8, -2},
+ {8, -1}, {8, 0}, {8, 1}, {8, 2}, {8, 3}, {8, 4},
+ {8, 5}, {9, -4}, {9, -3}, {9, -2}, {9, -1}, {9, 0},
+ {9, 1}, {9, 2}, {9, 3}, {9, 4}, {10, -3}, {10, -2},
+ {10, -1}, {10, 0}, {10, 1}, {10, 2}, {10, 3},
+ {11, -1}, {11, 0}, {11, 1}
+ };
for (int[] line : data) {
points.add(Vector2D.of(line[0], line[1]));
@@ -320,20 +322,20 @@ public abstract class ConvexHullGenerator2DAbstractTest {
Vector2D[] referenceHull = new Vector2D[] {
Vector2D.of(-11.0, -1.0),
Vector2D.of(-10.0, -3.0),
- Vector2D.of( -6.0, -7.0),
- Vector2D.of( -3.0, -8.0),
- Vector2D.of( 3.0, -8.0),
- Vector2D.of( 6.0, -7.0),
- Vector2D.of( 10.0, -3.0),
- Vector2D.of( 11.0, -1.0),
- Vector2D.of( 11.0, 1.0),
- Vector2D.of( 10.0, 3.0),
- Vector2D.of( 6.0, 7.0),
- Vector2D.of( 3.0, 8.0),
- Vector2D.of( -3.0, 8.0),
- Vector2D.of( -6.0, 7.0),
- Vector2D.of(-10.0, 3.0),
- Vector2D.of(-11.0, 1.0),
+ Vector2D.of(-6.0, -7.0),
+ Vector2D.of(-3.0, -8.0),
+ Vector2D.of(3.0, -8.0),
+ Vector2D.of(6.0, -7.0),
+ Vector2D.of(10.0, -3.0),
+ Vector2D.of(11.0, -1.0),
+ Vector2D.of(11.0, 1.0),
+ Vector2D.of(10.0, 3.0),
+ Vector2D.of(6.0, 7.0),
+ Vector2D.of(3.0, 8.0),
+ Vector2D.of(-3.0, 8.0),
+ Vector2D.of(-6.0, 7.0),
+ Vector2D.of(-10.0, 3.0),
+ Vector2D.of(-11.0, 1.0),
};
ConvexHull2D convHull = generator.generate(points);
@@ -403,9 +405,8 @@ public abstract class ConvexHullGenerator2DAbstractTest {
final int cmp = Precision.compareTo(cross, 0.0, tolerance);
if (sign != 0 && cmp != sign) {
- if (includesCollinearPoints && cmp == 0) {
+ if (!includesCollinearPoints || cmp != 0) {
// in case of collinear points the cross product will be zero
- } else {
return false;
}
}
diff --git a/commons-geometry-hull/src/test/java/org/apache/commons/geometry/euclidean/twod/hull/MonotoneChainTest.java b/commons-geometry-hull/src/test/java/org/apache/commons/geometry/euclidean/twod/hull/MonotoneChainTest.java
index 2b91053..ec658ac 100644
--- a/commons-geometry-hull/src/test/java/org/apache/commons/geometry/euclidean/twod/hull/MonotoneChainTest.java
+++ b/commons-geometry-hull/src/test/java/org/apache/commons/geometry/euclidean/twod/hull/MonotoneChainTest.java
@@ -35,7 +35,7 @@ public class MonotoneChainTest extends ConvexHullGenerator2DAbstractTest {
// ------------------------------------------------------------------------------
- @Test(expected=IllegalStateException.class)
+ @Test(expected = IllegalStateException.class)
public void testConvergenceException() {
final Collection<Vector2D> points = new ArrayList<>();
diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/SphericalTestUtils.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/SphericalTestUtils.java
index a1aac54..b37b0d7 100644
--- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/SphericalTestUtils.java
+++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/SphericalTestUtils.java
@@ -26,7 +26,10 @@ import org.junit.Assert;
/** Class containing various test utilities for spherical space.
*/
-public class SphericalTestUtils {
+public final class SphericalTestUtils {
+
+ /** Private constructor. */
+ private SphericalTestUtils() {}
/** Assert that the given points are equal, using the specified tolerance value.
* @param expected
@@ -76,7 +79,7 @@ public class SphericalTestUtils {
* @param loc expected location of the given points
* @param pts points to test
*/
- public static void checkClassify(Region<Point2S> region, RegionLocation loc, Point2S ... pts) {
+ public static void checkClassify(Region<Point2S> region, RegionLocation loc, Point2S... pts) {
for (Point2S pt : pts) {
Assert.assertEquals("Unexpected location for point " + pt, loc, region.classify(pt));
}
diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/AngularIntervalTest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/AngularIntervalTest.java
index ce923eb..27ab4bb 100644
--- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/AngularIntervalTest.java
+++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/AngularIntervalTest.java
@@ -304,8 +304,8 @@ public class AngularIntervalTest {
// act/assert
Assert.assertFalse(AngularInterval.full().wrapsZero());
Assert.assertFalse(AngularInterval.of(0, PlaneAngleRadians.PI_OVER_TWO, TEST_PRECISION).wrapsZero());
- Assert.assertFalse(AngularInterval.of(PlaneAngleRadians.PI_OVER_TWO, PlaneAngleRadians.PI , TEST_PRECISION).wrapsZero());
- Assert.assertFalse(AngularInterval.of(PlaneAngleRadians.PI, 1.5 * PlaneAngleRadians.PI , TEST_PRECISION).wrapsZero());
+ Assert.assertFalse(AngularInterval.of(PlaneAngleRadians.PI_OVER_TWO, PlaneAngleRadians.PI, TEST_PRECISION).wrapsZero());
+ Assert.assertFalse(AngularInterval.of(PlaneAngleRadians.PI, 1.5 * PlaneAngleRadians.PI, TEST_PRECISION).wrapsZero());
Assert.assertFalse(AngularInterval.of(1.5 * PlaneAngleRadians.PI, PlaneAngleRadians.TWO_PI - 1e-5, TEST_PRECISION).wrapsZero());
Assert.assertTrue(AngularInterval.of(1.5 * PlaneAngleRadians.PI, PlaneAngleRadians.TWO_PI, TEST_PRECISION).wrapsZero());
@@ -885,7 +885,7 @@ public class AngularIntervalTest {
checkClassify(interval, RegionLocation.OUTSIDE, Point1S.of(interval.getMidPoint().getAzimuth() + PlaneAngleRadians.PI));
}
- private static void checkClassify(Region<Point1S> region, RegionLocation loc, Point1S ... pts) {
+ private static void checkClassify(Region<Point1S> region, RegionLocation loc, Point1S... pts) {
for (Point1S pt : pts) {
Assert.assertEquals("Unexpected location for point " + pt, loc, region.classify(pt));
}
diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/CutAngleTest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/CutAngleTest.java
index ea6b6eb..1bf033c 100644
--- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/CutAngleTest.java
+++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/CutAngleTest.java
@@ -542,15 +542,15 @@ public class CutAngleTest {
// act/assert
GeometryTestUtils.assertThrows(
- () -> builder.add(CutAngle.createPositiveFacing(2e-3, precision).span()),
- IllegalArgumentException.class);
+ () -> builder.add(CutAngle.createPositiveFacing(2e-3, precision).span()),
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(
- () -> builder.add(CutAngle.createNegativeFacing(2e-3, precision).span()),
- IllegalArgumentException.class);
+ () -> builder.add(CutAngle.createNegativeFacing(2e-3, precision).span()),
+ IllegalArgumentException.class);
GeometryTestUtils.assertThrows(
- () -> builder.add((SubHyperplane<Point1S>) CutAngle.createPositiveFacing(2e-3, precision).span()),
- IllegalArgumentException.class);
+ () -> builder.add((SubHyperplane<Point1S>) CutAngle.createPositiveFacing(2e-3, precision).span()),
+ IllegalArgumentException.class);
}
@Test
@@ -586,7 +586,7 @@ public class CutAngleTest {
Assert.assertEquals(offset, pt.offset(Point1S.of(az)), TEST_EPS);
}
- private static void checkClassify(CutAngle pt, HyperplaneLocation loc, double ... azimuths) {
+ private static void checkClassify(CutAngle pt, HyperplaneLocation loc, double... azimuths) {
for (double az : azimuths) {
Assert.assertEquals("Unexpected location for azimuth " + az, loc, pt.classify(Point1S.of(az)));
}
diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/Point1STest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/Point1STest.java
index 00597da..f62f075 100644
--- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/Point1STest.java
+++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/Point1STest.java
@@ -471,8 +471,7 @@ public class Point1STest {
if (pt.isFinite()) {
Assert.assertEquals(1, vec.norm(), TEST_EPS);
Assert.assertEquals(normAz, PolarCoordinates.fromCartesian(vec).getAzimuth(), TEST_EPS);
- }
- else {
+ } else {
Assert.assertNull(vec);
}
}
diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/RegionBSPTree1STest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/RegionBSPTree1STest.java
index 34f6412..db37af8 100644
--- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/RegionBSPTree1STest.java
+++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/RegionBSPTree1STest.java
@@ -335,30 +335,30 @@ public class RegionBSPTree1STest {
// act/assert
checkSimpleSplit(
- tree.split(CutAngle.createPositiveFacing(1e-6, TEST_PRECISION)),
- AngularInterval.of(0, 1e-6, TEST_PRECISION),
- AngularInterval.of(1e-6, PlaneAngleRadians.TWO_PI, TEST_PRECISION)
- );
+ tree.split(CutAngle.createPositiveFacing(1e-6, TEST_PRECISION)),
+ AngularInterval.of(0, 1e-6, TEST_PRECISION),
+ AngularInterval.of(1e-6, PlaneAngleRadians.TWO_PI, TEST_PRECISION)
+ );
checkSimpleSplit(
- tree.split(CutAngle.createNegativeFacing(PlaneAngleRadians.PI_OVER_TWO, TEST_PRECISION)),
- AngularInterval.of(PlaneAngleRadians.PI_OVER_TWO, PlaneAngleRadians.TWO_PI, TEST_PRECISION),
- AngularInterval.of(0, PlaneAngleRadians.PI_OVER_TWO, TEST_PRECISION)
- );
+ tree.split(CutAngle.createNegativeFacing(PlaneAngleRadians.PI_OVER_TWO, TEST_PRECISION)),
+ AngularInterval.of(PlaneAngleRadians.PI_OVER_TWO, PlaneAngleRadians.TWO_PI, TEST_PRECISION),
+ AngularInterval.of(0, PlaneAngleRadians.PI_OVER_TWO, TEST_PRECISION)
+ );
checkSimpleSplit(
- tree.split(CutAngle.createPositiveFacing(PlaneAngleRadians.PI, TEST_PRECISION)),
- AngularInterval.of(0, PlaneAngleRadians.PI, TEST_PRECISION),
- AngularInterval.of(PlaneAngleRadians.PI, PlaneAngleRadians.TWO_PI, TEST_PRECISION)
- );
+ tree.split(CutAngle.createPositiveFacing(PlaneAngleRadians.PI, TEST_PRECISION)),
+ AngularInterval.of(0, PlaneAngleRadians.PI, TEST_PRECISION),
+ AngularInterval.of(PlaneAngleRadians.PI, PlaneAngleRadians.TWO_PI, TEST_PRECISION)
+ );
checkSimpleSplit(
- tree.split(CutAngle.createNegativeFacing(-PlaneAngleRadians.PI_OVER_TWO, TEST_PRECISION)),
- AngularInterval.of(-PlaneAngleRadians.PI_OVER_TWO, PlaneAngleRadians.TWO_PI, TEST_PRECISION),
- AngularInterval.of(0, -PlaneAngleRadians.PI_OVER_TWO, TEST_PRECISION)
- );
+ tree.split(CutAngle.createNegativeFacing(-PlaneAngleRadians.PI_OVER_TWO, TEST_PRECISION)),
+ AngularInterval.of(-PlaneAngleRadians.PI_OVER_TWO, PlaneAngleRadians.TWO_PI, TEST_PRECISION),
+ AngularInterval.of(0, -PlaneAngleRadians.PI_OVER_TWO, TEST_PRECISION)
+ );
checkSimpleSplit(
- tree.split(CutAngle.createPositiveFacing(PlaneAngleRadians.TWO_PI - 1e-6, TEST_PRECISION)),
- AngularInterval.of(0, PlaneAngleRadians.TWO_PI - 1e-6, TEST_PRECISION),
- AngularInterval.of(PlaneAngleRadians.TWO_PI - 1e-6, PlaneAngleRadians.TWO_PI, TEST_PRECISION)
- );
+ tree.split(CutAngle.createPositiveFacing(PlaneAngleRadians.TWO_PI - 1e-6, TEST_PRECISION)),
+ AngularInterval.of(0, PlaneAngleRadians.TWO_PI - 1e-6, TEST_PRECISION),
+ AngularInterval.of(PlaneAngleRadians.TWO_PI - 1e-6, PlaneAngleRadians.TWO_PI, TEST_PRECISION)
+ );
}
@Test
@@ -370,26 +370,26 @@ public class RegionBSPTree1STest {
// act/assert
checkSimpleSplit(
- tree.split(CutAngle.createPositiveFacing(0, TEST_PRECISION)),
- null,
- twoPi
- );
+ tree.split(CutAngle.createPositiveFacing(0, TEST_PRECISION)),
+ null,
+ twoPi
+ );
checkSimpleSplit(
- tree.split(CutAngle.createNegativeFacing(0, TEST_PRECISION)),
- twoPi,
- null
- );
+ tree.split(CutAngle.createNegativeFacing(0, TEST_PRECISION)),
+ twoPi,
+ null
+ );
checkSimpleSplit(
- tree.split(CutAngle.createPositiveFacing(PlaneAngleRadians.TWO_PI - 1e-18, TEST_PRECISION)),
- null,
- twoPi
- );
+ tree.split(CutAngle.createPositiveFacing(PlaneAngleRadians.TWO_PI - 1e-18, TEST_PRECISION)),
+ null,
+ twoPi
+ );
checkSimpleSplit(
- tree.split(CutAngle.createNegativeFacing(PlaneAngleRadians.TWO_PI - 1e-18, TEST_PRECISION)),
- twoPi,
- null
- );
+ tree.split(CutAngle.createNegativeFacing(PlaneAngleRadians.TWO_PI - 1e-18, TEST_PRECISION)),
+ twoPi,
+ null
+ );
}
@Test
@@ -400,32 +400,32 @@ public class RegionBSPTree1STest {
// act
checkSimpleSplit(
- tree.split(CutAngle.createNegativeFacing(0, TEST_PRECISION)),
- interval,
- null
- );
+ tree.split(CutAngle.createNegativeFacing(0, TEST_PRECISION)),
+ interval,
+ null
+ );
checkSimpleSplit(
- tree.split(CutAngle.createNegativeFacing(-PlaneAngleRadians.TWO_PI, TEST_PRECISION)),
- interval,
- null
- );
+ tree.split(CutAngle.createNegativeFacing(-PlaneAngleRadians.TWO_PI, TEST_PRECISION)),
+ interval,
+ null
+ );
checkSimpleSplit(
- tree.split(CutAngle.createPositiveFacing(PlaneAngleRadians.TWO_PI + PlaneAngleRadians.PI_OVER_TWO, TEST_PRECISION)),
- null,
- interval
- );
+ tree.split(CutAngle.createPositiveFacing(PlaneAngleRadians.TWO_PI + PlaneAngleRadians.PI_OVER_TWO, TEST_PRECISION)),
+ null,
+ interval
+ );
checkSimpleSplit(
- tree.split(CutAngle.createPositiveFacing(1.5 * PlaneAngleRadians.PI, TEST_PRECISION)),
- interval,
- null
- );
+ tree.split(CutAngle.createPositiveFacing(1.5 * PlaneAngleRadians.PI, TEST_PRECISION)),
+ interval,
+ null
+ );
checkSimpleSplit(
- tree.split(CutAngle.createNegativeFacing(PlaneAngleRadians.PI, TEST_PRECISION)),
- AngularInterval.of(PlaneAngleRadians.PI, -PlaneAngleRadians.PI_OVER_TWO, TEST_PRECISION),
- AngularInterval.of(PlaneAngleRadians.PI_OVER_TWO, PlaneAngleRadians.PI, TEST_PRECISION)
- );
+ tree.split(CutAngle.createNegativeFacing(PlaneAngleRadians.PI, TEST_PRECISION)),
+ AngularInterval.of(PlaneAngleRadians.PI, -PlaneAngleRadians.PI_OVER_TWO, TEST_PRECISION),
+ AngularInterval.of(PlaneAngleRadians.PI_OVER_TWO, PlaneAngleRadians.PI, TEST_PRECISION)
+ );
}
@Test
@@ -527,7 +527,7 @@ public class RegionBSPTree1STest {
CutAngle splitter = CutAngle.createPositiveFacing(1, TEST_PRECISION);
// act
- Split<RegionBSPTree1S>split = tree.splitDiameter(splitter);
+ Split<RegionBSPTree1S> split = tree.splitDiameter(splitter);
// assert
Assert.assertEquals(SplitLocation.MINUS, split.getLocation());
@@ -548,7 +548,7 @@ public class RegionBSPTree1STest {
CutAngle splitter = CutAngle.createNegativeFacing(0, TEST_PRECISION);
// act
- Split<RegionBSPTree1S>split = tree.splitDiameter(splitter);
+ Split<RegionBSPTree1S> split = tree.splitDiameter(splitter);
// assert
Assert.assertEquals(SplitLocation.MINUS, split.getLocation());
@@ -572,7 +572,7 @@ public class RegionBSPTree1STest {
CutAngle splitter = CutAngle.createPositiveFacing(1, TEST_PRECISION);
// act
- Split<RegionBSPTree1S>split = tree.splitDiameter(splitter);
+ Split<RegionBSPTree1S> split = tree.splitDiameter(splitter);
// assert
Assert.assertEquals(SplitLocation.PLUS, split.getLocation());
@@ -597,7 +597,7 @@ public class RegionBSPTree1STest {
CutAngle splitter = CutAngle.createNegativeFacing(PlaneAngleRadians.PI - 1, TEST_PRECISION);
// act
- Split<RegionBSPTree1S>split = tree.splitDiameter(splitter);
+ Split<RegionBSPTree1S> split = tree.splitDiameter(splitter);
// assert
Assert.assertEquals(SplitLocation.PLUS, split.getLocation());
@@ -622,7 +622,7 @@ public class RegionBSPTree1STest {
CutAngle splitter = CutAngle.createPositiveFacing(2.5, TEST_PRECISION);
// act
- Split<RegionBSPTree1S>split = tree.splitDiameter(splitter);
+ Split<RegionBSPTree1S> split = tree.splitDiameter(splitter);
// assert
Assert.assertEquals(SplitLocation.BOTH, split.getLocation());
@@ -649,7 +649,7 @@ public class RegionBSPTree1STest {
CutAngle splitter = CutAngle.createNegativeFacing(2.5, TEST_PRECISION);
// act
- Split<RegionBSPTree1S>split = tree.splitDiameter(splitter);
+ Split<RegionBSPTree1S> split = tree.splitDiameter(splitter);
// assert
Assert.assertEquals(SplitLocation.BOTH, split.getLocation());
@@ -876,8 +876,7 @@ public class RegionBSPTree1STest {
if (minusInterval != null) {
Assert.assertNotNull("Expected minus region to not be null", minus);
checkSingleInterval(minus, minusInterval.getMin(), minusInterval.getMax());
- }
- else {
+ } else {
Assert.assertNull("Expected minus region to be null", minus);
}
@@ -885,8 +884,7 @@ public class RegionBSPTree1STest {
if (plusInterval != null) {
Assert.assertNotNull("Expected plus region to not be null", plus);
checkSingleInterval(plus, plusInterval.getMin(), plusInterval.getMax());
- }
- else {
+ } else {
Assert.assertNull("Expected plus region to be null", plus);
}
}
@@ -905,8 +903,7 @@ public class RegionBSPTree1STest {
if (TEST_PRECISION.eq(normalizedMin, normalizedMax)) {
Assert.assertTrue(interval.isFull());
- }
- else {
+ } else {
Assert.assertEquals(normalizedMin,
interval.getMinBoundary().getPoint().getNormalizedAzimuth(), TEST_EPS);
Assert.assertEquals(normalizedMax,
@@ -914,7 +911,7 @@ public class RegionBSPTree1STest {
}
}
- private static void checkClassify(Region<Point1S> region, RegionLocation loc, double ... pts) {
+ private static void checkClassify(Region<Point1S> region, RegionLocation loc, double... pts) {
for (double pt : pts) {
Assert.assertEquals("Unexpected location for point " + pt, loc, region.classify(Point1S.of(pt)));
}
diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/AbstractGreatArcPathConnectorTest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/AbstractGreatArcPathConnectorTest.java
index 99dd2b7..889f9cc 100644
--- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/AbstractGreatArcPathConnectorTest.java
+++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/AbstractGreatArcPathConnectorTest.java
@@ -88,7 +88,7 @@ public class AbstractGreatArcPathConnectorTest {
public void testConnectAll_singleLune() {
// arrange
GreatCircle upperBound = GreatCircle.fromPoleAndU(
- Vector3D.of(0, 1, -1), Vector3D.Unit.PLUS_X , TEST_PRECISION);
+ Vector3D.of(0, 1, -1), Vector3D.Unit.PLUS_X, TEST_PRECISION);
connector.add(XY_PLANE.arc(0, PlaneAngleRadians.PI));
connector.add(upperBound.arc(PlaneAngleRadians.PI, 0));
@@ -109,7 +109,7 @@ public class AbstractGreatArcPathConnectorTest {
public void testConnectAll_singleLune_pathsNotOrientedCorrectly() {
// arrange
GreatCircle upperBound = GreatCircle.fromPoleAndU(
- Vector3D.of(0, 1, -1), Vector3D.Unit.PLUS_X , TEST_PRECISION);
+ Vector3D.of(0, 1, -1), Vector3D.Unit.PLUS_X, TEST_PRECISION);
connector.add(XY_PLANE.arc(0, PlaneAngleRadians.PI));
connector.add(upperBound.arc(0, PlaneAngleRadians.PI));
@@ -278,14 +278,14 @@ public class AbstractGreatArcPathConnectorTest {
assertPathPoints(path2.get(0), Point2S.MINUS_I, Point2S.MINUS_J);
}
- private static void assertPathPoints(GreatArcPath path, Point2S ... points) {
+ private static void assertPathPoints(GreatArcPath path, Point2S... points) {
List<Point2S> expectedPoints = Arrays.asList(points);
List<Point2S> actualPoints = path.getVertices();
String msg = "Expected path points to equal " + expectedPoints + " but was " + actualPoints;
Assert.assertEquals(msg, expectedPoints.size(), actualPoints.size());
- for (int i=0; i<expectedPoints.size(); ++i) {
+ for (int i = 0; i < expectedPoints.size(); ++i) {
SphericalTestUtils.assertPointsEq(expectedPoints.get(i), actualPoints.get(i), TEST_EPS);
}
}
diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/ConvexArea2STest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/ConvexArea2STest.java
index 65b4018..9380c4e 100644
--- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/ConvexArea2STest.java
+++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/ConvexArea2STest.java
@@ -744,7 +744,7 @@ public class ConvexArea2STest {
SphericalTestUtils.assertPointsEq(end, arc.getEndPoint(), TEST_EPS);
}
- private static void assertPath(GreatArcPath path, Point2S ... expectedVertices) {
+ private static void assertPath(GreatArcPath path, Point2S... expectedVertices) {
List<Point2S> vertices = path.getVertices();
Assert.assertEquals(expectedVertices.length, vertices.size());
diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/GreatArcTest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/GreatArcTest.java
index 121768c..25033e7 100644
--- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/GreatArcTest.java
+++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/GreatArcTest.java
@@ -354,7 +354,7 @@ public class GreatArcTest {
GeometryTestUtils.assertContains("end= (", str);
}
- private static void checkClassify(GreatArc arc, RegionLocation loc, Point2S ... pts) {
+ private static void checkClassify(GreatArc arc, RegionLocation loc, Point2S... pts) {
for (Point2S pt : pts) {
Assert.assertEquals("Unexpected location for point " + pt, loc, arc.classify(pt));
}
diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/GreatCircleTest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/GreatCircleTest.java
index 4c64052..a554ee8 100644
--- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/GreatCircleTest.java
+++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/GreatCircleTest.java
@@ -640,7 +640,7 @@ public class GreatCircleTest {
new EpsilonDoublePrecisionContext(eps));
// act/assert
- Assert.assertTrue(a.eq(a));;
+ Assert.assertTrue(a.eq(a));
Assert.assertFalse(a.eq(b));
Assert.assertFalse(a.eq(c));
diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/InteriorAngleGreatArcConnectorTest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/InteriorAngleGreatArcConnectorTest.java
index 867ef64..067df65 100644
--- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/InteriorAngleGreatArcConnectorTest.java
+++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/InteriorAngleGreatArcConnectorTest.java
@@ -92,14 +92,14 @@ public class InteriorAngleGreatArcConnectorTest {
Assert.assertEquals(1, paths.size());
assertPathPoints(paths.get(0),
- Point2S.PLUS_K,
- Point2S.MINUS_I,
- Point2S.MINUS_J,
- Point2S.PLUS_K,
- Point2S.PLUS_I,
- Point2S.PLUS_J,
- Point2S.PLUS_K
- );
+ Point2S.PLUS_K,
+ Point2S.MINUS_I,
+ Point2S.MINUS_J,
+ Point2S.PLUS_K,
+ Point2S.PLUS_I,
+ Point2S.PLUS_J,
+ Point2S.PLUS_K
+ );
}
@Test
@@ -121,14 +121,14 @@ public class InteriorAngleGreatArcConnectorTest {
Assert.assertEquals(1, paths.size());
assertPathPoints(paths.get(0),
- Point2S.PLUS_K,
- Point2S.MINUS_I,
- Point2S.MINUS_J,
- Point2S.PLUS_K,
- Point2S.PLUS_I,
- Point2S.PLUS_J,
- Point2S.PLUS_K
- );
+ Point2S.PLUS_K,
+ Point2S.MINUS_I,
+ Point2S.MINUS_J,
+ Point2S.PLUS_K,
+ Point2S.PLUS_I,
+ Point2S.PLUS_J,
+ Point2S.PLUS_K
+ );
}
@Test
@@ -151,18 +151,18 @@ public class InteriorAngleGreatArcConnectorTest {
Assert.assertEquals(2, paths.size());
assertPathPoints(paths.get(0),
- Point2S.PLUS_K,
- Point2S.MINUS_I,
- Point2S.MINUS_J,
- Point2S.PLUS_K
- );
+ Point2S.PLUS_K,
+ Point2S.MINUS_I,
+ Point2S.MINUS_J,
+ Point2S.PLUS_K
+ );
assertPathPoints(paths.get(1),
- Point2S.PLUS_K,
- Point2S.PLUS_I,
- Point2S.PLUS_J,
- Point2S.PLUS_K
- );
+ Point2S.PLUS_K,
+ Point2S.PLUS_I,
+ Point2S.PLUS_J,
+ Point2S.PLUS_K
+ );
}
@Test
@@ -184,18 +184,18 @@ public class InteriorAngleGreatArcConnectorTest {
Assert.assertEquals(2, paths.size());
assertPathPoints(paths.get(0),
- Point2S.PLUS_K,
- Point2S.MINUS_I,
- Point2S.MINUS_J,
- Point2S.PLUS_K
- );
+ Point2S.PLUS_K,
+ Point2S.MINUS_I,
+ Point2S.MINUS_J,
+ Point2S.PLUS_K
+ );
assertPathPoints(paths.get(1),
- Point2S.PLUS_K,
- Point2S.PLUS_I,
- Point2S.PLUS_J,
- Point2S.PLUS_K
- );
+ Point2S.PLUS_K,
+ Point2S.PLUS_I,
+ Point2S.PLUS_J,
+ Point2S.PLUS_K
+ );
}
/**
@@ -207,14 +207,14 @@ public class InteriorAngleGreatArcConnectorTest {
body.accept(new Minimize());
}
- private static void assertPathPoints(GreatArcPath path, Point2S ... points) {
+ private static void assertPathPoints(GreatArcPath path, Point2S... points) {
List<Point2S> expectedPoints = Arrays.asList(points);
List<Point2S> actualPoints = path.getVertices();
String msg = "Expected path points to equal " + expectedPoints + " but was " + actualPoints;
Assert.assertEquals(msg, expectedPoints.size(), actualPoints.size());
- for (int i=0; i<expectedPoints.size(); ++i) {
+ for (int i = 0; i < expectedPoints.size(); ++i) {
SphericalTestUtils.assertPointsEq(expectedPoints.get(i), actualPoints.get(i), TEST_EPS);
}
}
diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/RegionBSPTree2STest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/RegionBSPTree2STest.java
index 9dfcd66..4b15a22 100644
--- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/RegionBSPTree2STest.java
+++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/RegionBSPTree2STest.java
@@ -599,18 +599,18 @@ public class RegionBSPTree2STest {
public void testGeographicMap() {
// arrange
RegionBSPTree2S continental = latLongToTree(new double[][] {
- { 51.14850, 2.51357 }, { 50.94660, 1.63900 }, { 50.12717, 1.33876 }, { 49.34737, -0.98946 },
- { 49.77634, -1.93349 }, { 48.64442, -1.61651 }, { 48.90169, -3.29581 }, { 48.68416, -4.59234 },
- { 47.95495, -4.49155 }, { 47.57032, -2.96327 }, { 46.01491, -1.19379 }, { 44.02261, -1.38422 },
- { 43.42280, -1.90135 }, { 43.03401, -1.50277 }, { 42.34338, 1.82679 }, { 42.47301, 2.98599 },
- { 43.07520, 3.10041 }, { 43.39965, 4.55696 }, { 43.12889, 6.52924 }, { 43.69384, 7.43518 },
- { 44.12790, 7.54959 }, { 45.02851, 6.74995 }, { 45.33309, 7.09665 }, { 46.42967, 6.50009 },
- { 46.27298, 6.02260 }, { 46.72577, 6.03738 }, { 47.62058, 7.46675 }, { 49.01778, 8.09927 },
- { 49.20195, 6.65822 }, { 49.44266, 5.89775 }, { 49.98537, 4.79922 }
+ {51.14850, 2.51357}, {50.94660, 1.63900}, {50.12717, 1.33876}, {49.34737, -0.98946},
+ {49.77634, -1.93349}, {48.64442, -1.61651}, {48.90169, -3.29581}, {48.68416, -4.59234},
+ {47.95495, -4.49155}, {47.57032, -2.96327}, {46.01491, -1.19379}, {44.02261, -1.38422},
+ {43.42280, -1.90135}, {43.03401, -1.50277}, {42.34338, 1.82679}, {42.47301, 2.98599},
+ {43.07520, 3.10041}, {43.39965, 4.55696}, {43.12889, 6.52924}, {43.69384, 7.43518},
+ {44.12790, 7.54959}, {45.02851, 6.74995}, {45.33309, 7.09665}, {46.42967, 6.50009},
+ {46.27298, 6.02260}, {46.72577, 6.03738}, {47.62058, 7.46675}, {49.01778, 8.09927},
+ {49.20195, 6.65822}, {49.44266, 5.89775}, {49.98537, 4.79922}
});
RegionBSPTree2S corsica = latLongToTree(new double[][] {
- { 42.15249, 9.56001 }, { 43.00998, 9.39000 }, { 42.62812, 8.74600 }, { 42.25651, 8.54421 },
- { 41.58361, 8.77572 }, { 41.38000, 9.22975 }
+ {42.15249, 9.56001}, {43.00998, 9.39000}, {42.62812, 8.74600}, {42.25651, 8.54421},
+ {41.58361, 8.77572}, {41.38000, 9.22975}
});
// act
@@ -646,7 +646,7 @@ public class RegionBSPTree2STest {
return c1.intersection(c2);
}
- private static void assertPath(GreatArcPath path, Point2S ... vertices) {
+ private static void assertPath(GreatArcPath path, Point2S... vertices) {
List<Point2S> expected = Arrays.asList(vertices);
List<Point2S> actual = path.getVertices();
diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/SubGreatCircleTest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/SubGreatCircleTest.java
index 221f410..e50f12f 100644
--- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/SubGreatCircleTest.java
+++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/SubGreatCircleTest.java
@@ -452,7 +452,7 @@ public class SubGreatCircleTest {
GeometryTestUtils.assertContains("region= RegionBSPTree1S[", str);
}
- private static void checkClassify(SubHyperplane<Point2S> sub, RegionLocation loc, Point2S ... pts) {
+ private static void checkClassify(SubHyperplane<Point2S> sub, RegionLocation loc, Point2S... pts) {
for (Point2S pt : pts) {
Assert.assertEquals("Unexpected location for point " + pt, loc, sub.classify(pt));
}
diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/Transform2STest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/Transform2STest.java
index 91def2b..4334d3b 100644
--- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/Transform2STest.java
+++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/Transform2STest.java
@@ -36,9 +36,9 @@ public class Transform2STest {
// assert
Assert.assertTrue(t.preservesOrientation());
Assert.assertArrayEquals(new double[] {
- 1, 0, 0, 0,
- 0, 1, 0, 0,
- 0, 0, 1, 0
+ 1, 0, 0, 0,
+ 0, 1, 0, 0,
+ 0, 0, 1, 0
}, t.getEuclideanTransform().toArray(), 0);
SphericalTestUtils.assertPointsEqual(Point2S.PLUS_I, t.apply(Point2S.PLUS_I), TEST_EPS);
diff --git a/pom.xml b/pom.xml
index 2a69ccd..45b3d15 100644
--- a/pom.xml
+++ b/pom.xml
@@ -255,19 +255,18 @@
<enableRulesSummary>false</enableRulesSummary>
<logViolationsToConsole>false</logViolationsToConsole>
<failOnViolation>true</failOnViolation>
- <resourceExcludes>NOTICE.txt,LICENSE.txt,**/maven-archiver/pom.properties,**/resolver-status.properties</resourceExcludes>
+ <resourceExcludes>NOTICE.txt,LICENSE.txt,**/pom.properties,**/resolver-status.properties</resourceExcludes>
<excludes>**/generated/**.java</excludes>
</configuration>
- <!-- Uncommenting the lines below currently results in a failed build (see report). -->
- <!-- <executions> -->
- <!-- <execution> -->
- <!-- <id>validate</id> -->
- <!-- <phase>validate</phase> -->
- <!-- <goals> -->
- <!-- <goal>check</goal> -->
- <!-- </goals> -->
- <!-- </execution> -->
- <!-- </executions> -->
+ <executions>
+ <execution>
+ <id>validate</id>
+ <phase>validate</phase>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ </execution>
+ </executions>
</plugin>
<plugin>
<artifactId>maven-pmd-plugin</artifactId>
diff --git a/src/main/resources/checkstyle/checkstyle-suppressions.xml b/src/main/resources/checkstyle/checkstyle-suppressions.xml
index bc75f02..766d02d 100644
--- a/src/main/resources/checkstyle/checkstyle-suppressions.xml
+++ b/src/main/resources/checkstyle/checkstyle-suppressions.xml
@@ -38,5 +38,6 @@
<suppress checks="DesignForExtension" files=".*[/\\]test[/\\].*" />
<suppress checks="LineLength" files=".*[/\\]test[/\\].*" />
<suppress checks="IllegalCatch" files=".*[/\\]test[/\\].*" />
+ <suppress checks="MethodName" files=".*[/\\]test[/\\].*" />
<suppress checks="MethodLength" files="" />
</suppressions>