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 2018/07/06 22:41:48 UTC
[commons-geometry] 01/08: GEOMETRY-3: making euclidean point and
vector constructors private
This is an automated email from the ASF dual-hosted git repository.
erans pushed a commit to branch GEOMETRY-3__TBR
in repository https://gitbox.apache.org/repos/asf/commons-geometry.git
commit e97c5355668643a0dd26611c95900e2e5e67e4fc
Author: Matt Juntunen <ma...@hotmail.com>
AuthorDate: Tue May 22 15:37:48 2018 -0400
GEOMETRY-3: making euclidean point and vector constructors private
---
.../threed/enclosing/SphereGenerator.java | 2 +-
.../euclidean/twod/enclosing/DiskGenerator.java | 2 +-
.../geometry/enclosing/WelzlEncloser2DTest.java | 4 +-
.../geometry/enclosing/WelzlEncloser3DTest.java | 58 +-
.../threed/enclosing/SphereGeneratorTest.java | 78 +-
.../twod/enclosing/DiskGeneratorTest.java | 32 +-
.../geometry/euclidean/oned/IntervalsSet.java | 10 +-
.../commons/geometry/euclidean/oned/Point1D.java | 15 +-
.../commons/geometry/euclidean/oned/Vector1D.java | 24 +-
.../commons/geometry/euclidean/threed/Line.java | 2 +-
.../euclidean/threed/OutlineExtractor.java | 4 +-
.../commons/geometry/euclidean/threed/Plane.java | 4 +-
.../commons/geometry/euclidean/threed/Point3D.java | 14 +-
.../geometry/euclidean/threed/PolyhedronsSet.java | 16 +-
.../geometry/euclidean/threed/Rotation.java | 8 +-
.../commons/geometry/euclidean/threed/SubLine.java | 4 +-
.../geometry/euclidean/threed/Vector3D.java | 42 +-
.../commons/geometry/euclidean/twod/Line.java | 10 +-
.../commons/geometry/euclidean/twod/Point2D.java | 14 +-
.../geometry/euclidean/twod/PolygonsSet.java | 22 +-
.../commons/geometry/euclidean/twod/Segment.java | 2 +-
.../commons/geometry/euclidean/twod/SubLine.java | 4 +-
.../commons/geometry/euclidean/twod/Vector2D.java | 32 +-
.../core/partitioning/CharacterizationTest.java | 104 +-
.../geometry/euclidean/EuclideanTestUtils.java | 8 +-
.../geometry/euclidean/oned/IntervalsSetTest.java | 68 +-
.../geometry/euclidean/oned/OrientedPointTest.java | 64 +-
.../geometry/euclidean/oned/Point1DTest.java | 14 +-
.../euclidean/oned/SubOrientedPointTest.java | 30 +-
.../geometry/euclidean/threed/LineTest.java | 64 +-
.../geometry/euclidean/threed/PLYParser.java | 2 +-
.../geometry/euclidean/threed/PlaneTest.java | 68 +-
.../euclidean/threed/PolyhedronsSetTest.java | 762 ++++++------
.../geometry/euclidean/threed/RotationTest.java | 118 +-
.../geometry/euclidean/threed/SubLineTest.java | 58 +-
.../commons/geometry/euclidean/twod/LineTest.java | 56 +-
.../geometry/euclidean/twod/NestedLoopsTest.java | 10 +-
.../geometry/euclidean/twod/PolygonsSetTest.java | 1312 ++++++++++----------
.../geometry/euclidean/twod/SegmentTest.java | 12 +-
.../geometry/euclidean/twod/SubLineTest.java | 58 +-
.../hull/ConvexHullGenerator2DAbstractTest.java | 160 +--
.../euclidean/twod/hull/MonotoneChainTest.java | 16 +-
.../geometry/spherical/SphericalCoordinates.java | 4 +-
.../commons/geometry/spherical/oned/S1Point.java | 2 +-
.../commons/geometry/spherical/twod/S2Point.java | 2 +-
.../spherical/SphericalCoordinatesTest.java | 24 +-
.../geometry/spherical/SphericalTestUtils.java | 2 +-
.../geometry/spherical/twod/CircleTest.java | 6 +-
.../spherical/twod/SphericalPolygonsSetTest.java | 24 +-
.../geometry/spherical/twod/SubCircleTest.java | 4 +-
50 files changed, 1727 insertions(+), 1728 deletions(-)
diff --git a/commons-geometry-enclosing/src/main/java/org/apache/commons/geometry/euclidean/threed/enclosing/SphereGenerator.java b/commons-geometry-enclosing/src/main/java/org/apache/commons/geometry/euclidean/threed/enclosing/SphereGenerator.java
index a124cf3..b0ada02 100644
--- a/commons-geometry-enclosing/src/main/java/org/apache/commons/geometry/euclidean/threed/enclosing/SphereGenerator.java
+++ b/commons-geometry-enclosing/src/main/java/org/apache/commons/geometry/euclidean/threed/enclosing/SphereGenerator.java
@@ -117,7 +117,7 @@ public class SphereGenerator implements SupportBallGenerator<Point3D> {
final BigFraction dy = c3[0].subtract(centerY);
final BigFraction dz = c4[0].subtract(centerZ);
final BigFraction r2 = dx.multiply(dx).add(dy.multiply(dy)).add(dz.multiply(dz));
- return new EnclosingBall<>(new Point3D(centerX.doubleValue(),
+ return new EnclosingBall<>(Point3D.of(centerX.doubleValue(),
centerY.doubleValue(),
centerZ.doubleValue()),
Math.sqrt(r2.doubleValue()),
diff --git a/commons-geometry-enclosing/src/main/java/org/apache/commons/geometry/euclidean/twod/enclosing/DiskGenerator.java b/commons-geometry-enclosing/src/main/java/org/apache/commons/geometry/euclidean/twod/enclosing/DiskGenerator.java
index c2b9acc..bab99ac 100644
--- a/commons-geometry-enclosing/src/main/java/org/apache/commons/geometry/euclidean/twod/enclosing/DiskGenerator.java
+++ b/commons-geometry-enclosing/src/main/java/org/apache/commons/geometry/euclidean/twod/enclosing/DiskGenerator.java
@@ -85,7 +85,7 @@ public class DiskGenerator implements SupportBallGenerator<Point2D> {
final BigFraction dx = c2[0].subtract(centerX);
final BigFraction dy = c3[0].subtract(centerY);
final BigFraction r2 = dx.multiply(dx).add(dy.multiply(dy));
- return new EnclosingBall<>(new Point2D(centerX.doubleValue(),
+ return new EnclosingBall<>(Point2D.of(centerX.doubleValue(),
centerY.doubleValue()),
Math.sqrt(r2.doubleValue()),
vA, vB, vC);
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 8a975e1..5f6fb80 100644
--- 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 {
for (int i = 0; i < nbPoints; ++i) {
double x = random.nextDouble();
double y = random.nextDouble();
- points.add(new Point2D(x, y));
+ points.add(Point2D.of(x, y));
}
checkDisk(points);
}
@@ -97,7 +97,7 @@ public class WelzlEncloser2DTest {
private List<Point2D> buildList(final double ... coordinates) {
List<Point2D> list = new ArrayList<>(coordinates.length / 2);
for (int i = 0; i < coordinates.length; i += 2) {
- list.add(new Point2D(coordinates[i], coordinates[i + 1]));
+ list.add(Point2D.of(coordinates[i], coordinates[i + 1]));
}
return list;
}
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 e874ca7..b7fc5e0 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
@@ -53,17 +53,17 @@ public class WelzlEncloser3DTest {
@Test
public void testReducingBall() {
List<Point3D> list =
- Arrays.asList(new Point3D(-7.140397329568118, -16.571661242582177, 11.714458961735405),
- new Point3D(-7.137986707455888, -16.570767323375720, 11.708602108715928),
- new Point3D(-7.139185068549035, -16.570891204702250, 11.715554057357394),
- new Point3D(-7.142682716997507, -16.571609818234290, 11.710787934580328),
- new Point3D(-7.139018392423351, -16.574405614157020, 11.710518716711425),
- new Point3D(-7.140870659936730, -16.567993074240455, 11.710914678204503),
- new Point3D(-7.136350173659562, -16.570498228820930, 11.713965225900928),
- new Point3D(-7.141675762759172, -16.572852471407028, 11.714033471449508),
- new Point3D(-7.140453077221105, -16.570212820780647, 11.708624578004980),
- new Point3D(-7.140322188726825, -16.574152894557717, 11.710305611121410),
- new Point3D(-7.141116131477088, -16.574061164624560, 11.712938509321699));
+ Arrays.asList(Point3D.of(-7.140397329568118, -16.571661242582177, 11.714458961735405),
+ Point3D.of(-7.137986707455888, -16.570767323375720, 11.708602108715928),
+ Point3D.of(-7.139185068549035, -16.570891204702250, 11.715554057357394),
+ Point3D.of(-7.142682716997507, -16.571609818234290, 11.710787934580328),
+ Point3D.of(-7.139018392423351, -16.574405614157020, 11.710518716711425),
+ Point3D.of(-7.140870659936730, -16.567993074240455, 11.710914678204503),
+ Point3D.of(-7.136350173659562, -16.570498228820930, 11.713965225900928),
+ Point3D.of(-7.141675762759172, -16.572852471407028, 11.714033471449508),
+ Point3D.of(-7.140453077221105, -16.570212820780647, 11.708624578004980),
+ Point3D.of(-7.140322188726825, -16.574152894557717, 11.710305611121410),
+ Point3D.of(-7.141116131477088, -16.574061164624560, 11.712938509321699));
WelzlEncloser<Point3D> encloser =
new WelzlEncloser<>(1.0e-10, new SphereGenerator());
EnclosingBall<Point3D> ball = encloser.enclose(list);
@@ -74,24 +74,24 @@ public class WelzlEncloser3DTest {
public void testInfiniteLoop() {
// this test used to generate an infinite loop
List<Point3D> list =
- Arrays.asList(new Point3D( -0.89227075512164380, -2.89317694645713900, 14.84572323743355500),
- new Point3D( -0.92099498940693580, -2.31086108263908940, 12.92071026467688300),
- new Point3D( -0.85227999411005200, -3.06314731441320730, 15.40163831651287000),
- new Point3D( -1.77399413020785970, -3.65630391378114260, 14.13190097751873400),
- new Point3D( 0.33157833272465354, -2.22813591757792160, 14.21225234159008200),
- new Point3D( -1.53065579165484400, -1.65692084770139570, 14.61483055714788500),
- new Point3D( -1.08457093941217140, -1.96100325935602980, 13.09265170575555000),
- new Point3D( 0.30029469589708850, -3.05470831395667370, 14.56352400426342600),
- new Point3D( -0.95007443938638460, -1.86810946486118360, 15.14491234340057000),
- new Point3D( -1.89661503804130830, -2.17004080885185860, 14.81235128513927000),
- new Point3D( -0.72193328761607530, -1.44513142833618270, 14.52355724218561800),
- new Point3D( -0.26895980939606550, -3.69512371522084140, 14.72272846327652000),
- new Point3D( -1.53501693431786170, -3.25055166611021900, 15.15509062584274800),
- new Point3D( -0.71727553535519410, -3.62284279460799100, 13.26256700929380700),
- new Point3D( -0.30220950676137365, -3.25410412500779070, 13.13682612771606000),
- new Point3D( -0.04543996608267075, -1.93081853923797750, 14.79497997883171400),
- new Point3D( -1.53348892951571640, -3.66688919703524900, 14.73095600812074200),
- new Point3D( -0.98034899533935820, -3.34004481162763960, 13.03245014017556800));
+ Arrays.asList(Point3D.of( -0.89227075512164380, -2.89317694645713900, 14.84572323743355500),
+ Point3D.of( -0.92099498940693580, -2.31086108263908940, 12.92071026467688300),
+ Point3D.of( -0.85227999411005200, -3.06314731441320730, 15.40163831651287000),
+ Point3D.of( -1.77399413020785970, -3.65630391378114260, 14.13190097751873400),
+ Point3D.of( 0.33157833272465354, -2.22813591757792160, 14.21225234159008200),
+ Point3D.of( -1.53065579165484400, -1.65692084770139570, 14.61483055714788500),
+ Point3D.of( -1.08457093941217140, -1.96100325935602980, 13.09265170575555000),
+ Point3D.of( 0.30029469589708850, -3.05470831395667370, 14.56352400426342600),
+ Point3D.of( -0.95007443938638460, -1.86810946486118360, 15.14491234340057000),
+ Point3D.of( -1.89661503804130830, -2.17004080885185860, 14.81235128513927000),
+ Point3D.of( -0.72193328761607530, -1.44513142833618270, 14.52355724218561800),
+ Point3D.of( -0.26895980939606550, -3.69512371522084140, 14.72272846327652000),
+ Point3D.of( -1.53501693431786170, -3.25055166611021900, 15.15509062584274800),
+ Point3D.of( -0.71727553535519410, -3.62284279460799100, 13.26256700929380700),
+ Point3D.of( -0.30220950676137365, -3.25410412500779070, 13.13682612771606000),
+ Point3D.of( -0.04543996608267075, -1.93081853923797750, 14.79497997883171400),
+ Point3D.of( -1.53348892951571640, -3.66688919703524900, 14.73095600812074200),
+ Point3D.of( -0.98034899533935820, -3.34004481162763960, 13.03245014017556800));
WelzlEncloser<Point3D> encloser =
new WelzlEncloser<>(1.0e-10, new SphereGenerator());
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 a1bf60b..b65d726 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
@@ -41,16 +41,16 @@ public class SphereGeneratorTest {
@Test
public void testSupport1Point() {
- List<Point3D> support = Arrays.asList(new Point3D(1, 2, 3));
+ List<Point3D> support = Arrays.asList(Point3D.of(1, 2, 3));
EnclosingBall<Point3D> sphere = new SphereGenerator().ballOnSupport(support);
Assert.assertEquals(0.0, sphere.getRadius(), 1.0e-10);
Assert.assertTrue(sphere.contains(support.get(0)));
Assert.assertTrue(sphere.contains(support.get(0), 0.5));
- Assert.assertFalse(sphere.contains(new Point3D(support.get(0).getX() + 0.1,
+ Assert.assertFalse(sphere.contains(Point3D.of(support.get(0).getX() + 0.1,
support.get(0).getY() + 0.1,
support.get(0).getZ() + 0.1),
0.001));
- Assert.assertTrue(sphere.contains(new Point3D(support.get(0).getX() + 0.1,
+ Assert.assertTrue(sphere.contains(Point3D.of(support.get(0).getX() + 0.1,
support.get(0).getY() + 0.1,
support.get(0).getZ() + 0.1),
0.5));
@@ -61,8 +61,8 @@ public class SphereGeneratorTest {
@Test
public void testSupport2Points() {
- List<Point3D> support = Arrays.asList(new Point3D(1, 0, 0),
- new Point3D(3, 0, 0));
+ List<Point3D> support = Arrays.asList(Point3D.of(1, 0, 0),
+ Point3D.of(3, 0, 0));
EnclosingBall<Point3D> sphere = new SphereGenerator().ballOnSupport(support);
Assert.assertEquals(1.0, sphere.getRadius(), 1.0e-10);
int i = 0;
@@ -71,17 +71,17 @@ public class SphereGeneratorTest {
Assert.assertEquals(1.0, v.distance(sphere.getCenter()), 1.0e-10);
Assert.assertTrue(v == sphere.getSupport()[i++]);
}
- Assert.assertTrue(sphere.contains(new Point3D(2, 0.9, 0)));
+ Assert.assertTrue(sphere.contains(Point3D.of(2, 0.9, 0)));
Assert.assertFalse(sphere.contains(Point3D.ZERO));
- Assert.assertEquals(0.0, new Point3D(2, 0, 0).distance(sphere.getCenter()), 1.0e-10);
+ Assert.assertEquals(0.0, Point3D.of(2, 0, 0).distance(sphere.getCenter()), 1.0e-10);
Assert.assertEquals(2, sphere.getSupportSize());
}
@Test
public void testSupport3Points() {
- List<Point3D> support = Arrays.asList(new Point3D(1, 0, 0),
- new Point3D(3, 0, 0),
- new Point3D(2, 2, 0));
+ List<Point3D> support = Arrays.asList(Point3D.of(1, 0, 0),
+ Point3D.of(3, 0, 0),
+ Point3D.of(2, 2, 0));
EnclosingBall<Point3D> sphere = new SphereGenerator().ballOnSupport(support);
Assert.assertEquals(5.0 / 4.0, sphere.getRadius(), 1.0e-10);
int i = 0;
@@ -90,23 +90,23 @@ public class SphereGeneratorTest {
Assert.assertEquals(5.0 / 4.0, v.distance(sphere.getCenter()), 1.0e-10);
Assert.assertTrue(v == sphere.getSupport()[i++]);
}
- Assert.assertTrue(sphere.contains(new Point3D(2, 0.9, 0)));
- Assert.assertFalse(sphere.contains(new Point3D(0.9, 0, 0)));
- Assert.assertFalse(sphere.contains(new Point3D(3.1, 0, 0)));
- Assert.assertTrue(sphere.contains(new Point3D(2.0, -0.499, 0)));
- Assert.assertFalse(sphere.contains(new Point3D(2.0, -0.501, 0)));
- Assert.assertTrue(sphere.contains(new Point3D(2.0, 3.0 / 4.0, -1.249)));
- Assert.assertFalse(sphere.contains(new Point3D(2.0, 3.0 / 4.0, -1.251)));
- Assert.assertEquals(0.0, new Point3D(2.0, 3.0 / 4.0, 0).distance(sphere.getCenter()), 1.0e-10);
+ Assert.assertTrue(sphere.contains(Point3D.of(2, 0.9, 0)));
+ Assert.assertFalse(sphere.contains(Point3D.of(0.9, 0, 0)));
+ Assert.assertFalse(sphere.contains(Point3D.of(3.1, 0, 0)));
+ Assert.assertTrue(sphere.contains(Point3D.of(2.0, -0.499, 0)));
+ Assert.assertFalse(sphere.contains(Point3D.of(2.0, -0.501, 0)));
+ Assert.assertTrue(sphere.contains(Point3D.of(2.0, 3.0 / 4.0, -1.249)));
+ Assert.assertFalse(sphere.contains(Point3D.of(2.0, 3.0 / 4.0, -1.251)));
+ Assert.assertEquals(0.0, Point3D.of(2.0, 3.0 / 4.0, 0).distance(sphere.getCenter()), 1.0e-10);
Assert.assertEquals(3, sphere.getSupportSize());
}
@Test
public void testSupport4Points() {
- List<Point3D> support = Arrays.asList(new Point3D(17, 14, 18),
- new Point3D(11, 14, 22),
- new Point3D( 2, 22, 17),
- new Point3D(22, 11, -10));
+ List<Point3D> support = Arrays.asList(Point3D.of(17, 14, 18),
+ Point3D.of(11, 14, 22),
+ Point3D.of( 2, 22, 17),
+ Point3D.of(22, 11, -10));
EnclosingBall<Point3D> sphere = new SphereGenerator().ballOnSupport(support);
Assert.assertEquals(25.0, sphere.getRadius(), 1.0e-10);
int i = 0;
@@ -115,19 +115,19 @@ public class SphereGeneratorTest {
Assert.assertEquals(25.0, v.distance(sphere.getCenter()), 1.0e-10);
Assert.assertTrue(v == sphere.getSupport()[i++]);
}
- Assert.assertTrue(sphere.contains (new Point3D(-22.999, 2, 2)));
- Assert.assertFalse(sphere.contains(new Point3D(-23.001, 2, 2)));
- Assert.assertTrue(sphere.contains (new Point3D( 26.999, 2, 2)));
- Assert.assertFalse(sphere.contains(new Point3D( 27.001, 2, 2)));
- Assert.assertTrue(sphere.contains (new Point3D(2, -22.999, 2)));
- Assert.assertFalse(sphere.contains(new Point3D(2, -23.001, 2)));
- Assert.assertTrue(sphere.contains (new Point3D(2, 26.999, 2)));
- Assert.assertFalse(sphere.contains(new Point3D(2, 27.001, 2)));
- Assert.assertTrue(sphere.contains (new Point3D(2, 2, -22.999)));
- Assert.assertFalse(sphere.contains(new Point3D(2, 2, -23.001)));
- Assert.assertTrue(sphere.contains (new Point3D(2, 2, 26.999)));
- Assert.assertFalse(sphere.contains(new Point3D(2, 2, 27.001)));
- Assert.assertEquals(0.0, new Point3D(2.0, 2.0, 2.0).distance(sphere.getCenter()), 1.0e-10);
+ Assert.assertTrue(sphere.contains (Point3D.of(-22.999, 2, 2)));
+ Assert.assertFalse(sphere.contains(Point3D.of(-23.001, 2, 2)));
+ Assert.assertTrue(sphere.contains (Point3D.of( 26.999, 2, 2)));
+ Assert.assertFalse(sphere.contains(Point3D.of( 27.001, 2, 2)));
+ Assert.assertTrue(sphere.contains (Point3D.of(2, -22.999, 2)));
+ Assert.assertFalse(sphere.contains(Point3D.of(2, -23.001, 2)));
+ Assert.assertTrue(sphere.contains (Point3D.of(2, 26.999, 2)));
+ Assert.assertFalse(sphere.contains(Point3D.of(2, 27.001, 2)));
+ Assert.assertTrue(sphere.contains (Point3D.of(2, 2, -22.999)));
+ Assert.assertFalse(sphere.contains(Point3D.of(2, 2, -23.001)));
+ Assert.assertTrue(sphere.contains (Point3D.of(2, 2, 26.999)));
+ Assert.assertFalse(sphere.contains(Point3D.of(2, 2, 27.001)));
+ Assert.assertEquals(0.0, Point3D.of(2.0, 2.0, 2.0).distance(sphere.getCenter()), 1.0e-10);
Assert.assertEquals(4, sphere.getSupportSize());
}
@@ -153,16 +153,16 @@ public class SphereGeneratorTest {
@Test
public void testDegeneratedCase() {
final List<Point3D> support =
- Arrays.asList(new Point3D(Math.scalb(-8039905610797991.0, -50), // -7.140870659936730
+ Arrays.asList(Point3D.of(Math.scalb(-8039905610797991.0, -50), // -7.140870659936730
Math.scalb(-4663475464714142.0, -48), // -16.567993074240455
Math.scalb( 6592658872616184.0, -49)), // 11.710914678204503
- new Point3D(Math.scalb(-8036658568968473.0, -50), // -7.137986707455888
+ Point3D.of(Math.scalb(-8036658568968473.0, -50), // -7.137986707455888
Math.scalb(-4664256346424880.0, -48), // -16.570767323375720
Math.scalb( 6591357011730307.0, -49)), // 11.708602108715928)
- new Point3D(Math.scalb(-8037820142977230.0, -50), // -7.139018392423351
+ Point3D.of(Math.scalb(-8037820142977230.0, -50), // -7.139018392423351
Math.scalb(-4665280434237813.0, -48), // -16.574405614157020
Math.scalb( 6592435966112099.0, -49)), // 11.710518716711425
- new Point3D(Math.scalb(-8038007803611611.0, -50), // -7.139185068549035
+ Point3D.of(Math.scalb(-8038007803611611.0, -50), // -7.139185068549035
Math.scalb(-4664291215918380.0, -48), // -16.570891204702250
Math.scalb( 6595270610894208.0, -49))); // 11.715554057357394
EnclosingBall<Point3D> sphere = new SphereGenerator().ballOnSupport(support);
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 fcafaa4..8770b6b 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
@@ -42,15 +42,15 @@ public class DiskGeneratorTest {
@Test
public void testSupport1Point() {
- List<Point2D> support = Arrays.asList(new Point2D(1, 2));
+ List<Point2D> support = Arrays.asList(Point2D.of(1, 2));
EnclosingBall<Point2D> disk = new DiskGenerator().ballOnSupport(support);
Assert.assertEquals(0.0, disk.getRadius(), 1.0e-10);
Assert.assertTrue(disk.contains(support.get(0)));
Assert.assertTrue(disk.contains(support.get(0), 0.5));
- Assert.assertFalse(disk.contains(new Point2D(support.get(0).getX() + 0.1,
+ Assert.assertFalse(disk.contains(Point2D.of(support.get(0).getX() + 0.1,
support.get(0).getY() - 0.1),
0.001));
- Assert.assertTrue(disk.contains(new Point2D(support.get(0).getX() + 0.1,
+ Assert.assertTrue(disk.contains(Point2D.of(support.get(0).getX() + 0.1,
support.get(0).getY() - 0.1),
0.5));
Assert.assertEquals(0, support.get(0).distance(disk.getCenter()), 1.0e-10);
@@ -60,8 +60,8 @@ public class DiskGeneratorTest {
@Test
public void testSupport2Points() {
- List<Point2D> support = Arrays.asList(new Point2D(1, 0),
- new Point2D(3, 0));
+ List<Point2D> support = Arrays.asList(Point2D.of(1, 0),
+ Point2D.of(3, 0));
EnclosingBall<Point2D> disk = new DiskGenerator().ballOnSupport(support);
Assert.assertEquals(1.0, disk.getRadius(), 1.0e-10);
int i = 0;
@@ -70,17 +70,17 @@ public class DiskGeneratorTest {
Assert.assertEquals(1.0, v.distance(disk.getCenter()), 1.0e-10);
Assert.assertTrue(v == disk.getSupport()[i++]);
}
- Assert.assertTrue(disk.contains(new Point2D(2, 0.9)));
+ Assert.assertTrue(disk.contains(Point2D.of(2, 0.9)));
Assert.assertFalse(disk.contains(Point2D.ZERO));
- Assert.assertEquals(0.0, new Point2D(2, 0).distance(disk.getCenter()), 1.0e-10);
+ Assert.assertEquals(0.0, Point2D.of(2, 0).distance(disk.getCenter()), 1.0e-10);
Assert.assertEquals(2, disk.getSupportSize());
}
@Test
public void testSupport3Points() {
- List<Point2D> support = Arrays.asList(new Point2D(1, 0),
- new Point2D(3, 0),
- new Point2D(2, 2));
+ List<Point2D> support = Arrays.asList(Point2D.of(1, 0),
+ Point2D.of(3, 0),
+ Point2D.of(2, 2));
EnclosingBall<Point2D> disk = new DiskGenerator().ballOnSupport(support);
Assert.assertEquals(5.0 / 4.0, disk.getRadius(), 1.0e-10);
int i = 0;
@@ -89,12 +89,12 @@ public class DiskGeneratorTest {
Assert.assertEquals(5.0 / 4.0, v.distance(disk.getCenter()), 1.0e-10);
Assert.assertTrue(v == disk.getSupport()[i++]);
}
- Assert.assertTrue(disk.contains(new Point2D(2, 0.9)));
- Assert.assertFalse(disk.contains(new Point2D(0.9, 0)));
- Assert.assertFalse(disk.contains(new Point2D(3.1, 0)));
- Assert.assertTrue(disk.contains(new Point2D(2.0, -0.499)));
- Assert.assertFalse(disk.contains(new Point2D(2.0, -0.501)));
- Assert.assertEquals(0.0, new Point2D(2.0, 3.0 / 4.0).distance(disk.getCenter()), 1.0e-10);
+ Assert.assertTrue(disk.contains(Point2D.of(2, 0.9)));
+ Assert.assertFalse(disk.contains(Point2D.of(0.9, 0)));
+ Assert.assertFalse(disk.contains(Point2D.of(3.1, 0)));
+ Assert.assertTrue(disk.contains(Point2D.of(2.0, -0.499)));
+ Assert.assertFalse(disk.contains(Point2D.of(2.0, -0.501)));
+ Assert.assertEquals(0.0, Point2D.of(2.0, 3.0 / 4.0).distance(disk.getCenter()), 1.0e-10);
Assert.assertEquals(3, disk.getSupportSize());
}
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/IntervalsSet.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/IntervalsSet.java
index 05e7798..376b8fc 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/IntervalsSet.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/IntervalsSet.java
@@ -105,14 +105,14 @@ public class IntervalsSet extends AbstractRegion<Point1D, Point1D> implements It
}
// the tree must be open on the negative infinity side
final SubHyperplane<Point1D> upperCut =
- new OrientedPoint(new Point1D(upper), true, tolerance).wholeHyperplane();
+ new OrientedPoint(Point1D.of(upper), true, tolerance).wholeHyperplane();
return new BSPTree<>(upperCut,
new BSPTree<Point1D>(Boolean.FALSE),
new BSPTree<Point1D>(Boolean.TRUE),
null);
}
final SubHyperplane<Point1D> lowerCut =
- new OrientedPoint(new Point1D(lower), false, tolerance).wholeHyperplane();
+ new OrientedPoint(Point1D.of(lower), false, tolerance).wholeHyperplane();
if (Double.isInfinite(upper) && (upper > 0)) {
// the tree must be open on the positive infinity side
return new BSPTree<>(lowerCut,
@@ -123,7 +123,7 @@ public class IntervalsSet extends AbstractRegion<Point1D, Point1D> implements It
// the tree must be bounded on the two sides
final SubHyperplane<Point1D> upperCut =
- new OrientedPoint(new Point1D(upper), true, tolerance).wholeHyperplane();
+ new OrientedPoint(Point1D.of(upper), true, tolerance).wholeHyperplane();
return new BSPTree<>(lowerCut,
new BSPTree<Point1D>(Boolean.FALSE),
new BSPTree<>(upperCut,
@@ -157,7 +157,7 @@ public class IntervalsSet extends AbstractRegion<Point1D, Point1D> implements It
if (Double.isInfinite(size)) {
setBarycenter(Point1D.NaN);
} else if (size > 0) {
- setBarycenter(new Point1D(sum / size));
+ setBarycenter(Point1D.of(sum / size));
} else {
setBarycenter(((OrientedPoint) getTree(false).getCut().getHyperplane()).getLocation());
}
@@ -242,7 +242,7 @@ public class IntervalsSet extends AbstractRegion<Point1D, Point1D> implements It
* @return a new point for finite abscissa, null otherwise
*/
private Point1D finiteOrNullPoint(final double x) {
- return Double.isInfinite(x) ? null : new Point1D(x);
+ return Double.isInfinite(x) ? null : Point1D.of(x);
}
/** Build an ordered list of intervals representing the instance.
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/Point1D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/Point1D.java
index eeeed9f..75f4cb8 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/Point1D.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/Point1D.java
@@ -25,32 +25,31 @@ import org.apache.commons.numbers.arrays.LinearCombination;
public final class Point1D extends Cartesian1D implements EuclideanPoint<Point1D, Vector1D> {
/** Origin (coordinates: 0). */
- public static final Point1D ZERO = new Point1D(0.0);
+ public static final Point1D ZERO = Point1D.of(0.0);
/** Unit (coordinates: 1). */
- public static final Point1D ONE = new Point1D(1.0);
+ public static final Point1D ONE = Point1D.of(1.0);
// CHECKSTYLE: stop ConstantName
/** A vector with all coordinates set to NaN. */
- public static final Point1D NaN = new Point1D(Double.NaN);
+ public static final Point1D NaN = Point1D.of(Double.NaN);
// CHECKSTYLE: resume ConstantName
/** A point with all coordinates set to positive infinity. */
public static final Point1D POSITIVE_INFINITY =
- new Point1D(Double.POSITIVE_INFINITY);
+ Point1D.of(Double.POSITIVE_INFINITY);
/** A point with all coordinates set to negative infinity. */
public static final Point1D NEGATIVE_INFINITY =
- new Point1D(Double.NEGATIVE_INFINITY);
+ Point1D.of(Double.NEGATIVE_INFINITY);
/** Serializable UID. */
private static final long serialVersionUID = 7556674948671647925L;
/** Simple constructor.
* @param x abscissa (coordinate value)
- * @see #getX()
*/
- public Point1D(double x) {
+ private Point1D(double x) {
super(x);
}
@@ -81,7 +80,7 @@ public final class Point1D extends Cartesian1D implements EuclideanPoint<Point1D
/** {@inheritDoc} */
@Override
public Point1D add(Vector1D v) {
- return new Point1D(getX() + v.getX());
+ return Point1D.of(getX() + v.getX());
}
/**
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/Vector1D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/Vector1D.java
index 1e6ab7d..8455441 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/Vector1D.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/Vector1D.java
@@ -25,23 +25,23 @@ import org.apache.commons.numbers.arrays.LinearCombination;
public final class Vector1D extends Cartesian1D implements EuclideanVector<Point1D, Vector1D> {
/** Zero vector (coordinates: 0). */
- public static final Vector1D ZERO = new Vector1D(0.0);
+ public static final Vector1D ZERO = Vector1D.of(0.0);
/** Unit vector (coordinates: 1). */
- public static final Vector1D ONE = new Vector1D(1.0);
+ public static final Vector1D ONE = Vector1D.of(1.0);
// CHECKSTYLE: stop ConstantName
/** A vector with all coordinates set to NaN. */
- public static final Vector1D NaN = new Vector1D(Double.NaN);
+ public static final Vector1D NaN = Vector1D.of(Double.NaN);
// CHECKSTYLE: resume ConstantName
/** A vector with all coordinates set to positive infinity. */
public static final Vector1D POSITIVE_INFINITY =
- new Vector1D(Double.POSITIVE_INFINITY);
+ Vector1D.of(Double.POSITIVE_INFINITY);
/** A vector with all coordinates set to negative infinity. */
public static final Vector1D NEGATIVE_INFINITY =
- new Vector1D(Double.NEGATIVE_INFINITY);
+ Vector1D.of(Double.NEGATIVE_INFINITY);
/** Serializable UID. */
private static final long serialVersionUID = 1582116020164328846L;
@@ -49,7 +49,7 @@ public final class Vector1D extends Cartesian1D implements EuclideanVector<Point
/** Simple constructor.
* @param x abscissa (coordinate value)
*/
- public Vector1D(double x) {
+ private Vector1D(double x) {
super(x);
}
@@ -92,31 +92,31 @@ public final class Vector1D extends Cartesian1D implements EuclideanVector<Point
/** {@inheritDoc} */
@Override
public Vector1D add(Vector1D v) {
- return new Vector1D(getX() + v.getX());
+ return Vector1D.of(getX() + v.getX());
}
/** {@inheritDoc} */
@Override
public Vector1D add(double factor, Vector1D v) {
- return new Vector1D(getX() + (factor * v.getX()));
+ return Vector1D.of(getX() + (factor * v.getX()));
}
/** {@inheritDoc} */
@Override
public Vector1D subtract(Vector1D v) {
- return new Vector1D(getX() - v.getX());
+ return Vector1D.of(getX() - v.getX());
}
/** {@inheritDoc} */
@Override
public Vector1D subtract(double factor, Vector1D v) {
- return new Vector1D(getX() - (factor * v.getX()));
+ return Vector1D.of(getX() - (factor * v.getX()));
}
/** {@inheritDoc} */
@Override
public Vector1D negate() {
- return new Vector1D(-getX());
+ return Vector1D.of(-getX());
}
/** {@inheritDoc} */
@@ -132,7 +132,7 @@ public final class Vector1D extends Cartesian1D implements EuclideanVector<Point
/** {@inheritDoc} */
@Override
public Vector1D scalarMultiply(double a) {
- return new Vector1D(a * getX());
+ return Vector1D.of(a * getX());
}
/** {@inheritDoc} */
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Line.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Line.java
index 68512a8..e7b4f38 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Line.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Line.java
@@ -135,7 +135,7 @@ public class Line implements Embedding<Point3D, Point1D> {
*/
@Override
public Point1D toSubSpace(final Point3D point) {
- return new Point1D(getAbscissa(point));
+ return Point1D.of(getAbscissa(point));
}
/** Transform a sub-space point into a space point.
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/OutlineExtractor.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/OutlineExtractor.java
index 830d8bf..be504db 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/OutlineExtractor.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/OutlineExtractor.java
@@ -205,12 +205,12 @@ public class OutlineExtractor {
int previous = closed ? (loop.length - 1) : 1;
Vector3D previous3D = plane.toSpace(loop[previous]).asVector();
int current = (previous + 1) % loop.length;
- Point2D pPoint = new Point2D(previous3D.dotProduct(u),
+ Point2D pPoint = Point2D.of(previous3D.dotProduct(u),
previous3D.dotProduct(v));
while (current < loop.length) {
final Vector3D current3D = plane.toSpace(loop[current]).asVector();
- final Point2D cPoint = new Point2D(current3D.dotProduct(u),
+ final Point2D cPoint = Point2D.of(current3D.dotProduct(u),
current3D.dotProduct(v));
final org.apache.commons.geometry.euclidean.twod.Line line =
new org.apache.commons.geometry.euclidean.twod.Line(pPoint, cPoint, tolerance);
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Plane.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Plane.java
index 5ac48dc..23fc6cd 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Plane.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Plane.java
@@ -241,7 +241,7 @@ public class Plane implements Hyperplane<Point3D>, Embedding<Point3D, Point2D> {
@Override
public Point2D toSubSpace(final Point3D point) {
Vector3D vec = point.asVector();
- return new Point2D(vec.dotProduct(u), vec.dotProduct(v));
+ return Point2D.of(vec.dotProduct(u), vec.dotProduct(v));
}
/** Transform an in-plane point into a 3D space point.
@@ -380,7 +380,7 @@ public class Plane implements Hyperplane<Point3D>, Embedding<Point3D, Point2D> {
}
final double r = 1.0 / determinant;
- return new Point3D(
+ return Point3D.of(
(-a23 * d1 - (c1 * b3 - c3 * b1) * d2 - (c2 * b1 - c1 * b2) * d3) * r,
(-b23 * d1 - (c3 * a1 - c1 * a3) * d2 - (c1 * a2 - c2 * a1) * d3) * r,
(-c23 * d1 - (b1 * a3 - b3 * a1) * d2 - (b2 * a1 - b1 * a2) * d3) * r);
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Point3D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Point3D.java
index 46de33d..05af242 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Point3D.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Point3D.java
@@ -26,20 +26,20 @@ import org.apache.commons.numbers.arrays.LinearCombination;
public final class Point3D extends Cartesian3D implements EuclideanPoint<Point3D, Vector3D> {
/** Zero point (coordinates: 0, 0, 0). */
- public static final Point3D ZERO = new Point3D(0, 0, 0);
+ public static final Point3D ZERO = Point3D.of(0, 0, 0);
// CHECKSTYLE: stop ConstantName
/** A point with all coordinates set to NaN. */
- public static final Point3D NaN = new Point3D(Double.NaN, Double.NaN, Double.NaN);
+ public static final Point3D NaN = Point3D.of(Double.NaN, Double.NaN, Double.NaN);
// CHECKSTYLE: resume ConstantName
/** A point with all coordinates set to positive infinity. */
public static final Point3D POSITIVE_INFINITY =
- new Point3D(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
+ Point3D.of(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
/** A point with all coordinates set to negative infinity. */
public static final Point3D NEGATIVE_INFINITY =
- new Point3D(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY);
+ Point3D.of(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY);
/** Serializable version identifier. */
private static final long serialVersionUID = 1313493323784566947L;
@@ -50,7 +50,7 @@ public final class Point3D extends Cartesian3D implements EuclideanPoint<Point3D
* @param y ordinate
* @param z height
*/
- public Point3D(double x, double y, double z) {
+ private Point3D(double x, double y, double z) {
super(x, y, z);
}
@@ -69,7 +69,7 @@ public final class Point3D extends Cartesian3D implements EuclideanPoint<Point3D
/** {@inheritDoc} */
@Override
public Vector3D subtract(Point3D p) {
- return new Vector3D(
+ return Vector3D.of(
getX() - p.getX(),
getY() - p.getY(),
getZ() - p.getZ()
@@ -85,7 +85,7 @@ public final class Point3D extends Cartesian3D implements EuclideanPoint<Point3D
/** {@inheritDoc} */
@Override
public Point3D add(Vector3D v) {
- return new Point3D(
+ return Point3D.of(
getX() + v.getX(),
getY() + v.getY(),
getZ() + v.getZ()
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/PolyhedronsSet.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/PolyhedronsSet.java
index d70efba..114eb51 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/PolyhedronsSet.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/PolyhedronsSet.java
@@ -152,12 +152,12 @@ public class PolyhedronsSet extends AbstractRegion<Point3D, Point2D> {
// too thin box, build an empty polygons set
return new BSPTree<>(Boolean.FALSE);
}
- final Plane pxMin = new Plane(new Point3D(xMin, 0, 0), Vector3D.MINUS_X, tolerance);
- final Plane pxMax = new Plane(new Point3D(xMax, 0, 0), Vector3D.PLUS_X, tolerance);
- final Plane pyMin = new Plane(new Point3D(0, yMin, 0), Vector3D.MINUS_Y, tolerance);
- final Plane pyMax = new Plane(new Point3D(0, yMax, 0), Vector3D.PLUS_Y, tolerance);
- final Plane pzMin = new Plane(new Point3D(0, 0, zMin), Vector3D.MINUS_Z, tolerance);
- final Plane pzMax = new Plane(new Point3D(0, 0, zMax), Vector3D.PLUS_Z, tolerance);
+ final Plane pxMin = new Plane(Point3D.of(xMin, 0, 0), Vector3D.MINUS_X, tolerance);
+ final Plane pxMax = new Plane(Point3D.of(xMax, 0, 0), Vector3D.PLUS_X, tolerance);
+ final Plane pyMin = new Plane(Point3D.of(0, yMin, 0), Vector3D.MINUS_Y, tolerance);
+ final Plane pyMax = new Plane(Point3D.of(0, yMax, 0), Vector3D.PLUS_Y, tolerance);
+ final Plane pzMin = new Plane(Point3D.of(0, 0, zMin), Vector3D.MINUS_Z, tolerance);
+ final Plane pzMax = new Plane(Point3D.of(0, 0, zMax), Vector3D.PLUS_Z, tolerance);
final Region<Point3D> boundary =
new RegionFactory<Point3D>().buildConvex(pxMin, pxMax, pyMin, pyMax, pzMin, pzMax);
return boundary.getTree(false);
@@ -614,8 +614,8 @@ public class PolyhedronsSet extends AbstractRegion<Point3D, Point2D> {
final Plane oPlane = (Plane) original;
final Plane tPlane = (Plane) transformed;
final Point3D p00 = oPlane.getOrigin();
- final Point3D p10 = oPlane.toSpace(new Point2D(1.0, 0.0));
- final Point3D p01 = oPlane.toSpace(new Point2D(0.0, 1.0));
+ final Point3D p10 = oPlane.toSpace(Point2D.of(1.0, 0.0));
+ final Point3D p01 = oPlane.toSpace(Point2D.of(0.0, 1.0));
final Point2D tP00 = tPlane.toSubSpace(apply(p00));
final Point2D tP10 = tPlane.toSubSpace(apply(p10));
final Point2D tP01 = tPlane.toSubSpace(apply(p01));
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Rotation.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Rotation.java
index 7261fd1..931be75 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Rotation.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Rotation.java
@@ -543,10 +543,10 @@ public class Rotation implements Serializable {
final double sgn = convention == RotationConvention.VECTOR_OPERATOR ? +1 : -1;
if (q0 < 0) {
final double inverse = sgn / Math.sqrt(squaredSine);
- return new Vector3D(q1 * inverse, q2 * inverse, q3 * inverse);
+ return Vector3D.of(q1 * inverse, q2 * inverse, q3 * inverse);
}
final double inverse = -sgn / Math.sqrt(squaredSine);
- return new Vector3D(q1 * inverse, q2 * inverse, q3 * inverse);
+ return Vector3D.of(q1 * inverse, q2 * inverse, q3 * inverse);
}
}
@@ -1113,7 +1113,7 @@ public class Rotation implements Serializable {
double s = q1 * x + q2 * y + q3 * z;
- return new Vector3D(2 * (q0 * (x * q0 - (q2 * z - q3 * y)) + s * q1) - x,
+ return Vector3D.of(2 * (q0 * (x * q0 - (q2 * z - q3 * y)) + s * q1) - x,
2 * (q0 * (y * q0 - (q3 * x - q1 * z)) + s * q2) - y,
2 * (q0 * (z * q0 - (q1 * y - q2 * x)) + s * q3) - z);
@@ -1151,7 +1151,7 @@ public class Rotation implements Serializable {
double s = q1 * x + q2 * y + q3 * z;
double m0 = -q0;
- return new Vector3D(2 * (m0 * (x * m0 - (q2 * z - q3 * y)) + s * q1) - x,
+ return Vector3D.of(2 * (m0 * (x * m0 - (q2 * z - q3 * y)) + s * q1) - x,
2 * (m0 * (y * m0 - (q3 * x - q1 * z)) + s * q2) - y,
2 * (m0 * (z * m0 - (q1 * y - q2 * x)) + s * q3) - z);
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/SubLine.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/SubLine.java
index fdf511b..d390536 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/SubLine.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/SubLine.java
@@ -83,8 +83,8 @@ public class SubLine {
final List<Segment> segments = new ArrayList<>(list.size());
for (final Interval interval : list) {
- final Point3D start = line.toSpace(new Point1D(interval.getInf()));
- final Point3D end = line.toSpace(new Point1D(interval.getSup()));
+ final Point3D start = line.toSpace(Point1D.of(interval.getInf()));
+ final Point3D end = line.toSpace(Point1D.of(interval.getSup()));
segments.add(new Segment(start, end, line));
}
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Vector3D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Vector3D.java
index 5a9e0ac..f50816a 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Vector3D.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Vector3D.java
@@ -25,38 +25,38 @@ import org.apache.commons.numbers.arrays.LinearCombination;
public class Vector3D extends Cartesian3D implements EuclideanVector<Point3D, Vector3D> {
/** Zero (null) vector (coordinates: 0, 0, 0). */
- public static final Vector3D ZERO = new Vector3D(0, 0, 0);
+ public static final Vector3D ZERO = Vector3D.of(0, 0, 0);
/** First canonical vector (coordinates: 1, 0, 0). */
- public static final Vector3D PLUS_X = new Vector3D(1, 0, 0);
+ public static final Vector3D PLUS_X = Vector3D.of(1, 0, 0);
/** Opposite of the first canonical vector (coordinates: -1, 0, 0). */
- public static final Vector3D MINUS_X = new Vector3D(-1, 0, 0);
+ public static final Vector3D MINUS_X = Vector3D.of(-1, 0, 0);
/** Second canonical vector (coordinates: 0, 1, 0). */
- public static final Vector3D PLUS_Y = new Vector3D(0, 1, 0);
+ public static final Vector3D PLUS_Y = Vector3D.of(0, 1, 0);
/** Opposite of the second canonical vector (coordinates: 0, -1, 0). */
- public static final Vector3D MINUS_Y = new Vector3D(0, -1, 0);
+ public static final Vector3D MINUS_Y = Vector3D.of(0, -1, 0);
/** Third canonical vector (coordinates: 0, 0, 1). */
- public static final Vector3D PLUS_Z = new Vector3D(0, 0, 1);
+ public static final Vector3D PLUS_Z = Vector3D.of(0, 0, 1);
/** Opposite of the third canonical vector (coordinates: 0, 0, -1). */
- public static final Vector3D MINUS_Z = new Vector3D(0, 0, -1);
+ public static final Vector3D MINUS_Z = Vector3D.of(0, 0, -1);
// CHECKSTYLE: stop ConstantName
/** A vector with all coordinates set to NaN. */
- public static final Vector3D NaN = new Vector3D(Double.NaN, Double.NaN, Double.NaN);
+ public static final Vector3D NaN = Vector3D.of(Double.NaN, Double.NaN, Double.NaN);
// CHECKSTYLE: resume ConstantName
/** A vector with all coordinates set to positive infinity. */
public static final Vector3D POSITIVE_INFINITY =
- new Vector3D(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
+ Vector3D.of(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
/** A vector with all coordinates set to negative infinity. */
public static final Vector3D NEGATIVE_INFINITY =
- new Vector3D(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY);
+ Vector3D.of(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY);
/** Serializable UID */
private static final long serialVersionUID = 3695385854431542858L;
@@ -70,7 +70,7 @@ public class Vector3D extends Cartesian3D implements EuclideanVector<Point3D, Ve
* @param y ordinate
* @param z height
*/
- public Vector3D(double x, double y, double z) {
+ private Vector3D(double x, double y, double z) {
super(x, y, z);
}
@@ -135,7 +135,7 @@ public class Vector3D extends Cartesian3D implements EuclideanVector<Point3D, Ve
/** {@inheritDoc} */
@Override
public Vector3D add(Vector3D v) {
- return new Vector3D(
+ return Vector3D.of(
getX() + v.getX(),
getY() + v.getY(),
getZ() + v.getZ()
@@ -145,7 +145,7 @@ public class Vector3D extends Cartesian3D implements EuclideanVector<Point3D, Ve
/** {@inheritDoc} */
@Override
public Vector3D add(double factor, Vector3D v) {
- return new Vector3D(
+ return Vector3D.of(
getX() + (factor * v.getX()),
getY() + (factor * v.getY()),
getZ() + (factor * v.getZ())
@@ -155,7 +155,7 @@ public class Vector3D extends Cartesian3D implements EuclideanVector<Point3D, Ve
/** {@inheritDoc} */
@Override
public Vector3D subtract(Vector3D v) {
- return new Vector3D(
+ return Vector3D.of(
getX() - v.getX(),
getY() - v.getY(),
getZ() - v.getZ()
@@ -165,7 +165,7 @@ public class Vector3D extends Cartesian3D implements EuclideanVector<Point3D, Ve
/** {@inheritDoc} */
@Override
public Vector3D subtract(double factor, Vector3D v) {
- return new Vector3D(
+ return Vector3D.of(
getX() - (factor * v.getX()),
getY() - (factor * v.getY()),
getZ() - (factor * v.getZ())
@@ -175,7 +175,7 @@ public class Vector3D extends Cartesian3D implements EuclideanVector<Point3D, Ve
/** {@inheritDoc} */
@Override
public Vector3D negate() {
- return new Vector3D(-getX(), -getY(), -getZ());
+ return Vector3D.of(-getX(), -getY(), -getZ());
}
/** {@inheritDoc} */
@@ -215,13 +215,13 @@ public class Vector3D extends Cartesian3D implements EuclideanVector<Point3D, Ve
if (Math.abs(x) <= threshold) {
double inverse = 1 / Math.sqrt(y * y + z * z);
- return new Vector3D(0, inverse * z, -inverse * y);
+ return Vector3D.of(0, inverse * z, -inverse * y);
} else if (Math.abs(y) <= threshold) {
double inverse = 1 / Math.sqrt(x * x + z * z);
- return new Vector3D(-inverse * z, 0, inverse * x);
+ return Vector3D.of(-inverse * z, 0, inverse * x);
}
double inverse = 1 / Math.sqrt(x * x + y * y);
- return new Vector3D(inverse * y, -inverse * x, 0);
+ return Vector3D.of(inverse * y, -inverse * x, 0);
}
/** Compute the angular separation between two vectors.
@@ -260,7 +260,7 @@ public class Vector3D extends Cartesian3D implements EuclideanVector<Point3D, Ve
* @return the cross product this ^ v as a new Cartesian3D
*/
public Vector3D crossProduct(final Vector3D v) {
- return new Vector3D(LinearCombination.value(getY(), v.getZ(), -getZ(), v.getY()),
+ return Vector3D.of(LinearCombination.value(getY(), v.getZ(), -getZ(), v.getY()),
LinearCombination.value(getZ(), v.getX(), -getX(), v.getZ()),
LinearCombination.value(getX(), v.getY(), -getY(), v.getX()));
}
@@ -268,7 +268,7 @@ public class Vector3D extends Cartesian3D implements EuclideanVector<Point3D, Ve
/** {@inheritDoc} */
@Override
public Vector3D scalarMultiply(double a) {
- return new Vector3D(a * getX(), a * getY(), a * getZ());
+ return Vector3D.of(a * getX(), a * getY(), a * getZ());
}
/** {@inheritDoc} */
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Line.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Line.java
index cb3c2ea..c5a5394 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Line.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Line.java
@@ -212,14 +212,14 @@ public class Line implements Hyperplane<Point2D>, Embedding<Point2D, Point1D> {
/** {@inheritDoc} */
@Override
public Point1D toSubSpace(final Point2D point) {
- return new Point1D(LinearCombination.value(cos, point.getX(), sin, point.getY()));
+ return Point1D.of(LinearCombination.value(cos, point.getX(), sin, point.getY()));
}
/** {@inheritDoc} */
@Override
public Point2D toSpace(final Point1D point) {
final double abscissa = point.getX();
- return new Point2D(LinearCombination.value(abscissa, cos, -originOffset, sin),
+ return Point2D.of(LinearCombination.value(abscissa, cos, -originOffset, sin),
LinearCombination.value(abscissa, sin, originOffset, cos));
}
@@ -233,7 +233,7 @@ public class Line implements Hyperplane<Point2D>, Embedding<Point2D, Point1D> {
if (Math.abs(d) < tolerance) {
return null;
}
- return new Point2D(LinearCombination.value(cos, other.originOffset, -other.cos, originOffset) / d,
+ return Point2D.of(LinearCombination.value(cos, other.originOffset, -other.cos, originOffset) / d,
LinearCombination.value(sin, other.originOffset, -other.sin, originOffset) / d);
}
@@ -301,7 +301,7 @@ public class Line implements Hyperplane<Point2D>, Embedding<Point2D, Point1D> {
public Point2D getPointAt(final Point1D abscissa, final double offset) {
final double x = abscissa.getX();
final double dOffset = offset - originOffset;
- return new Point2D(LinearCombination.value(x, cos, dOffset, sin),
+ return Point2D.of(LinearCombination.value(x, cos, dOffset, sin),
LinearCombination.value(x, sin, -dOffset, cos));
}
@@ -468,7 +468,7 @@ public class Line implements Hyperplane<Point2D>, Embedding<Point2D, Point1D> {
public Point2D apply(final Point2D point) {
final double x = point.getX();
final double y = point.getY();
- return new Point2D(LinearCombination.value(cXX, x, cXY, y, cX1, 1),
+ return Point2D.of(LinearCombination.value(cXX, x, cXY, y, cX1, 1),
LinearCombination.value(cYX, x, cYY, y, cY1, 1));
}
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Point2D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Point2D.java
index e062b89..376d970 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Point2D.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Point2D.java
@@ -25,20 +25,20 @@ import org.apache.commons.numbers.arrays.LinearCombination;
public final class Point2D extends Cartesian2D implements EuclideanPoint<Point2D, Vector2D> {
/** Origin (coordinates: 0, 0). */
- public static final Point2D ZERO = new Point2D(0, 0);
+ public static final Point2D ZERO = Point2D.of(0, 0);
// CHECKSTYLE: stop ConstantName
/** A point with all coordinates set to NaN. */
- public static final Point2D NaN = new Point2D(Double.NaN, Double.NaN);
+ public static final Point2D NaN = Point2D.of(Double.NaN, Double.NaN);
// CHECKSTYLE: resume ConstantName
/** A point with all coordinates set to positive infinity. */
public static final Point2D POSITIVE_INFINITY =
- new Point2D(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
+ Point2D.of(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
/** A point with all coordinates set to negative infinity. */
public static final Point2D NEGATIVE_INFINITY =
- new Point2D(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY);
+ Point2D.of(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY);
/** Serializable UID. */
private static final long serialVersionUID = 266938651998679754L;
@@ -48,14 +48,14 @@ public final class Point2D extends Cartesian2D implements EuclideanPoint<Point2D
* @param x abscissa
* @param y ordinate
*/
- public Point2D(double x, double y) {
+ private Point2D(double x, double y) {
super(x, y);
}
/** {@inheritDoc} */
@Override
public Vector2D asVector() {
- return new Vector2D(getX(), getY());
+ return Vector2D.of(getX(), getY());
}
/** {@inheritDoc} */
@@ -79,7 +79,7 @@ public final class Point2D extends Cartesian2D implements EuclideanPoint<Point2D
/** {@inheritDoc} */
@Override
public Point2D add(Vector2D v) {
- return new Point2D(getX() + v.getX(), getY() + v.getY());
+ return Point2D.of(getX() + v.getX(), getY() + v.getY());
}
/**
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/PolygonsSet.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/PolygonsSet.java
index de79c32..e7ffbeb 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/PolygonsSet.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/PolygonsSet.java
@@ -158,10 +158,10 @@ public class PolygonsSet extends AbstractRegion<Point2D, Point1D> {
// too thin box, build an empty polygons set
return null;
}
- final Point2D minMin = new Point2D(xMin, yMin);
- final Point2D minMax = new Point2D(xMin, yMax);
- final Point2D maxMin = new Point2D(xMax, yMin);
- final Point2D maxMax = new Point2D(xMax, yMax);
+ final Point2D minMin = Point2D.of(xMin, yMin);
+ final Point2D minMax = Point2D.of(xMin, yMax);
+ final Point2D maxMin = Point2D.of(xMax, yMin);
+ final Point2D maxMax = Point2D.of(xMax, yMax);
return new Line[] {
new Line(minMin, maxMin, tolerance),
new Line(maxMin, maxMax, tolerance),
@@ -579,7 +579,7 @@ public class PolygonsSet extends AbstractRegion<Point2D, Point1D> {
setBarycenter(Point2D.NaN);
} else {
setSize(sum / 2);
- setBarycenter(new Point2D(sumX / (3 * sum), sumY / (3 * sum)));
+ setBarycenter(Point2D.of(sumX / (3 * sum), sumY / (3 * sum)));
}
}
@@ -661,8 +661,8 @@ public class PolygonsSet extends AbstractRegion<Point2D, Point1D> {
final Line line = loop.get(0).getLine();
vertices[i++] = new Point2D[] {
null,
- line.toSpace(new Point1D(-Float.MAX_VALUE)),
- line.toSpace(new Point1D(+Float.MAX_VALUE))
+ line.toSpace(Point1D.of(-Float.MAX_VALUE)),
+ line.toSpace(Point1D.of(+Float.MAX_VALUE))
};
} else if (loop.get(0).getStart() == null) {
// open loop with at least one real point
@@ -675,7 +675,7 @@ public class PolygonsSet extends AbstractRegion<Point2D, Point1D> {
double x = segment.getLine().toSubSpace(segment.getEnd()).getX();
x -= Math.max(1.0, Math.abs(x / 2));
array[j++] = null;
- array[j++] = segment.getLine().toSpace(new Point1D(x));
+ array[j++] = segment.getLine().toSpace(Point1D.of(x));
}
if (j < (array.length - 1)) {
@@ -685,7 +685,7 @@ public class PolygonsSet extends AbstractRegion<Point2D, Point1D> {
// last dummy point
double x = segment.getLine().toSubSpace(segment.getStart()).getX();
x += Math.max(1.0, Math.abs(x / 2));
- array[j++] = segment.getLine().toSpace(new Point1D(x));
+ array[j++] = segment.getLine().toSpace(Point1D.of(x));
}
}
@@ -1047,9 +1047,9 @@ public class PolygonsSet extends AbstractRegion<Point2D, Point1D> {
// find the 2D points
final Point2D startV = Double.isInfinite(i.getInf()) ?
- null : line.toSpace(new Point1D(i.getInf()));
+ null : line.toSpace(Point1D.of(i.getInf()));
final Point2D endV = Double.isInfinite(i.getSup()) ?
- null : line.toSpace(new Point1D(i.getSup()));
+ null : line.toSpace(Point1D.of(i.getSup()));
// recover the connectivity information
final BSPTree<Point2D> startN = selectClosest(startV, splitters);
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Segment.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Segment.java
index bc8b214..a728d61 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Segment.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Segment.java
@@ -100,7 +100,7 @@ public class Segment {
final double px = start.getX() + r * deltaX;
final double py = start.getY() + r * deltaY;
- final Point2D interPt = new Point2D(px, py);
+ final Point2D interPt = Point2D.of(px, py);
return interPt.distance(p);
}
}
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/SubLine.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/SubLine.java
index b9e63d6..94d2398 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/SubLine.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/SubLine.java
@@ -81,8 +81,8 @@ public class SubLine extends AbstractSubHyperplane<Point2D, Point1D> {
final List<Segment> segments = new ArrayList<>(list.size());
for (final Interval interval : list) {
- final Point2D start = line.toSpace(new Point1D(interval.getInf()));
- final Point2D end = line.toSpace(new Point1D(interval.getSup()));
+ final Point2D start = line.toSpace(Point1D.of(interval.getInf()));
+ final Point2D end = line.toSpace(Point1D.of(interval.getSup()));
segments.add(new Segment(start, end, line));
}
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Vector2D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Vector2D.java
index 0bc84d2..98ac4bc 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Vector2D.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Vector2D.java
@@ -25,32 +25,32 @@ import org.apache.commons.numbers.arrays.LinearCombination;
public final class Vector2D extends Cartesian2D implements EuclideanVector<Point2D, Vector2D> {
/** Zero vector (coordinates: 0, 0). */
- public static final Vector2D ZERO = new Vector2D(0, 0);
+ public static final Vector2D ZERO = Vector2D.of(0, 0);
/** Unit vector pointing in the direction of the positive x-axis. */
- public static final Vector2D PLUS_X = new Vector2D(1, 0);
+ public static final Vector2D PLUS_X = Vector2D.of(1, 0);
/** Unit vector pointing in the direction of the negative x-axis. */
- public static final Vector2D MINUS_X = new Vector2D(-1, 0);
+ public static final Vector2D MINUS_X = Vector2D.of(-1, 0);
/** Unit vector pointing in the direction of the positive y-axis. */
- public static final Vector2D PLUS_Y = new Vector2D(0, 1);
+ public static final Vector2D PLUS_Y = Vector2D.of(0, 1);
/** Unit vector pointing in the direction of the negative y-axis. */
- public static final Vector2D MINUS_Y = new Vector2D(0, -1);
+ public static final Vector2D MINUS_Y = Vector2D.of(0, -1);
// CHECKSTYLE: stop ConstantName
/** A vector with all coordinates set to NaN. */
- public static final Vector2D NaN = new Vector2D(Double.NaN, Double.NaN);
+ public static final Vector2D NaN = Vector2D.of(Double.NaN, Double.NaN);
// CHECKSTYLE: resume ConstantName
/** A vector with all coordinates set to positive infinity. */
public static final Vector2D POSITIVE_INFINITY =
- new Vector2D(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
+ Vector2D.of(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
/** A vector with all coordinates set to negative infinity. */
public static final Vector2D NEGATIVE_INFINITY =
- new Vector2D(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY);
+ Vector2D.of(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY);
/** Serializable UID */
private static final long serialVersionUID = 1746839897232305304L;
@@ -62,7 +62,7 @@ public final class Vector2D extends Cartesian2D implements EuclideanVector<Point
* @param x abscissa (first coordinate)
* @param y ordinate (second coordinate)
*/
- public Vector2D(double x, double y) {
+ private Vector2D(double x, double y) {
super(x, y);
}
@@ -77,7 +77,7 @@ public final class Vector2D extends Cartesian2D implements EuclideanVector<Point
/** {@inheritDoc} */
@Override
public Point2D asPoint() {
- return new Point2D(getX(), getY());
+ return Point2D.of(getX(), getY());
}
/** {@inheritDoc} */
@@ -117,31 +117,31 @@ public final class Vector2D extends Cartesian2D implements EuclideanVector<Point
/** {@inheritDoc} */
@Override
public Vector2D add(Vector2D v) {
- return new Vector2D(getX() + v.getX(), getY() + v.getY());
+ return Vector2D.of(getX() + v.getX(), getY() + v.getY());
}
/** {@inheritDoc} */
@Override
public Vector2D add(double factor, Vector2D v) {
- return new Vector2D(getX() + (factor * v.getX()), getY() + (factor * v.getY()));
+ return Vector2D.of(getX() + (factor * v.getX()), getY() + (factor * v.getY()));
}
/** {@inheritDoc} */
@Override
public Vector2D subtract(Vector2D v) {
- return new Vector2D(getX() - v.getX(), getY() - v.getY());
+ return Vector2D.of(getX() - v.getX(), getY() - v.getY());
}
/** {@inheritDoc} */
@Override
public Vector2D subtract(double factor, Vector2D v) {
- return new Vector2D(getX() - (factor * v.getX()), getY() - (factor * v.getY()));
+ return Vector2D.of(getX() - (factor * v.getX()), getY() - (factor * v.getY()));
}
/** {@inheritDoc} */
@Override
public Vector2D negate() {
- return new Vector2D(-getX(), -getY());
+ return Vector2D.of(-getX(), -getY());
}
/** {@inheritDoc} */
@@ -157,7 +157,7 @@ public final class Vector2D extends Cartesian2D implements EuclideanVector<Point
/** {@inheritDoc} */
@Override
public Vector2D scalarMultiply(double a) {
- return new Vector2D(a * getX(), a * getY());
+ return Vector2D.of(a * getX(), a * getY());
}
/** {@inheritDoc} */
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/core/partitioning/CharacterizationTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/core/partitioning/CharacterizationTest.java
index e2a94fb..dc28a43 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/core/partitioning/CharacterizationTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/core/partitioning/CharacterizationTest.java
@@ -38,7 +38,7 @@ public class CharacterizationTest {
public void testCharacterize_insideLeaf() {
// arrange
BSPTree<Point2D> tree = new BSPTree<>(Boolean.TRUE);
- SubLine sub = buildSubLine(new Point2D(0, -1), new Point2D(0, 1));
+ SubLine sub = buildSubLine(Point2D.of(0, -1), Point2D.of(0, 1));
// act
Characterization<Point2D> ch = new Characterization<>(tree, sub);
@@ -57,7 +57,7 @@ public class CharacterizationTest {
public void testCharacterize_outsideLeaf() {
// arrange
BSPTree<Point2D> tree = new BSPTree<>(Boolean.FALSE);
- SubLine sub = buildSubLine(new Point2D(0, -1), new Point2D(0, 1));
+ SubLine sub = buildSubLine(Point2D.of(0, -1), Point2D.of(0, 1));
// act
Characterization<Point2D> ch = new Characterization<>(tree, sub);
@@ -76,9 +76,9 @@ public class CharacterizationTest {
public void testCharacterize_onPlusSide() {
// arrange
BSPTree<Point2D> tree = new BSPTree<>(Boolean.TRUE);
- cut(tree, buildLine(new Point2D(0, 0), new Point2D(1, 0)));
+ cut(tree, buildLine(Point2D.of(0, 0), Point2D.of(1, 0)));
- SubLine sub = buildSubLine(new Point2D(0, -1), new Point2D(0, -2));
+ SubLine sub = buildSubLine(Point2D.of(0, -1), Point2D.of(0, -2));
// act
Characterization<Point2D> ch = new Characterization<>(tree, sub);
@@ -97,9 +97,9 @@ public class CharacterizationTest {
public void testCharacterize_onMinusSide() {
// arrange
BSPTree<Point2D> tree = new BSPTree<>(Boolean.TRUE);
- cut(tree, buildLine(new Point2D(0, 0), new Point2D(1, 0)));
+ cut(tree, buildLine(Point2D.of(0, 0), Point2D.of(1, 0)));
- SubLine sub = buildSubLine(new Point2D(0, 1), new Point2D(0, 2));
+ SubLine sub = buildSubLine(Point2D.of(0, 1), Point2D.of(0, 2));
// act
Characterization<Point2D> ch = new Characterization<>(tree, sub);
@@ -118,9 +118,9 @@ public class CharacterizationTest {
public void testCharacterize_onBothSides() {
// arrange
BSPTree<Point2D> tree = new BSPTree<>(Boolean.TRUE);
- cut(tree, buildLine(new Point2D(0, 0), new Point2D(1, 0)));
+ cut(tree, buildLine(Point2D.of(0, 0), Point2D.of(1, 0)));
- SubLine sub = buildSubLine(new Point2D(0, -1), new Point2D(0, 1));
+ SubLine sub = buildSubLine(Point2D.of(0, -1), Point2D.of(0, 1));
// act
Characterization<Point2D> ch = new Characterization<>(tree, sub);
@@ -131,8 +131,8 @@ public class CharacterizationTest {
SubLine inside = (SubLine) ch.insideTouching();
Assert.assertEquals(1, inside.getSegments().size());
- assertVectorEquals(new Point2D(0, 0), inside.getSegments().get(0).getStart());
- assertVectorEquals(new Point2D(0, 1), inside.getSegments().get(0).getEnd());
+ assertVectorEquals(Point2D.of(0, 0), inside.getSegments().get(0).getStart());
+ assertVectorEquals(Point2D.of(0, 1), inside.getSegments().get(0).getEnd());
Assert.assertEquals(1, size(ch.getInsideSplitters()));
Iterator<BSPTree<Point2D>> insideSplitterIter = ch.getInsideSplitters().iterator();
@@ -143,8 +143,8 @@ public class CharacterizationTest {
SubLine outside = (SubLine) ch.outsideTouching();
Assert.assertEquals(1, outside.getSegments().size());
- assertVectorEquals(new Point2D(0, -1), outside.getSegments().get(0).getStart());
- assertVectorEquals(new Point2D(0, 0), outside.getSegments().get(0).getEnd());
+ assertVectorEquals(Point2D.of(0, -1), outside.getSegments().get(0).getStart());
+ assertVectorEquals(Point2D.of(0, 0), outside.getSegments().get(0).getEnd());
Assert.assertEquals(1, size(ch.getOutsideSplitters()));
Iterator<BSPTree<Point2D>> outsideSplitterIter = ch.getOutsideSplitters().iterator();
@@ -155,10 +155,10 @@ public class CharacterizationTest {
public void testCharacterize_multipleSplits_reunitedOnPlusSide() {
// arrange
BSPTree<Point2D> tree = new BSPTree<>(Boolean.TRUE);
- cut(tree, buildLine(new Point2D(0, 0), new Point2D(1, 0)));
- cut(tree.getMinus(), buildLine(new Point2D(-1, 0), new Point2D(0, 1)));
+ cut(tree, buildLine(Point2D.of(0, 0), Point2D.of(1, 0)));
+ cut(tree.getMinus(), buildLine(Point2D.of(-1, 0), Point2D.of(0, 1)));
- SubLine sub = buildSubLine(new Point2D(0, -2), new Point2D(0, 2));
+ SubLine sub = buildSubLine(Point2D.of(0, -2), Point2D.of(0, 2));
// act
Characterization<Point2D> ch = new Characterization<>(tree, sub);
@@ -169,8 +169,8 @@ public class CharacterizationTest {
SubLine inside = (SubLine) ch.insideTouching();
Assert.assertEquals(1, inside.getSegments().size());
- assertVectorEquals(new Point2D(0, 1), inside.getSegments().get(0).getStart());
- assertVectorEquals(new Point2D(0, 2), inside.getSegments().get(0).getEnd());
+ assertVectorEquals(Point2D.of(0, 1), inside.getSegments().get(0).getStart());
+ assertVectorEquals(Point2D.of(0, 2), inside.getSegments().get(0).getEnd());
Assert.assertEquals(2, size(ch.getInsideSplitters()));
Iterator<BSPTree<Point2D>> insideSplitterIter = ch.getInsideSplitters().iterator();
@@ -182,8 +182,8 @@ public class CharacterizationTest {
SubLine outside = (SubLine) ch.outsideTouching();
Assert.assertEquals(1, outside.getSegments().size());
- assertVectorEquals(new Point2D(0, -2), outside.getSegments().get(0).getStart());
- assertVectorEquals(new Point2D(0, 1), outside.getSegments().get(0).getEnd());
+ assertVectorEquals(Point2D.of(0, -2), outside.getSegments().get(0).getStart());
+ assertVectorEquals(Point2D.of(0, 1), outside.getSegments().get(0).getEnd());
Assert.assertEquals(2, size(ch.getOutsideSplitters()));
Iterator<BSPTree<Point2D>> outsideSplitterIter = ch.getOutsideSplitters().iterator();
@@ -195,11 +195,11 @@ public class CharacterizationTest {
public void testCharacterize_multipleSplits_reunitedOnMinusSide() {
// arrange
BSPTree<Point2D> tree = new BSPTree<>(Boolean.TRUE);
- cut(tree, buildLine(new Point2D(0, 0), new Point2D(1, 0)));
- cut(tree.getMinus(), buildLine(new Point2D(-1, 0), new Point2D(0, 1)));
- cut(tree.getMinus().getPlus(), buildLine(new Point2D(-0.5, 0.5), new Point2D(0, 0)));
+ cut(tree, buildLine(Point2D.of(0, 0), Point2D.of(1, 0)));
+ cut(tree.getMinus(), buildLine(Point2D.of(-1, 0), Point2D.of(0, 1)));
+ cut(tree.getMinus().getPlus(), buildLine(Point2D.of(-0.5, 0.5), Point2D.of(0, 0)));
- SubLine sub = buildSubLine(new Point2D(0, -2), new Point2D(0, 2));
+ SubLine sub = buildSubLine(Point2D.of(0, -2), Point2D.of(0, 2));
// act
Characterization<Point2D> ch = new Characterization<>(tree, sub);
@@ -210,8 +210,8 @@ public class CharacterizationTest {
SubLine inside = (SubLine) ch.insideTouching();
Assert.assertEquals(1, inside.getSegments().size());
- assertVectorEquals(new Point2D(0, 0), inside.getSegments().get(0).getStart());
- assertVectorEquals(new Point2D(0, 2), inside.getSegments().get(0).getEnd());
+ assertVectorEquals(Point2D.of(0, 0), inside.getSegments().get(0).getStart());
+ assertVectorEquals(Point2D.of(0, 2), inside.getSegments().get(0).getEnd());
Assert.assertEquals(2, size(ch.getInsideSplitters()));
Iterator<BSPTree<Point2D>> insideSplitterIter = ch.getInsideSplitters().iterator();
@@ -223,8 +223,8 @@ public class CharacterizationTest {
SubLine outside = (SubLine) ch.outsideTouching();
Assert.assertEquals(1, outside.getSegments().size());
- assertVectorEquals(new Point2D(0, -2), outside.getSegments().get(0).getStart());
- assertVectorEquals(new Point2D(0, 0), outside.getSegments().get(0).getEnd());
+ assertVectorEquals(Point2D.of(0, -2), outside.getSegments().get(0).getStart());
+ assertVectorEquals(Point2D.of(0, 0), outside.getSegments().get(0).getEnd());
Assert.assertEquals(1, size(ch.getOutsideSplitters()));
Iterator<BSPTree<Point2D>> outsideSplitterIter = ch.getOutsideSplitters().iterator();
@@ -235,9 +235,9 @@ public class CharacterizationTest {
public void testCharacterize_onHyperplane_sameOrientation() {
// arrange
BSPTree<Point2D> tree = new BSPTree<>(Boolean.TRUE);
- cut(tree, buildLine(new Point2D(0, 0), new Point2D(1, 0)));
+ cut(tree, buildLine(Point2D.of(0, 0), Point2D.of(1, 0)));
- SubLine sub = buildSubLine(new Point2D(0, 0), new Point2D(1, 0));
+ SubLine sub = buildSubLine(Point2D.of(0, 0), Point2D.of(1, 0));
// act
Characterization<Point2D> ch = new Characterization<>(tree, sub);
@@ -256,9 +256,9 @@ public class CharacterizationTest {
public void testCharacterize_onHyperplane_oppositeOrientation() {
// arrange
BSPTree<Point2D> tree = new BSPTree<>(Boolean.TRUE);
- cut(tree, buildLine(new Point2D(0, 0), new Point2D(1, 0)));
+ cut(tree, buildLine(Point2D.of(0, 0), Point2D.of(1, 0)));
- SubLine sub = buildSubLine(new Point2D(1, 0), new Point2D(0, 0));
+ SubLine sub = buildSubLine(Point2D.of(1, 0), Point2D.of(0, 0));
// act
Characterization<Point2D> ch = new Characterization<>(tree, sub);
@@ -277,10 +277,10 @@ public class CharacterizationTest {
public void testCharacterize_onHyperplane_multipleSplits_sameOrientation() {
// arrange
BSPTree<Point2D> tree = new BSPTree<>(Boolean.TRUE);
- cut(tree, buildLine(new Point2D(0, 0), new Point2D(1, 0)));
- cut(tree.getMinus(), buildLine(new Point2D(-1, 0), new Point2D(0, 1)));
+ cut(tree, buildLine(Point2D.of(0, 0), Point2D.of(1, 0)));
+ cut(tree.getMinus(), buildLine(Point2D.of(-1, 0), Point2D.of(0, 1)));
- SubLine sub = buildSubLine(new Point2D(-2, 0), new Point2D(2, 0));
+ SubLine sub = buildSubLine(Point2D.of(-2, 0), Point2D.of(2, 0));
// act
Characterization<Point2D> ch = new Characterization<>(tree, sub);
@@ -291,8 +291,8 @@ public class CharacterizationTest {
SubLine inside = (SubLine) ch.insideTouching();
Assert.assertEquals(1, inside.getSegments().size());
- assertVectorEquals(new Point2D(-2, 0), inside.getSegments().get(0).getStart());
- assertVectorEquals(new Point2D(-1, 0), inside.getSegments().get(0).getEnd());
+ assertVectorEquals(Point2D.of(-2, 0), inside.getSegments().get(0).getStart());
+ assertVectorEquals(Point2D.of(-1, 0), inside.getSegments().get(0).getEnd());
Assert.assertEquals(1, size(ch.getInsideSplitters()));
Iterator<BSPTree<Point2D>> insideSplitterIter = ch.getInsideSplitters().iterator();
@@ -303,8 +303,8 @@ public class CharacterizationTest {
SubLine outside = (SubLine) ch.outsideTouching();
Assert.assertEquals(1, outside.getSegments().size());
- assertVectorEquals(new Point2D(-1, 0), outside.getSegments().get(0).getStart());
- assertVectorEquals(new Point2D(2, 0), outside.getSegments().get(0).getEnd());
+ assertVectorEquals(Point2D.of(-1, 0), outside.getSegments().get(0).getStart());
+ assertVectorEquals(Point2D.of(2, 0), outside.getSegments().get(0).getEnd());
Assert.assertEquals(1, size(ch.getOutsideSplitters()));
Iterator<BSPTree<Point2D>> outsideSplitterIter = ch.getOutsideSplitters().iterator();
@@ -315,10 +315,10 @@ public class CharacterizationTest {
public void testCharacterize_onHyperplane_multipleSplits_oppositeOrientation() {
// arrange
BSPTree<Point2D> tree = new BSPTree<>(Boolean.TRUE);
- cut(tree, buildLine(new Point2D(0, 0), new Point2D(1, 0)));
- cut(tree.getMinus(), buildLine(new Point2D(-1, 0), new Point2D(0, 1)));
+ cut(tree, buildLine(Point2D.of(0, 0), Point2D.of(1, 0)));
+ cut(tree.getMinus(), buildLine(Point2D.of(-1, 0), Point2D.of(0, 1)));
- SubLine sub = buildSubLine(new Point2D(2, 0), new Point2D(-2, 0));
+ SubLine sub = buildSubLine(Point2D.of(2, 0), Point2D.of(-2, 0));
// act
Characterization<Point2D> ch = new Characterization<>(tree, sub);
@@ -329,8 +329,8 @@ public class CharacterizationTest {
SubLine inside = (SubLine) ch.insideTouching();
Assert.assertEquals(1, inside.getSegments().size());
- assertVectorEquals(new Point2D(-1, 0), inside.getSegments().get(0).getStart());
- assertVectorEquals(new Point2D(-2, 0), inside.getSegments().get(0).getEnd());
+ assertVectorEquals(Point2D.of(-1, 0), inside.getSegments().get(0).getStart());
+ assertVectorEquals(Point2D.of(-2, 0), inside.getSegments().get(0).getEnd());
Assert.assertEquals(1, size(ch.getInsideSplitters()));
Iterator<BSPTree<Point2D>> insideSplitterIter = ch.getInsideSplitters().iterator();
@@ -341,8 +341,8 @@ public class CharacterizationTest {
SubLine outside = (SubLine) ch.outsideTouching();
Assert.assertEquals(1, outside.getSegments().size());
- assertVectorEquals(new Point2D(2, 0), outside.getSegments().get(0).getStart());
- assertVectorEquals(new Point2D(-1, 0), outside.getSegments().get(0).getEnd());
+ assertVectorEquals(Point2D.of(2, 0), outside.getSegments().get(0).getStart());
+ assertVectorEquals(Point2D.of(-1, 0), outside.getSegments().get(0).getEnd());
Assert.assertEquals(1, size(ch.getOutsideSplitters()));
Iterator<BSPTree<Point2D>> outsideSplitterIter = ch.getOutsideSplitters().iterator();
@@ -355,7 +355,7 @@ public class CharacterizationTest {
PolygonsSet poly = new PolygonsSet(0, 1, 0, 1, TEST_TOLERANCE);
BSPTree<Point2D> tree = poly.getTree(false);
- SubLine sub = buildSubLine(new Point2D(2, 0), new Point2D(-2, 0));
+ SubLine sub = buildSubLine(Point2D.of(2, 0), Point2D.of(-2, 0));
// act
Characterization<Point2D> ch = new Characterization<>(tree, sub);
@@ -366,8 +366,8 @@ public class CharacterizationTest {
SubLine inside = (SubLine) ch.insideTouching();
Assert.assertEquals(1, inside.getSegments().size());
- assertVectorEquals(new Point2D(1, 0), inside.getSegments().get(0).getStart());
- assertVectorEquals(new Point2D(0, 0), inside.getSegments().get(0).getEnd());
+ assertVectorEquals(Point2D.of(1, 0), inside.getSegments().get(0).getStart());
+ assertVectorEquals(Point2D.of(0, 0), inside.getSegments().get(0).getEnd());
Assert.assertEquals(2, size(ch.getInsideSplitters()));
@@ -376,10 +376,10 @@ public class CharacterizationTest {
SubLine outside = (SubLine) ch.outsideTouching();
Assert.assertEquals(2, outside.getSegments().size());
- assertVectorEquals(new Point2D(2, 0), outside.getSegments().get(0).getStart());
- assertVectorEquals(new Point2D(1, 0), outside.getSegments().get(0).getEnd());
- assertVectorEquals(new Point2D(0, 0), outside.getSegments().get(1).getStart());
- assertVectorEquals(new Point2D(-2, 0), outside.getSegments().get(1).getEnd());
+ assertVectorEquals(Point2D.of(2, 0), outside.getSegments().get(0).getStart());
+ assertVectorEquals(Point2D.of(1, 0), outside.getSegments().get(0).getEnd());
+ assertVectorEquals(Point2D.of(0, 0), outside.getSegments().get(1).getStart());
+ assertVectorEquals(Point2D.of(-2, 0), outside.getSegments().get(1).getEnd());
Assert.assertEquals(2, size(ch.getOutsideSplitters()));
}
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 9fb0df1..e3ebdf9 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
@@ -181,7 +181,7 @@ public class EuclideanTestUtils {
@Override
public OrientedPoint parseHyperplane()
throws IOException, ParseException {
- return new OrientedPoint(new Point1D(getNumber()), getBoolean(), getNumber());
+ return new OrientedPoint(Point1D.of(getNumber()), getBoolean(), getNumber());
}
};
@@ -202,7 +202,7 @@ public class EuclideanTestUtils {
@Override
public Line parseHyperplane()
throws IOException, ParseException {
- return new Line(new Point2D(getNumber(), getNumber()), getNumber(), getNumber());
+ return new Line(Point2D.of(getNumber(), getNumber()), getNumber(), getNumber());
}
};
@@ -223,8 +223,8 @@ public class EuclideanTestUtils {
@Override
public Plane parseHyperplane()
throws IOException, ParseException {
- return new Plane(new Point3D(getNumber(), getNumber(), getNumber()),
- new Vector3D(getNumber(), getNumber(), getNumber()),
+ return new Plane(Point3D.of(getNumber(), getNumber(), getNumber()),
+ Vector3D.of(getNumber(), getNumber(), getNumber()),
getNumber());
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/IntervalsSetTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/IntervalsSetTest.java
index dd70adf..f032f7b 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/IntervalsSetTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/IntervalsSetTest.java
@@ -150,7 +150,7 @@ public class IntervalsSetTest {
Assert.assertEquals(9.0, set.getSup(), TEST_TOLERANCE);
Assert.assertEquals(10.0, set.getSize(), TEST_TOLERANCE);
Assert.assertEquals(0.0, set.getBoundarySize(), TEST_TOLERANCE);
- EuclideanTestUtils.assertCoordinatesEqual(new Point1D(4.0), set.getBarycenter(), TEST_TOLERANCE);
+ EuclideanTestUtils.assertCoordinatesEqual(Point1D.of(4.0), set.getBarycenter(), TEST_TOLERANCE);
List<Interval> intervals = set.asList();
Assert.assertEquals(1, intervals.size());
@@ -176,7 +176,7 @@ public class IntervalsSetTest {
Assert.assertEquals(1.0, set.getSup(), TEST_TOLERANCE);
Assert.assertEquals(0.0, set.getSize(), TEST_TOLERANCE);
Assert.assertEquals(0.0, set.getBoundarySize(), TEST_TOLERANCE);
- EuclideanTestUtils.assertCoordinatesEqual(new Point1D(1.0), set.getBarycenter(), TEST_TOLERANCE);
+ EuclideanTestUtils.assertCoordinatesEqual(Point1D.of(1.0), set.getBarycenter(), TEST_TOLERANCE);
List<Interval> intervals = set.asList();
Assert.assertEquals(1, intervals.size());
@@ -294,7 +294,7 @@ public class IntervalsSetTest {
Assert.assertEquals(9.0, set.getSup(), TEST_TOLERANCE);
Assert.assertEquals(10.0, set.getSize(), TEST_TOLERANCE);
Assert.assertEquals(0.0, set.getBoundarySize(), TEST_TOLERANCE);
- EuclideanTestUtils.assertCoordinatesEqual(new Point1D(4.0), set.getBarycenter(), TEST_TOLERANCE);
+ EuclideanTestUtils.assertCoordinatesEqual(Point1D.of(4.0), set.getBarycenter(), TEST_TOLERANCE);
List<Interval> intervals = set.asList();
Assert.assertEquals(1, intervals.size());
@@ -327,7 +327,7 @@ public class IntervalsSetTest {
Assert.assertEquals(9.0, set.getSup(), TEST_TOLERANCE);
Assert.assertEquals(7.0, set.getSize(), TEST_TOLERANCE);
Assert.assertEquals(0.0, set.getBoundarySize(), TEST_TOLERANCE);
- EuclideanTestUtils.assertCoordinatesEqual(new Point1D(29.5 / 7.0), set.getBarycenter(), TEST_TOLERANCE);
+ EuclideanTestUtils.assertCoordinatesEqual(Point1D.of(29.5 / 7.0), set.getBarycenter(), TEST_TOLERANCE);
List<Interval> intervals = set.asList();
Assert.assertEquals(2, intervals.size());
@@ -365,7 +365,7 @@ public class IntervalsSetTest {
EuclideanTestUtils.assertPositiveInfinity(set.getSup());
EuclideanTestUtils.assertPositiveInfinity(set.getSize());
Assert.assertEquals(0.0, set.getBoundarySize(), TEST_TOLERANCE);
- EuclideanTestUtils.assertCoordinatesEqual(new Point1D(Double.NaN), set.getBarycenter(), TEST_TOLERANCE);
+ EuclideanTestUtils.assertCoordinatesEqual(Point1D.of(Double.NaN), set.getBarycenter(), TEST_TOLERANCE);
List<Interval> intervals = set.asList();
Assert.assertEquals(4, intervals.size());
@@ -461,31 +461,31 @@ public class IntervalsSetTest {
IntervalsSet set = new IntervalsSet(boundaries, TEST_TOLERANCE);
// act/assert
- assertProjection(new Point1D(-2), -1, set, new Point1D(-3));
- assertProjection(new Point1D(-2), 0, set, new Point1D(-2));
- assertProjection(new Point1D(-2), 0.1, set, new Point1D(-1.9));
+ assertProjection(Point1D.of(-2), -1, set, Point1D.of(-3));
+ assertProjection(Point1D.of(-2), 0, set, Point1D.of(-2));
+ assertProjection(Point1D.of(-2), 0.1, set, Point1D.of(-1.9));
- assertProjection(new Point1D(-1), 0.5, set, new Point1D(-1.5));
- assertProjection(new Point1D(-1), 0.1, set, new Point1D(-1.1));
- assertProjection(new Point1D(-1), 0, set, new Point1D(-1));
- assertProjection(new Point1D(-1), -1, set, new Point1D(0));
+ assertProjection(Point1D.of(-1), 0.5, set, Point1D.of(-1.5));
+ assertProjection(Point1D.of(-1), 0.1, set, Point1D.of(-1.1));
+ assertProjection(Point1D.of(-1), 0, set, Point1D.of(-1));
+ assertProjection(Point1D.of(-1), -1, set, Point1D.of(0));
- assertProjection(new Point1D(2), -1, set, new Point1D(1));
- assertProjection(new Point1D(2), 0, set, new Point1D(2));
- assertProjection(new Point1D(2), 1, set, new Point1D(3));
+ assertProjection(Point1D.of(2), -1, set, Point1D.of(1));
+ assertProjection(Point1D.of(2), 0, set, Point1D.of(2));
+ assertProjection(Point1D.of(2), 1, set, Point1D.of(3));
- assertProjection(new Point1D(5), 1, set, new Point1D(4));
- assertProjection(new Point1D(5), 0, set, new Point1D(5));
+ assertProjection(Point1D.of(5), 1, set, Point1D.of(4));
+ assertProjection(Point1D.of(5), 0, set, Point1D.of(5));
- assertProjection(new Point1D(5), -1, set, new Point1D(6));
- assertProjection(new Point1D(5), -2, set, new Point1D(7));
+ assertProjection(Point1D.of(5), -1, set, Point1D.of(6));
+ assertProjection(Point1D.of(5), -2, set, Point1D.of(7));
- assertProjection(new Point1D(9), -1, set, new Point1D(8));
- assertProjection(new Point1D(9), 0, set, new Point1D(9));
- assertProjection(new Point1D(9), 0.1, set, new Point1D(9.1));
+ assertProjection(Point1D.of(9), -1, set, Point1D.of(8));
+ assertProjection(Point1D.of(9), 0, set, Point1D.of(9));
+ assertProjection(Point1D.of(9), 0.1, set, Point1D.of(9.1));
- assertProjection(new Point1D(10), 0, set, new Point1D(10));
- assertProjection(new Point1D(10), -1, set, new Point1D(11));
+ assertProjection(Point1D.of(10), 0, set, Point1D.of(10));
+ assertProjection(Point1D.of(10), -1, set, Point1D.of(11));
}
@Test
@@ -493,11 +493,11 @@ public class IntervalsSetTest {
IntervalsSet set = new IntervalsSet(2.3, 5.7, 1.0e-10);
Assert.assertEquals(3.4, set.getSize(), 1.0e-10);
Assert.assertEquals(4.0, set.getBarycenter().getX(), 1.0e-10);
- Assert.assertEquals(Region.Location.BOUNDARY, set.checkPoint(new Point1D(2.3)));
- Assert.assertEquals(Region.Location.BOUNDARY, set.checkPoint(new Point1D(5.7)));
- Assert.assertEquals(Region.Location.OUTSIDE, set.checkPoint(new Point1D(1.2)));
- Assert.assertEquals(Region.Location.OUTSIDE, set.checkPoint(new Point1D(8.7)));
- Assert.assertEquals(Region.Location.INSIDE, set.checkPoint(new Point1D(3.0)));
+ Assert.assertEquals(Region.Location.BOUNDARY, set.checkPoint(Point1D.of(2.3)));
+ Assert.assertEquals(Region.Location.BOUNDARY, set.checkPoint(Point1D.of(5.7)));
+ Assert.assertEquals(Region.Location.OUTSIDE, set.checkPoint(Point1D.of(1.2)));
+ Assert.assertEquals(Region.Location.OUTSIDE, set.checkPoint(Point1D.of(8.7)));
+ Assert.assertEquals(Region.Location.INSIDE, set.checkPoint(Point1D.of(3.0)));
Assert.assertEquals(2.3, set.getInf(), 1.0e-10);
Assert.assertEquals(5.7, set.getSup(), 1.0e-10);
}
@@ -505,11 +505,11 @@ public class IntervalsSetTest {
@Test
public void testInfinite() {
IntervalsSet set = new IntervalsSet(9.0, Double.POSITIVE_INFINITY, 1.0e-10);
- Assert.assertEquals(Region.Location.BOUNDARY, set.checkPoint(new Point1D(9.0)));
- Assert.assertEquals(Region.Location.OUTSIDE, set.checkPoint(new Point1D(8.4)));
+ Assert.assertEquals(Region.Location.BOUNDARY, set.checkPoint(Point1D.of(9.0)));
+ Assert.assertEquals(Region.Location.OUTSIDE, set.checkPoint(Point1D.of(8.4)));
for (double e = 1.0; e <= 6.0; e += 1.0) {
Assert.assertEquals(Region.Location.INSIDE,
- set.checkPoint(new Point1D(Math.pow(10.0, e))));
+ set.checkPoint(Point1D.of(Math.pow(10.0, e))));
}
Assert.assertTrue(Double.isInfinite(set.getSize()));
Assert.assertEquals(9.0, set.getInf(), 1.0e-10);
@@ -558,7 +558,7 @@ public class IntervalsSetTest {
}
private void assertLocation(Region.Location location, IntervalsSet set, double pt) {
- Assert.assertEquals(location, set.checkPoint(new Point1D(pt)));
+ Assert.assertEquals(location, set.checkPoint(Point1D.of(pt)));
}
private void assertInterval(double expectedInf, double expectedSup, Interval actual, double tolerance) {
@@ -581,6 +581,6 @@ public class IntervalsSetTest {
private SubOrientedPoint subOrientedPoint(double location, boolean direct, double tolerance) {
// the remaining region isn't necessary for creating 1D boundaries so we can set it to null here
- return new SubOrientedPoint(new OrientedPoint(new Point1D(location), direct, tolerance), null);
+ return new SubOrientedPoint(new OrientedPoint(Point1D.of(location), direct, tolerance), null);
}
}
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 a986b91..37140ca 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
@@ -26,7 +26,7 @@ public class OrientedPointTest {
@Test
public void testConstructor() {
// act
- OrientedPoint pt = new OrientedPoint(new Point1D(2.0), true, 1e-5);
+ OrientedPoint pt = new OrientedPoint(Point1D.of(2.0), true, 1e-5);
// assert
Assert.assertEquals(2.0, pt.getLocation().getX(), Precision.EPSILON);
@@ -37,7 +37,7 @@ public class OrientedPointTest {
@Test
public void testCopySelf() {
// arrange
- OrientedPoint orig = new OrientedPoint(new Point1D(2.0), true, 1e-5);
+ OrientedPoint orig = new OrientedPoint(Point1D.of(2.0), true, 1e-5);
// act
OrientedPoint copy = orig.copySelf();
@@ -52,37 +52,37 @@ public class OrientedPointTest {
@Test
public void testGetOffset_direct_point() {
// arrange
- OrientedPoint pt = new OrientedPoint(new Point1D(-1.0), true, 1e-5);
+ OrientedPoint pt = new OrientedPoint(Point1D.of(-1.0), true, 1e-5);
// act/assert
- Assert.assertEquals(-99, pt.getOffset(new Point1D(-100)), Precision.EPSILON);
- Assert.assertEquals(-1, pt.getOffset(new Point1D(-2)), Precision.EPSILON);
- Assert.assertEquals(-0.01, pt.getOffset(new Point1D(-1.01)), Precision.EPSILON);
- Assert.assertEquals(0.0, pt.getOffset(new Point1D(-1.0)), Precision.EPSILON);
- Assert.assertEquals(0.01, pt.getOffset(new Point1D(-0.99)), Precision.EPSILON);
- Assert.assertEquals(1, pt.getOffset(new Point1D(0)), Precision.EPSILON);
- Assert.assertEquals(101, pt.getOffset(new Point1D(100)), Precision.EPSILON);
+ Assert.assertEquals(-99, pt.getOffset(Point1D.of(-100)), Precision.EPSILON);
+ Assert.assertEquals(-1, pt.getOffset(Point1D.of(-2)), Precision.EPSILON);
+ Assert.assertEquals(-0.01, pt.getOffset(Point1D.of(-1.01)), Precision.EPSILON);
+ Assert.assertEquals(0.0, pt.getOffset(Point1D.of(-1.0)), Precision.EPSILON);
+ Assert.assertEquals(0.01, pt.getOffset(Point1D.of(-0.99)), Precision.EPSILON);
+ Assert.assertEquals(1, pt.getOffset(Point1D.of(0)), Precision.EPSILON);
+ Assert.assertEquals(101, pt.getOffset(Point1D.of(100)), Precision.EPSILON);
}
@Test
public void testGetOffset_notDirect_point() {
// arrange
- OrientedPoint pt = new OrientedPoint(new Point1D(-1.0), false, 1e-5);
+ OrientedPoint pt = new OrientedPoint(Point1D.of(-1.0), false, 1e-5);
// act/assert
- Assert.assertEquals(99, pt.getOffset(new Point1D(-100)), Precision.EPSILON);
- Assert.assertEquals(1, pt.getOffset(new Point1D(-2)), Precision.EPSILON);
- Assert.assertEquals(0.01, pt.getOffset(new Point1D(-1.01)), Precision.EPSILON);
- Assert.assertEquals(0.0, pt.getOffset(new Point1D(-1.0)), Precision.EPSILON);
- Assert.assertEquals(-0.01, pt.getOffset(new Point1D(-0.99)), Precision.EPSILON);
- Assert.assertEquals(-1, pt.getOffset(new Point1D(0)), Precision.EPSILON);
- Assert.assertEquals(-101, pt.getOffset(new Point1D(100)), Precision.EPSILON);
+ Assert.assertEquals(99, pt.getOffset(Point1D.of(-100)), Precision.EPSILON);
+ Assert.assertEquals(1, pt.getOffset(Point1D.of(-2)), Precision.EPSILON);
+ Assert.assertEquals(0.01, pt.getOffset(Point1D.of(-1.01)), Precision.EPSILON);
+ Assert.assertEquals(0.0, pt.getOffset(Point1D.of(-1.0)), Precision.EPSILON);
+ Assert.assertEquals(-0.01, pt.getOffset(Point1D.of(-0.99)), Precision.EPSILON);
+ Assert.assertEquals(-1, pt.getOffset(Point1D.of(0)), Precision.EPSILON);
+ Assert.assertEquals(-101, pt.getOffset(Point1D.of(100)), Precision.EPSILON);
}
@Test
public void testWholeHyperplane() {
// arrange
- OrientedPoint pt = new OrientedPoint(new Point1D(1.0), false, 1e-5);
+ OrientedPoint pt = new OrientedPoint(Point1D.of(1.0), false, 1e-5);
// act
SubOrientedPoint subPt = pt.wholeHyperplane();
@@ -95,7 +95,7 @@ public class OrientedPointTest {
@Test
public void testWholeSpace() {
// arrange
- OrientedPoint pt = new OrientedPoint(new Point1D(1.0), false, 1e-5);
+ OrientedPoint pt = new OrientedPoint(Point1D.of(1.0), false, 1e-5);
// act
IntervalsSet set = pt.wholeSpace();
@@ -108,10 +108,10 @@ public class OrientedPointTest {
@Test
public void testSameOrientationAs() {
// arrange
- OrientedPoint notDirect1 = new OrientedPoint(new Point1D(1.0), false, 1e-5);
- OrientedPoint notDirect2 = new OrientedPoint(new Point1D(1.0), false, 1e-5);
- OrientedPoint direct1 = new OrientedPoint(new Point1D(1.0), true, 1e-5);
- OrientedPoint direct2 = new OrientedPoint(new Point1D(1.0), true, 1e-5);
+ OrientedPoint notDirect1 = new OrientedPoint(Point1D.of(1.0), false, 1e-5);
+ OrientedPoint notDirect2 = new OrientedPoint(Point1D.of(1.0), false, 1e-5);
+ OrientedPoint direct1 = new OrientedPoint(Point1D.of(1.0), true, 1e-5);
+ OrientedPoint direct2 = new OrientedPoint(Point1D.of(1.0), true, 1e-5);
// act/assert
Assert.assertTrue(notDirect1.sameOrientationAs(notDirect1));
@@ -129,19 +129,19 @@ public class OrientedPointTest {
@Test
public void testProject() {
// arrange
- OrientedPoint pt = new OrientedPoint(new Point1D(1.0), true, 1e-5);
+ OrientedPoint pt = new OrientedPoint(Point1D.of(1.0), true, 1e-5);
// act/assert
- Assert.assertEquals(1.0, pt.project(new Point1D(-1.0)).getX(), Precision.EPSILON);
- Assert.assertEquals(1.0, pt.project(new Point1D(0.0)).getX(), Precision.EPSILON);
- Assert.assertEquals(1.0, pt.project(new Point1D(1.0)).getX(), Precision.EPSILON);
- Assert.assertEquals(1.0, pt.project(new Point1D(100.0)).getX(), Precision.EPSILON);
+ Assert.assertEquals(1.0, pt.project(Point1D.of(-1.0)).getX(), Precision.EPSILON);
+ Assert.assertEquals(1.0, pt.project(Point1D.of(0.0)).getX(), Precision.EPSILON);
+ Assert.assertEquals(1.0, pt.project(Point1D.of(1.0)).getX(), Precision.EPSILON);
+ Assert.assertEquals(1.0, pt.project(Point1D.of(100.0)).getX(), Precision.EPSILON);
}
@Test
public void testRevertSelf() {
// arrange
- OrientedPoint pt = new OrientedPoint(new Point1D(2.0), true, 1e-5);
+ OrientedPoint pt = new OrientedPoint(Point1D.of(2.0), true, 1e-5);
// act
pt.revertSelf();
@@ -151,7 +151,7 @@ public class OrientedPointTest {
Assert.assertFalse(pt.isDirect());
Assert.assertEquals(1e-5, pt.getTolerance(), Precision.EPSILON);
- Assert.assertEquals(1, pt.getOffset(new Point1D(1.0)), Precision.EPSILON);
- Assert.assertEquals(-1, pt.getOffset(new Point1D(3.0)), Precision.EPSILON);
+ Assert.assertEquals(1, pt.getOffset(Point1D.of(1.0)), Precision.EPSILON);
+ Assert.assertEquals(-1, pt.getOffset(Point1D.of(3.0)), Precision.EPSILON);
}
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/Point1DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/Point1DTest.java
index 702abef..f17af96 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/Point1DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/Point1DTest.java
@@ -197,13 +197,13 @@ public class Point1DTest {
@Test
public void testOf_coordinateArg() {
// act/assert
- checkPoint(Point1D.of(new Vector1D(0)), 0.0);
- checkPoint(Point1D.of(new Vector1D(-1)), -1.0);
- checkPoint(Point1D.of(new Vector1D(1)), 1.0);
- checkPoint(Point1D.of(new Vector1D(Math.PI)), Math.PI);
- checkPoint(Point1D.of(new Vector1D(Double.NaN)), Double.NaN);
- checkPoint(Point1D.of(new Vector1D(Double.NEGATIVE_INFINITY)), Double.NEGATIVE_INFINITY);
- checkPoint(Point1D.of(new Vector1D(Double.POSITIVE_INFINITY)), Double.POSITIVE_INFINITY);
+ checkPoint(Point1D.of(Vector1D.of(0)), 0.0);
+ checkPoint(Point1D.of(Vector1D.of(-1)), -1.0);
+ checkPoint(Point1D.of(Vector1D.of(1)), 1.0);
+ checkPoint(Point1D.of(Vector1D.of(Math.PI)), Math.PI);
+ checkPoint(Point1D.of(Vector1D.of(Double.NaN)), Double.NaN);
+ checkPoint(Point1D.of(Vector1D.of(Double.NEGATIVE_INFINITY)), Double.NEGATIVE_INFINITY);
+ checkPoint(Point1D.of(Vector1D.of(Double.POSITIVE_INFINITY)), Double.POSITIVE_INFINITY);
}
@Test
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/SubOrientedPointTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/SubOrientedPointTest.java
index 6cf8de7..ab3c9d9 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/SubOrientedPointTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/SubOrientedPointTest.java
@@ -28,7 +28,7 @@ public class SubOrientedPointTest {
@Test
public void testGetSize() {
// arrange
- OrientedPoint hyperplane = new OrientedPoint(new Point1D(1), true, TEST_TOLERANCE);
+ OrientedPoint hyperplane = new OrientedPoint(Point1D.of(1), true, TEST_TOLERANCE);
SubOrientedPoint pt = hyperplane.wholeHyperplane();
// act/assert
@@ -38,7 +38,7 @@ public class SubOrientedPointTest {
@Test
public void testIsEmpty() {
// arrange
- OrientedPoint hyperplane = new OrientedPoint(new Point1D(1), true, TEST_TOLERANCE);
+ OrientedPoint hyperplane = new OrientedPoint(Point1D.of(1), true, TEST_TOLERANCE);
SubOrientedPoint pt = hyperplane.wholeHyperplane();
// act/assert
@@ -48,10 +48,10 @@ public class SubOrientedPointTest {
@Test
public void testBuildNew() {
// arrange
- OrientedPoint originalHyperplane = new OrientedPoint(new Point1D(1), true, TEST_TOLERANCE);
+ OrientedPoint originalHyperplane = new OrientedPoint(Point1D.of(1), true, TEST_TOLERANCE);
SubOrientedPoint pt = originalHyperplane.wholeHyperplane();
- OrientedPoint hyperplane = new OrientedPoint(new Point1D(2), true, TEST_TOLERANCE);
+ OrientedPoint hyperplane = new OrientedPoint(Point1D.of(2), true, TEST_TOLERANCE);
IntervalsSet intervals = new IntervalsSet(2, 3, TEST_TOLERANCE);
// act
@@ -66,11 +66,11 @@ public class SubOrientedPointTest {
@Test
public void testSplit_resultOnMinusSide() {
// arrange
- OrientedPoint hyperplane = new OrientedPoint(new Point1D(1), true, TEST_TOLERANCE);
+ OrientedPoint hyperplane = new OrientedPoint(Point1D.of(1), true, TEST_TOLERANCE);
IntervalsSet interval = new IntervalsSet(TEST_TOLERANCE);
SubOrientedPoint pt = new SubOrientedPoint(hyperplane, interval);
- OrientedPoint splitter = new OrientedPoint(new Point1D(2), true, TEST_TOLERANCE);
+ OrientedPoint splitter = new OrientedPoint(Point1D.of(2), true, TEST_TOLERANCE);
// act
SplitSubHyperplane<Point1D> split = pt.split(splitter);
@@ -92,11 +92,11 @@ public class SubOrientedPointTest {
@Test
public void testSplit_resultOnPlusSide() {
// arrange
- OrientedPoint hyperplane = new OrientedPoint(new Point1D(1), true, TEST_TOLERANCE);
+ OrientedPoint hyperplane = new OrientedPoint(Point1D.of(1), true, TEST_TOLERANCE);
IntervalsSet interval = new IntervalsSet(TEST_TOLERANCE);
SubOrientedPoint pt = new SubOrientedPoint(hyperplane, interval);
- OrientedPoint splitter = new OrientedPoint(new Point1D(0), true, TEST_TOLERANCE);
+ OrientedPoint splitter = new OrientedPoint(Point1D.of(0), true, TEST_TOLERANCE);
// act
SplitSubHyperplane<Point1D> split = pt.split(splitter);
@@ -118,11 +118,11 @@ public class SubOrientedPointTest {
@Test
public void testSplit_equivalentHyperplanes() {
// arrange
- OrientedPoint hyperplane = new OrientedPoint(new Point1D(1), true, TEST_TOLERANCE);
+ OrientedPoint hyperplane = new OrientedPoint(Point1D.of(1), true, TEST_TOLERANCE);
IntervalsSet interval = new IntervalsSet(TEST_TOLERANCE);
SubOrientedPoint pt = new SubOrientedPoint(hyperplane, interval);
- OrientedPoint splitter = new OrientedPoint(new Point1D(1), true, TEST_TOLERANCE);
+ OrientedPoint splitter = new OrientedPoint(Point1D.of(1), true, TEST_TOLERANCE);
// act
SplitSubHyperplane<Point1D> split = pt.split(splitter);
@@ -137,23 +137,23 @@ public class SubOrientedPointTest {
@Test
public void testSplit_usesToleranceFromParentHyperplane() {
// arrange
- OrientedPoint hyperplane = new OrientedPoint(new Point1D(1), true, 0.1);
+ OrientedPoint hyperplane = new OrientedPoint(Point1D.of(1), true, 0.1);
SubOrientedPoint pt = hyperplane.wholeHyperplane();
// act/assert
- SplitSubHyperplane<Point1D> plusSplit = pt.split(new OrientedPoint(new Point1D(0.899), true, 1e-10));
+ SplitSubHyperplane<Point1D> plusSplit = pt.split(new OrientedPoint(Point1D.of(0.899), true, 1e-10));
Assert.assertNull(plusSplit.getMinus());
Assert.assertNotNull(plusSplit.getPlus());
- SplitSubHyperplane<Point1D> lowWithinTolerance = pt.split(new OrientedPoint(new Point1D(0.901), true, 1e-10));
+ SplitSubHyperplane<Point1D> lowWithinTolerance = pt.split(new OrientedPoint(Point1D.of(0.901), true, 1e-10));
Assert.assertNull(lowWithinTolerance.getMinus());
Assert.assertNull(lowWithinTolerance.getPlus());
- SplitSubHyperplane<Point1D> highWithinTolerance = pt.split(new OrientedPoint(new Point1D(1.09), true, 1e-10));
+ SplitSubHyperplane<Point1D> highWithinTolerance = pt.split(new OrientedPoint(Point1D.of(1.09), true, 1e-10));
Assert.assertNull(highWithinTolerance.getMinus());
Assert.assertNull(highWithinTolerance.getPlus());
- SplitSubHyperplane<Point1D> minusSplit = pt.split(new OrientedPoint(new Point1D(1.101), true, 1e-10));
+ SplitSubHyperplane<Point1D> minusSplit = pt.split(new OrientedPoint(Point1D.of(1.101), true, 1e-10));
Assert.assertNotNull(minusSplit.getMinus());
Assert.assertNull(minusSplit.getPlus());
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/LineTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/LineTest.java
index 6a6a87b..e49c61b 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/LineTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/LineTest.java
@@ -23,8 +23,8 @@ public class LineTest {
@Test
public void testContains() {
- Point3D p1 = new Point3D(0, 0, 1);
- Line l = new Line(p1, new Point3D(0, 0, 2), 1.0e-10);
+ Point3D p1 = Point3D.of(0, 0, 1);
+ Line l = new Line(p1, Point3D.of(0, 0, 2), 1.0e-10);
Assert.assertTrue(l.contains(p1));
Assert.assertTrue(l.contains(Point3D.vectorCombination(1.0, p1, 0.3, l.getDirection())));
Vector3D u = l.getDirection().orthogonal();
@@ -37,8 +37,8 @@ public class LineTest {
@Test
public void testSimilar() {
- Point3D p1 = new Point3D (1.2, 3.4, -5.8);
- Point3D p2 = new Point3D (3.4, -5.8, 1.2);
+ Point3D p1 = Point3D.of(1.2, 3.4, -5.8);
+ Point3D p2 = Point3D.of(3.4, -5.8, 1.2);
Line lA = new Line(p1, p2, 1.0e-10);
Line lB = new Line(p2, p1, 1.0e-10);
Assert.assertTrue(lA.isSimilarTo(lB));
@@ -47,89 +47,89 @@ public class LineTest {
@Test
public void testPointDistance() {
- Line l = new Line(new Point3D(0, 1, 1), new Point3D(0, 2, 2), 1.0e-10);
- Assert.assertEquals(Math.sqrt(3.0 / 2.0), l.distance(new Point3D(1, 0, 1)), 1.0e-10);
- Assert.assertEquals(0, l.distance(new Point3D(0, -4, -4)), 1.0e-10);
+ Line l = new Line(Point3D.of(0, 1, 1), Point3D.of(0, 2, 2), 1.0e-10);
+ Assert.assertEquals(Math.sqrt(3.0 / 2.0), l.distance(Point3D.of(1, 0, 1)), 1.0e-10);
+ Assert.assertEquals(0, l.distance(Point3D.of(0, -4, -4)), 1.0e-10);
}
@Test
public void testLineDistance() {
- Line l = new Line(new Point3D(0, 1, 1), new Point3D(0, 2, 2), 1.0e-10);
+ Line l = new Line(Point3D.of(0, 1, 1), Point3D.of(0, 2, 2), 1.0e-10);
Assert.assertEquals(1.0,
- l.distance(new Line(new Point3D(1, 0, 1), new Point3D(1, 0, 2), 1.0e-10)),
+ l.distance(new Line(Point3D.of(1, 0, 1), Point3D.of(1, 0, 2), 1.0e-10)),
1.0e-10);
Assert.assertEquals(0.5,
- l.distance(new Line(new Point3D(-0.5, 0, 0), new Point3D(-0.5, -1, -1), 1.0e-10)),
+ l.distance(new Line(Point3D.of(-0.5, 0, 0), Point3D.of(-0.5, -1, -1), 1.0e-10)),
1.0e-10);
Assert.assertEquals(0.0,
l.distance(l),
1.0e-10);
Assert.assertEquals(0.0,
- l.distance(new Line(new Point3D(0, -4, -4), new Point3D(0, -5, -5), 1.0e-10)),
+ l.distance(new Line(Point3D.of(0, -4, -4), Point3D.of(0, -5, -5), 1.0e-10)),
1.0e-10);
Assert.assertEquals(0.0,
- l.distance(new Line(new Point3D(0, -4, -4), new Point3D(0, -3, -4), 1.0e-10)),
+ l.distance(new Line(Point3D.of(0, -4, -4), Point3D.of(0, -3, -4), 1.0e-10)),
1.0e-10);
Assert.assertEquals(0.0,
- l.distance(new Line(new Point3D(0, -4, -4), new Point3D(1, -4, -4), 1.0e-10)),
+ l.distance(new Line(Point3D.of(0, -4, -4), Point3D.of(1, -4, -4), 1.0e-10)),
1.0e-10);
Assert.assertEquals(Math.sqrt(8),
- l.distance(new Line(new Point3D(0, -4, 0), new Point3D(1, -4, 0), 1.0e-10)),
+ l.distance(new Line(Point3D.of(0, -4, 0), Point3D.of(1, -4, 0), 1.0e-10)),
1.0e-10);
}
@Test
public void testClosest() {
- Line l = new Line(new Point3D(0, 1, 1), new Point3D(0, 2, 2), 1.0e-10);
+ Line l = new Line(Point3D.of(0, 1, 1), Point3D.of(0, 2, 2), 1.0e-10);
Assert.assertEquals(0.0,
- l.closestPoint(new Line(new Point3D(1, 0, 1), new Point3D(1, 0, 2), 1.0e-10)).distance(new Point3D(0, 0, 0)),
+ l.closestPoint(new Line(Point3D.of(1, 0, 1), Point3D.of(1, 0, 2), 1.0e-10)).distance(Point3D.of(0, 0, 0)),
1.0e-10);
Assert.assertEquals(0.5,
- l.closestPoint(new Line(new Point3D(-0.5, 0, 0), new Point3D(-0.5, -1, -1), 1.0e-10)).distance(new Point3D(-0.5, 0, 0)),
+ l.closestPoint(new Line(Point3D.of(-0.5, 0, 0), Point3D.of(-0.5, -1, -1), 1.0e-10)).distance(Point3D.of(-0.5, 0, 0)),
1.0e-10);
Assert.assertEquals(0.0,
- l.closestPoint(l).distance(new Point3D(0, 0, 0)),
+ l.closestPoint(l).distance(Point3D.of(0, 0, 0)),
1.0e-10);
Assert.assertEquals(0.0,
- l.closestPoint(new Line(new Point3D(0, -4, -4), new Point3D(0, -5, -5), 1.0e-10)).distance(new Point3D(0, 0, 0)),
+ l.closestPoint(new Line(Point3D.of(0, -4, -4), Point3D.of(0, -5, -5), 1.0e-10)).distance(Point3D.of(0, 0, 0)),
1.0e-10);
Assert.assertEquals(0.0,
- l.closestPoint(new Line(new Point3D(0, -4, -4), new Point3D(0, -3, -4), 1.0e-10)).distance(new Point3D(0, -4, -4)),
+ l.closestPoint(new Line(Point3D.of(0, -4, -4), Point3D.of(0, -3, -4), 1.0e-10)).distance(Point3D.of(0, -4, -4)),
1.0e-10);
Assert.assertEquals(0.0,
- l.closestPoint(new Line(new Point3D(0, -4, -4), new Point3D(1, -4, -4), 1.0e-10)).distance(new Point3D(0, -4, -4)),
+ l.closestPoint(new Line(Point3D.of(0, -4, -4), Point3D.of(1, -4, -4), 1.0e-10)).distance(Point3D.of(0, -4, -4)),
1.0e-10);
Assert.assertEquals(0.0,
- l.closestPoint(new Line(new Point3D(0, -4, 0), new Point3D(1, -4, 0), 1.0e-10)).distance(new Point3D(0, -2, -2)),
+ l.closestPoint(new Line(Point3D.of(0, -4, 0), Point3D.of(1, -4, 0), 1.0e-10)).distance(Point3D.of(0, -2, -2)),
1.0e-10);
}
@Test
public void testIntersection() {
- Line l = new Line(new Point3D(0, 1, 1), new Point3D(0, 2, 2), 1.0e-10);
- Assert.assertNull(l.intersection(new Line(new Point3D(1, 0, 1), new Point3D(1, 0, 2), 1.0e-10)));
- Assert.assertNull(l.intersection(new Line(new Point3D(-0.5, 0, 0), new Point3D(-0.5, -1, -1), 1.0e-10)));
+ Line l = new Line(Point3D.of(0, 1, 1), Point3D.of(0, 2, 2), 1.0e-10);
+ Assert.assertNull(l.intersection(new Line(Point3D.of(1, 0, 1), Point3D.of(1, 0, 2), 1.0e-10)));
+ Assert.assertNull(l.intersection(new Line(Point3D.of(-0.5, 0, 0), Point3D.of(-0.5, -1, -1), 1.0e-10)));
Assert.assertEquals(0.0,
- l.intersection(l).distance(new Point3D(0, 0, 0)),
+ l.intersection(l).distance(Point3D.of(0, 0, 0)),
1.0e-10);
Assert.assertEquals(0.0,
- l.intersection(new Line(new Point3D(0, -4, -4), new Point3D(0, -5, -5), 1.0e-10)).distance(new Point3D(0, 0, 0)),
+ l.intersection(new Line(Point3D.of(0, -4, -4), Point3D.of(0, -5, -5), 1.0e-10)).distance(Point3D.of(0, 0, 0)),
1.0e-10);
Assert.assertEquals(0.0,
- l.intersection(new Line(new Point3D(0, -4, -4), new Point3D(0, -3, -4), 1.0e-10)).distance(new Point3D(0, -4, -4)),
+ l.intersection(new Line(Point3D.of(0, -4, -4), Point3D.of(0, -3, -4), 1.0e-10)).distance(Point3D.of(0, -4, -4)),
1.0e-10);
Assert.assertEquals(0.0,
- l.intersection(new Line(new Point3D(0, -4, -4), new Point3D(1, -4, -4), 1.0e-10)).distance(new Point3D(0, -4, -4)),
+ l.intersection(new Line(Point3D.of(0, -4, -4), Point3D.of(1, -4, -4), 1.0e-10)).distance(Point3D.of(0, -4, -4)),
1.0e-10);
- Assert.assertNull(l.intersection(new Line(new Point3D(0, -4, 0), new Point3D(1, -4, 0), 1.0e-10)));
+ Assert.assertNull(l.intersection(new Line(Point3D.of(0, -4, 0), Point3D.of(1, -4, 0), 1.0e-10)));
}
@Test
public void testRevert() {
// setup
- Line line = new Line(new Point3D(1653345.6696423641, 6170370.041579291, 90000),
- new Point3D(1650757.5050732433, 6160710.879908984, 0.9),
+ Line line = new Line(Point3D.of(1653345.6696423641, 6170370.041579291, 90000),
+ Point3D.of(1650757.5050732433, 6160710.879908984, 0.9),
1.0e-10);
Vector3D expected = line.getDirection().negate();
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/PLYParser.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/PLYParser.java
index 78ebefd..8a26afa 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/PLYParser.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/PLYParser.java
@@ -175,7 +175,7 @@ public class PLYParser {
fields.get(zIndex).getToken() != Token.UNKNOWN) {
complain();
}
- vertices[i] = new Point3D(Double.parseDouble(fields.get(xIndex).getValue()),
+ vertices[i] = Point3D.of(Double.parseDouble(fields.get(xIndex).getValue()),
Double.parseDouble(fields.get(yIndex).getValue()),
Double.parseDouble(fields.get(zIndex).getValue()));
}
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 f6080a8..d6e3039 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
@@ -27,18 +27,18 @@ public class PlaneTest {
@Test
public void testContains() {
- Plane p = new Plane(new Point3D(0, 0, 1), new Vector3D(0, 0, 1), 1.0e-10);
- Assert.assertTrue(p.contains(new Point3D(0, 0, 1)));
- Assert.assertTrue(p.contains(new Point3D(17, -32, 1)));
- Assert.assertTrue(! p.contains(new Point3D(17, -32, 1.001)));
+ Plane p = new Plane(Point3D.of(0, 0, 1), Vector3D.of(0, 0, 1), 1.0e-10);
+ Assert.assertTrue(p.contains(Point3D.of(0, 0, 1)));
+ Assert.assertTrue(p.contains(Point3D.of(17, -32, 1)));
+ Assert.assertTrue(! p.contains(Point3D.of(17, -32, 1.001)));
}
@Test
public void testOffset() {
- Point3D p1 = new Point3D(1, 1, 1);
- Plane p = new Plane(p1, new Vector3D(0.2, 0, 0), 1.0e-10);
- Assert.assertEquals(-5.0, p.getOffset(new Point3D(-4, 0, 0)), 1.0e-10);
- Assert.assertEquals(+5.0, p.getOffset(new Point3D(6, 10, -12)), 1.0e-10);
+ Point3D p1 = Point3D.of(1, 1, 1);
+ Plane p = new Plane(p1, Vector3D.of(0.2, 0, 0), 1.0e-10);
+ Assert.assertEquals(-5.0, p.getOffset(Point3D.of(-4, 0, 0)), 1.0e-10);
+ Assert.assertEquals(+5.0, p.getOffset(Point3D.of(6, 10, -12)), 1.0e-10);
Assert.assertEquals(0.3,
p.getOffset(Point3D.vectorCombination(1.0, p1, 0.3, p.getNormal())),
1.0e-10);
@@ -49,15 +49,15 @@ public class PlaneTest {
@Test
public void testPoint() {
- Plane p = new Plane(new Point3D(2, -3, 1), new Vector3D(1, 4, 9), 1.0e-10);
+ Plane p = new Plane(Point3D.of(2, -3, 1), Vector3D.of(1, 4, 9), 1.0e-10);
Assert.assertTrue(p.contains(p.getOrigin()));
}
@Test
public void testThreePoints() {
- Point3D p1 = new Point3D(1.2, 3.4, -5.8);
- Point3D p2 = new Point3D(3.4, -5.8, 1.2);
- Point3D p3 = new Point3D(-2.0, 4.3, 0.7);
+ Point3D p1 = Point3D.of(1.2, 3.4, -5.8);
+ Point3D p2 = Point3D.of(3.4, -5.8, 1.2);
+ Point3D p3 = Point3D.of(-2.0, 4.3, 0.7);
Plane p = new Plane(p1, p2, p3, 1.0e-10);
Assert.assertTrue(p.contains(p1));
Assert.assertTrue(p.contains(p2));
@@ -66,9 +66,9 @@ public class PlaneTest {
@Test
public void testRotate() {
- Point3D p1 = new Point3D(1.2, 3.4, -5.8);
- Point3D p2 = new Point3D(3.4, -5.8, 1.2);
- Point3D p3 = new Point3D(-2.0, 4.3, 0.7);
+ Point3D p1 = Point3D.of(1.2, 3.4, -5.8);
+ Point3D p2 = Point3D.of(3.4, -5.8, 1.2);
+ Point3D p3 = Point3D.of(-2.0, 4.3, 0.7);
Plane p = new Plane(p1, p2, p3, 1.0e-10);
Vector3D oldNormal = p.getNormal();
@@ -91,9 +91,9 @@ public class PlaneTest {
@Test
public void testTranslate() {
- Point3D p1 = new Point3D(1.2, 3.4, -5.8);
- Point3D p2 = new Point3D(3.4, -5.8, 1.2);
- Point3D p3 = new Point3D(-2.0, 4.3, 0.7);
+ Point3D p1 = Point3D.of(1.2, 3.4, -5.8);
+ Point3D p2 = Point3D.of(3.4, -5.8, 1.2);
+ Point3D p3 = Point3D.of(-2.0, 4.3, 0.7);
Plane p = new Plane(p1, p2, p3, 1.0e-10);
p = p.translate(Vector3D.linearCombination(2.0, p.getU(), -1.5, p.getV()));
@@ -115,22 +115,22 @@ public class PlaneTest {
@Test
public void testIntersection() {
- Plane p = new Plane(new Point3D(1, 2, 3), new Vector3D(-4, 1, -5), 1.0e-10);
- Line l = new Line(new Point3D(0.2, -3.5, 0.7), new Point3D(1.2, -2.5, -0.3), 1.0e-10);
+ Plane p = new Plane(Point3D.of(1, 2, 3), Vector3D.of(-4, 1, -5), 1.0e-10);
+ Line l = new Line(Point3D.of(0.2, -3.5, 0.7), Point3D.of(1.2, -2.5, -0.3), 1.0e-10);
Point3D point = p.intersection(l);
Assert.assertTrue(p.contains(point));
Assert.assertTrue(l.contains(point));
- Assert.assertNull(p.intersection(new Line(new Point3D(10, 10, 10),
- new Point3D(10, 10, 10).add(p.getNormal().orthogonal()),
+ Assert.assertNull(p.intersection(new Line(Point3D.of(10, 10, 10),
+ Point3D.of(10, 10, 10).add(p.getNormal().orthogonal()),
1.0e-10)));
}
@Test
public void testIntersection2() {
- Point3D p1 = new Point3D (1.2, 3.4, -5.8);
- Point3D p2 = new Point3D (3.4, -5.8, 1.2);
- Plane pA = new Plane(p1, p2, new Point3D (-2.0, 4.3, 0.7), 1.0e-10);
- Plane pB = new Plane(p1, new Point3D (11.4, -3.8, 5.1), p2, 1.0e-10);
+ Point3D p1 = Point3D.of(1.2, 3.4, -5.8);
+ Point3D p2 = Point3D.of(3.4, -5.8, 1.2);
+ Plane pA = new Plane(p1, p2, Point3D.of(-2.0, 4.3, 0.7), 1.0e-10);
+ Plane pB = new Plane(p1, Point3D.of(11.4, -3.8, 5.1), p2, 1.0e-10);
Line l = pA.intersection(pB);
Assert.assertTrue(l.contains(p1));
Assert.assertTrue(l.contains(p2));
@@ -139,10 +139,10 @@ public class PlaneTest {
@Test
public void testIntersection3() {
- Point3D reference = new Point3D (1.2, 3.4, -5.8);
- Plane p1 = new Plane(reference, new Vector3D(1, 3, 3), 1.0e-10);
- Plane p2 = new Plane(reference, new Vector3D(-2, 4, 0), 1.0e-10);
- Plane p3 = new Plane(reference, new Vector3D(7, 0, -4), 1.0e-10);
+ Point3D reference = Point3D.of(1.2, 3.4, -5.8);
+ Plane p1 = new Plane(reference, Vector3D.of(1, 3, 3), 1.0e-10);
+ Plane p2 = new Plane(reference, Vector3D.of(-2, 4, 0), 1.0e-10);
+ Plane p3 = new Plane(reference, Vector3D.of(7, 0, -4), 1.0e-10);
Point3D p = Plane.intersection(p1, p2, p3);
Assert.assertEquals(reference.getX(), p.getX(), 1.0e-10);
Assert.assertEquals(reference.getY(), p.getY(), 1.0e-10);
@@ -151,11 +151,11 @@ public class PlaneTest {
@Test
public void testSimilar() {
- Point3D p1 = new Point3D (1.2, 3.4, -5.8);
- Point3D p2 = new Point3D (3.4, -5.8, 1.2);
- Point3D p3 = new Point3D (-2.0, 4.3, 0.7);
+ Point3D p1 = Point3D.of(1.2, 3.4, -5.8);
+ Point3D p2 = Point3D.of(3.4, -5.8, 1.2);
+ Point3D p3 = Point3D.of(-2.0, 4.3, 0.7);
Plane pA = new Plane(p1, p2, p3, 1.0e-10);
- Plane pB = new Plane(p1, new Point3D (11.4, -3.8, 5.1), p2, 1.0e-10);
+ Plane pB = new Plane(p1, Point3D.of(11.4, -3.8, 5.1), p2, 1.0e-10);
Assert.assertTrue(! pA.isSimilarTo(pB));
Assert.assertTrue(pA.isSimilarTo(pA));
Assert.assertTrue(pA.isSimilarTo(new Plane(p1, p3, p2, 1.0e-10)));
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/PolyhedronsSetTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/PolyhedronsSetTest.java
index 2e04ec1..fe6c74d 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/PolyhedronsSetTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/PolyhedronsSetTest.java
@@ -60,11 +60,11 @@ public class PolyhedronsSetTest {
Assert.assertTrue(polySet.isFull());
checkPoints(Region.Location.INSIDE, polySet,
- new Point3D(-Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE),
- new Point3D(-100, -100, -100),
- new Point3D(0, 0, 0),
- new Point3D(100, 100, 100),
- new Point3D(Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE));
+ Point3D.of(-Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE),
+ Point3D.of(-100, -100, -100),
+ Point3D.of(0, 0, 0),
+ Point3D.of(100, 100, 100),
+ Point3D.of(Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE));
}
@Test
@@ -81,11 +81,11 @@ public class PolyhedronsSetTest {
Assert.assertFalse(polySet.isFull());
checkPoints(Region.Location.OUTSIDE, polySet,
- new Point3D(-Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE),
- new Point3D(-100, -100, -100),
- new Point3D(0, 0, 0),
- new Point3D(100, 100, 100),
- new Point3D(Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE));
+ Point3D.of(-Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE),
+ Point3D.of(-100, -100, -100),
+ Point3D.of(0, 0, 0),
+ Point3D.of(100, 100, 100),
+ Point3D.of(Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE));
}
@Test
@@ -107,12 +107,12 @@ public class PolyhedronsSetTest {
Assert.assertFalse(polySet.isFull());
checkPoints(Region.Location.INSIDE, polySet,
- new Point3D(-Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE),
- new Point3D(-100, -100, -100));
- checkPoints(Region.Location.BOUNDARY, polySet, new Point3D(0, 0, 0));
+ Point3D.of(-Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE),
+ Point3D.of(-100, -100, -100));
+ checkPoints(Region.Location.BOUNDARY, polySet, Point3D.of(0, 0, 0));
checkPoints(Region.Location.OUTSIDE, polySet,
- new Point3D(100, 100, 100),
- new Point3D(Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE));
+ Point3D.of(100, 100, 100),
+ Point3D.of(Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE));
}
@Test
@@ -133,12 +133,12 @@ public class PolyhedronsSetTest {
Assert.assertFalse(polySet.isFull());
checkPoints(Region.Location.INSIDE, polySet,
- new Point3D(-Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE),
- new Point3D(-100, -100, -100),
- new Point3D(100, 100, 100),
- new Point3D(Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE));
+ Point3D.of(-Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE),
+ Point3D.of(-100, -100, -100),
+ Point3D.of(100, 100, 100),
+ Point3D.of(Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE));
checkPoints(Region.Location.OUTSIDE, polySet,
- new Point3D(0, 0, 0));
+ Point3D.of(0, 0, 0));
}
@Test
@@ -175,50 +175,50 @@ public class PolyhedronsSetTest {
Assert.assertFalse(polySet.isFull());
checkPoints(Region.Location.OUTSIDE, polySet,
- new Point3D(-1, 0, 0),
- new Point3D(1, 0, 0),
- new Point3D(0, -1, 0),
- new Point3D(0, 1, 0),
- new Point3D(0, 0, -1),
- new Point3D(0, 0, 1),
-
- new Point3D(1, 1, 1),
- new Point3D(1, 1, -1),
- new Point3D(1, -1, 1),
- new Point3D(1, -1, -1),
- new Point3D(-1, 1, 1),
- new Point3D(-1, 1, -1),
- new Point3D(-1, -1, 1),
- new Point3D(-1, -1, -1));
+ Point3D.of(-1, 0, 0),
+ Point3D.of(1, 0, 0),
+ Point3D.of(0, -1, 0),
+ Point3D.of(0, 1, 0),
+ Point3D.of(0, 0, -1),
+ Point3D.of(0, 0, 1),
+
+ Point3D.of(1, 1, 1),
+ Point3D.of(1, 1, -1),
+ Point3D.of(1, -1, 1),
+ Point3D.of(1, -1, -1),
+ Point3D.of(-1, 1, 1),
+ Point3D.of(-1, 1, -1),
+ Point3D.of(-1, -1, 1),
+ Point3D.of(-1, -1, -1));
checkPoints(Region.Location.BOUNDARY, polySet,
- new Point3D(0.5, 0, 0),
- new Point3D(-0.5, 0, 0),
- new Point3D(0, 0.5, 0),
- new Point3D(0, -0.5, 0),
- new Point3D(0, 0, 0.5),
- new Point3D(0, 0, -0.5),
-
- new Point3D(0.5, 0.5, 0.5),
- new Point3D(0.5, 0.5, -0.5),
- new Point3D(0.5, -0.5, 0.5),
- new Point3D(0.5, -0.5, -0.5),
- new Point3D(-0.5, 0.5, 0.5),
- new Point3D(-0.5, 0.5, -0.5),
- new Point3D(-0.5, -0.5, 0.5),
- new Point3D(-0.5, -0.5, -0.5));
+ Point3D.of(0.5, 0, 0),
+ Point3D.of(-0.5, 0, 0),
+ Point3D.of(0, 0.5, 0),
+ Point3D.of(0, -0.5, 0),
+ Point3D.of(0, 0, 0.5),
+ Point3D.of(0, 0, -0.5),
+
+ Point3D.of(0.5, 0.5, 0.5),
+ Point3D.of(0.5, 0.5, -0.5),
+ Point3D.of(0.5, -0.5, 0.5),
+ Point3D.of(0.5, -0.5, -0.5),
+ Point3D.of(-0.5, 0.5, 0.5),
+ Point3D.of(-0.5, 0.5, -0.5),
+ Point3D.of(-0.5, -0.5, 0.5),
+ Point3D.of(-0.5, -0.5, -0.5));
checkPoints(Region.Location.INSIDE, polySet,
- new Point3D(0, 0, 0),
-
- new Point3D(0.4, 0.4, 0.4),
- new Point3D(0.4, 0.4, -0.4),
- new Point3D(0.4, -0.4, 0.4),
- new Point3D(0.4, -0.4, -0.4),
- new Point3D(-0.4, 0.4, 0.4),
- new Point3D(-0.4, 0.4, -0.4),
- new Point3D(-0.4, -0.4, 0.4),
- new Point3D(-0.4, -0.4, -0.4));
+ Point3D.of(0, 0, 0),
+
+ Point3D.of(0.4, 0.4, 0.4),
+ Point3D.of(0.4, 0.4, -0.4),
+ Point3D.of(0.4, -0.4, 0.4),
+ Point3D.of(0.4, -0.4, -0.4),
+ Point3D.of(-0.4, 0.4, 0.4),
+ Point3D.of(-0.4, 0.4, -0.4),
+ Point3D.of(-0.4, -0.4, 0.4),
+ Point3D.of(-0.4, -0.4, -0.4));
}
@Test
@@ -226,7 +226,7 @@ public class PolyhedronsSetTest {
// arrange
List<SubHyperplane<Point3D>> boundaries = new ArrayList<>();
boundaries.addAll(createBoxBoundaries(Point3D.ZERO, 1.0, TEST_TOLERANCE));
- boundaries.addAll(createBoxBoundaries(new Point3D(2, 0, 0), 1.0, TEST_TOLERANCE));
+ boundaries.addAll(createBoxBoundaries(Point3D.of(2, 0, 0), 1.0, TEST_TOLERANCE));
// act
PolyhedronsSet polySet = new PolyhedronsSet(boundaries, TEST_TOLERANCE);
@@ -235,26 +235,26 @@ public class PolyhedronsSetTest {
Assert.assertEquals(TEST_TOLERANCE, polySet.getTolerance(), Precision.EPSILON);
Assert.assertEquals(2.0, polySet.getSize(), TEST_TOLERANCE);
Assert.assertEquals(12.0, polySet.getBoundarySize(), TEST_TOLERANCE);
- EuclideanTestUtils.assertCoordinatesEqual(new Point3D(1, 0, 0), polySet.getBarycenter(), TEST_TOLERANCE);
+ EuclideanTestUtils.assertCoordinatesEqual(Point3D.of(1, 0, 0), polySet.getBarycenter(), TEST_TOLERANCE);
Assert.assertFalse(polySet.isEmpty());
Assert.assertFalse(polySet.isFull());
checkPoints(Region.Location.OUTSIDE, polySet,
- new Point3D(-1, 0, 0),
- new Point3D(1, 0, 0),
- new Point3D(3, 0, 0));
+ Point3D.of(-1, 0, 0),
+ Point3D.of(1, 0, 0),
+ Point3D.of(3, 0, 0));
checkPoints(Region.Location.INSIDE, polySet,
- new Point3D(0, 0, 0),
- new Point3D(2, 0, 0));
+ Point3D.of(0, 0, 0),
+ Point3D.of(2, 0, 0));
}
@Test
public void testCreateFromBoundaries_twoBoxes_sharedSide() {
// arrange
List<SubHyperplane<Point3D>> boundaries = new ArrayList<>();
- boundaries.addAll(createBoxBoundaries(new Point3D(0, 0, 0), 1.0, TEST_TOLERANCE));
- boundaries.addAll(createBoxBoundaries(new Point3D(1, 0, 0), 1.0, TEST_TOLERANCE));
+ boundaries.addAll(createBoxBoundaries(Point3D.of(0, 0, 0), 1.0, TEST_TOLERANCE));
+ boundaries.addAll(createBoxBoundaries(Point3D.of(1, 0, 0), 1.0, TEST_TOLERANCE));
// act
PolyhedronsSet polySet = new PolyhedronsSet(boundaries, TEST_TOLERANCE);
@@ -263,17 +263,17 @@ public class PolyhedronsSetTest {
Assert.assertEquals(TEST_TOLERANCE, polySet.getTolerance(), Precision.EPSILON);
Assert.assertEquals(2.0, polySet.getSize(), TEST_TOLERANCE);
Assert.assertEquals(10.0, polySet.getBoundarySize(), TEST_TOLERANCE);
- EuclideanTestUtils.assertCoordinatesEqual(new Point3D(0.5, 0, 0), polySet.getBarycenter(), TEST_TOLERANCE);
+ EuclideanTestUtils.assertCoordinatesEqual(Point3D.of(0.5, 0, 0), polySet.getBarycenter(), TEST_TOLERANCE);
Assert.assertFalse(polySet.isEmpty());
Assert.assertFalse(polySet.isFull());
checkPoints(Region.Location.OUTSIDE, polySet,
- new Point3D(-1, 0, 0),
- new Point3D(2, 0, 0));
+ Point3D.of(-1, 0, 0),
+ Point3D.of(2, 0, 0));
checkPoints(Region.Location.INSIDE, polySet,
- new Point3D(0, 0, 0),
- new Point3D(1, 0, 0));
+ Point3D.of(0, 0, 0),
+ Point3D.of(1, 0, 0));
}
@Test
@@ -281,8 +281,8 @@ public class PolyhedronsSetTest {
// arrange
double tolerance = 1e-6;
List<SubHyperplane<Point3D>> boundaries = new ArrayList<>();
- boundaries.addAll(createBoxBoundaries(new Point3D(0, 0, 0), 1.0, tolerance));
- boundaries.addAll(createBoxBoundaries(new Point3D(1 + 1e-7, 0, 0), 1.0, tolerance));
+ boundaries.addAll(createBoxBoundaries(Point3D.of(0, 0, 0), 1.0, tolerance));
+ boundaries.addAll(createBoxBoundaries(Point3D.of(1 + 1e-7, 0, 0), 1.0, tolerance));
// act
PolyhedronsSet polySet = new PolyhedronsSet(boundaries, tolerance);
@@ -291,25 +291,25 @@ public class PolyhedronsSetTest {
Assert.assertEquals(tolerance, polySet.getTolerance(), Precision.EPSILON);
Assert.assertEquals(2.0, polySet.getSize(), tolerance);
Assert.assertEquals(10.0, polySet.getBoundarySize(), tolerance);
- EuclideanTestUtils.assertCoordinatesEqual(new Point3D(0.5 + 5e-8, 0, 0), polySet.getBarycenter(), TEST_TOLERANCE);
+ EuclideanTestUtils.assertCoordinatesEqual(Point3D.of(0.5 + 5e-8, 0, 0), polySet.getBarycenter(), TEST_TOLERANCE);
Assert.assertFalse(polySet.isEmpty());
Assert.assertFalse(polySet.isFull());
checkPoints(Region.Location.OUTSIDE, polySet,
- new Point3D(-1, 0, 0),
- new Point3D(2, 0, 0));
+ Point3D.of(-1, 0, 0),
+ Point3D.of(2, 0, 0));
checkPoints(Region.Location.INSIDE, polySet,
- new Point3D(0, 0, 0),
- new Point3D(1, 0, 0));
+ Point3D.of(0, 0, 0),
+ Point3D.of(1, 0, 0));
}
@Test
public void testCreateFromBoundaries_twoBoxes_sharedEdge() {
// arrange
List<SubHyperplane<Point3D>> boundaries = new ArrayList<>();
- boundaries.addAll(createBoxBoundaries(new Point3D(0, 0, 0), 1.0, TEST_TOLERANCE));
- boundaries.addAll(createBoxBoundaries(new Point3D(1, 1, 0), 1.0, TEST_TOLERANCE));
+ boundaries.addAll(createBoxBoundaries(Point3D.of(0, 0, 0), 1.0, TEST_TOLERANCE));
+ boundaries.addAll(createBoxBoundaries(Point3D.of(1, 1, 0), 1.0, TEST_TOLERANCE));
// act
PolyhedronsSet polySet = new PolyhedronsSet(boundaries, TEST_TOLERANCE);
@@ -318,27 +318,27 @@ public class PolyhedronsSetTest {
Assert.assertEquals(TEST_TOLERANCE, polySet.getTolerance(), Precision.EPSILON);
Assert.assertEquals(2.0, polySet.getSize(), TEST_TOLERANCE);
Assert.assertEquals(12.0, polySet.getBoundarySize(), TEST_TOLERANCE);
- EuclideanTestUtils.assertCoordinatesEqual(new Point3D(0.5, 0.5, 0), polySet.getBarycenter(), TEST_TOLERANCE);
+ EuclideanTestUtils.assertCoordinatesEqual(Point3D.of(0.5, 0.5, 0), polySet.getBarycenter(), TEST_TOLERANCE);
Assert.assertFalse(polySet.isEmpty());
Assert.assertFalse(polySet.isFull());
checkPoints(Region.Location.OUTSIDE, polySet,
- new Point3D(-1, 0, 0),
- new Point3D(1, 0, 0),
- new Point3D(0, 1, 0),
- new Point3D(2, 1, 0));
+ Point3D.of(-1, 0, 0),
+ Point3D.of(1, 0, 0),
+ Point3D.of(0, 1, 0),
+ Point3D.of(2, 1, 0));
checkPoints(Region.Location.INSIDE, polySet,
- new Point3D(0, 0, 0),
- new Point3D(1, 1, 0));
+ Point3D.of(0, 0, 0),
+ Point3D.of(1, 1, 0));
}
@Test
public void testCreateFromBoundaries_twoBoxes_sharedPoint() {
// arrange
List<SubHyperplane<Point3D>> boundaries = new ArrayList<>();
- boundaries.addAll(createBoxBoundaries(new Point3D(0, 0, 0), 1.0, TEST_TOLERANCE));
- boundaries.addAll(createBoxBoundaries(new Point3D(1, 1, 1), 1.0, TEST_TOLERANCE));
+ boundaries.addAll(createBoxBoundaries(Point3D.of(0, 0, 0), 1.0, TEST_TOLERANCE));
+ boundaries.addAll(createBoxBoundaries(Point3D.of(1, 1, 1), 1.0, TEST_TOLERANCE));
// act
PolyhedronsSet polySet = new PolyhedronsSet(boundaries, TEST_TOLERANCE);
@@ -347,19 +347,19 @@ public class PolyhedronsSetTest {
Assert.assertEquals(TEST_TOLERANCE, polySet.getTolerance(), Precision.EPSILON);
Assert.assertEquals(2.0, polySet.getSize(), TEST_TOLERANCE);
Assert.assertEquals(12.0, polySet.getBoundarySize(), TEST_TOLERANCE);
- EuclideanTestUtils.assertCoordinatesEqual(new Point3D(0.5, 0.5, 0.5), polySet.getBarycenter(), TEST_TOLERANCE);
+ EuclideanTestUtils.assertCoordinatesEqual(Point3D.of(0.5, 0.5, 0.5), polySet.getBarycenter(), TEST_TOLERANCE);
Assert.assertFalse(polySet.isEmpty());
Assert.assertFalse(polySet.isFull());
checkPoints(Region.Location.OUTSIDE, polySet,
- new Point3D(-1, 0, 0),
- new Point3D(1, 0, 0),
- new Point3D(0, 1, 1),
- new Point3D(2, 1, 1));
+ Point3D.of(-1, 0, 0),
+ Point3D.of(1, 0, 0),
+ Point3D.of(0, 1, 1),
+ Point3D.of(2, 1, 1));
checkPoints(Region.Location.INSIDE, polySet,
- new Point3D(0, 0, 0),
- new Point3D(1, 1, 1));
+ Point3D.of(0, 0, 0),
+ Point3D.of(1, 1, 1));
}
@Test
@@ -370,7 +370,7 @@ public class PolyhedronsSetTest {
// assert
Assert.assertEquals(1.0, tree.getSize(), TEST_TOLERANCE);
Assert.assertEquals(6.0, tree.getBoundarySize(), TEST_TOLERANCE);
- EuclideanTestUtils.assertCoordinatesEqual(new Point3D(0.5, 0.5, 0.5), tree.getBarycenter(), TEST_TOLERANCE);
+ EuclideanTestUtils.assertCoordinatesEqual(Point3D.of(0.5, 0.5, 0.5), tree.getBarycenter(), TEST_TOLERANCE);
for (double x = -0.25; x < 1.25; x += 0.1) {
boolean xOK = (x >= 0.0) && (x <= 1.0);
@@ -380,25 +380,25 @@ public class PolyhedronsSetTest {
boolean zOK = (z >= 0.0) && (z <= 1.0);
Region.Location expected =
(xOK && yOK && zOK) ? Region.Location.INSIDE : Region.Location.OUTSIDE;
- Assert.assertEquals(expected, tree.checkPoint(new Point3D(x, y, z)));
+ Assert.assertEquals(expected, tree.checkPoint(Point3D.of(x, y, z)));
}
}
}
checkPoints(Region.Location.BOUNDARY, tree, new Point3D[] {
- new Point3D(0.0, 0.5, 0.5),
- new Point3D(1.0, 0.5, 0.5),
- new Point3D(0.5, 0.0, 0.5),
- new Point3D(0.5, 1.0, 0.5),
- new Point3D(0.5, 0.5, 0.0),
- new Point3D(0.5, 0.5, 1.0)
+ Point3D.of(0.0, 0.5, 0.5),
+ Point3D.of(1.0, 0.5, 0.5),
+ Point3D.of(0.5, 0.0, 0.5),
+ Point3D.of(0.5, 1.0, 0.5),
+ Point3D.of(0.5, 0.5, 0.0),
+ Point3D.of(0.5, 0.5, 1.0)
});
checkPoints(Region.Location.OUTSIDE, tree, new Point3D[] {
- new Point3D(0.0, 1.2, 1.2),
- new Point3D(1.0, 1.2, 1.2),
- new Point3D(1.2, 0.0, 1.2),
- new Point3D(1.2, 1.0, 1.2),
- new Point3D(1.2, 1.2, 0.0),
- new Point3D(1.2, 1.2, 1.0)
+ Point3D.of(0.0, 1.2, 1.2),
+ Point3D.of(1.0, 1.2, 1.2),
+ Point3D.of(1.2, 0.0, 1.2),
+ Point3D.of(1.2, 1.0, 1.2),
+ Point3D.of(1.2, 1.2, 0.0),
+ Point3D.of(1.2, 1.2, 1.0)
});
}
@@ -427,35 +427,35 @@ public class PolyhedronsSetTest {
boolean zOK = (z < 0.0) || (z > 1.0);
Region.Location expected =
(xOK || yOK || zOK) ? Region.Location.INSIDE : Region.Location.OUTSIDE;
- Assert.assertEquals(expected, tree.checkPoint(new Point3D(x, y, z)));
+ Assert.assertEquals(expected, tree.checkPoint(Point3D.of(x, y, z)));
}
}
}
checkPoints(Region.Location.BOUNDARY, tree, new Point3D[] {
- new Point3D(0.0, 0.5, 0.5),
- new Point3D(1.0, 0.5, 0.5),
- new Point3D(0.5, 0.0, 0.5),
- new Point3D(0.5, 1.0, 0.5),
- new Point3D(0.5, 0.5, 0.0),
- new Point3D(0.5, 0.5, 1.0)
+ Point3D.of(0.0, 0.5, 0.5),
+ Point3D.of(1.0, 0.5, 0.5),
+ Point3D.of(0.5, 0.0, 0.5),
+ Point3D.of(0.5, 1.0, 0.5),
+ Point3D.of(0.5, 0.5, 0.0),
+ Point3D.of(0.5, 0.5, 1.0)
});
checkPoints(Region.Location.INSIDE, tree, new Point3D[] {
- new Point3D(0.0, 1.2, 1.2),
- new Point3D(1.0, 1.2, 1.2),
- new Point3D(1.2, 0.0, 1.2),
- new Point3D(1.2, 1.0, 1.2),
- new Point3D(1.2, 1.2, 0.0),
- new Point3D(1.2, 1.2, 1.0)
+ Point3D.of(0.0, 1.2, 1.2),
+ Point3D.of(1.0, 1.2, 1.2),
+ Point3D.of(1.2, 0.0, 1.2),
+ Point3D.of(1.2, 1.0, 1.2),
+ Point3D.of(1.2, 1.2, 0.0),
+ Point3D.of(1.2, 1.2, 1.0)
});
}
@Test
public void testTetrahedron() {
// arrange
- Point3D vertex1 = new Point3D(1, 2, 3);
- Point3D vertex2 = new Point3D(2, 2, 4);
- Point3D vertex3 = new Point3D(2, 3, 3);
- Point3D vertex4 = new Point3D(1, 3, 4);
+ Point3D vertex1 = Point3D.of(1, 2, 3);
+ Point3D vertex2 = Point3D.of(2, 2, 4);
+ Point3D vertex3 = Point3D.of(2, 3, 3);
+ Point3D vertex4 = Point3D.of(1, 3, 4);
// act
PolyhedronsSet tree =
@@ -468,7 +468,7 @@ public class PolyhedronsSetTest {
// assert
Assert.assertEquals(1.0 / 3.0, tree.getSize(), TEST_TOLERANCE);
Assert.assertEquals(2.0 * Math.sqrt(3.0), tree.getBoundarySize(), TEST_TOLERANCE);
- EuclideanTestUtils.assertCoordinatesEqual(new Point3D(1.5, 2.5, 3.5), tree.getBarycenter(), TEST_TOLERANCE);
+ EuclideanTestUtils.assertCoordinatesEqual(Point3D.of(1.5, 2.5, 3.5), tree.getBarycenter(), TEST_TOLERANCE);
double third = 1.0 / 3.0;
checkPoints(Region.Location.BOUNDARY, tree, new Point3D[] {
@@ -479,10 +479,10 @@ public class PolyhedronsSetTest {
Point3D.vectorCombination(third, vertex4, third, vertex1, third, vertex2)
});
checkPoints(Region.Location.OUTSIDE, tree, new Point3D[] {
- new Point3D(1, 2, 4),
- new Point3D(2, 2, 3),
- new Point3D(2, 3, 4),
- new Point3D(1, 3, 3)
+ Point3D.of(1, 2, 4),
+ Point3D.of(2, 2, 3),
+ Point3D.of(2, 3, 4),
+ Point3D.of(1, 3, 3)
});
}
@@ -494,42 +494,42 @@ public class PolyhedronsSetTest {
double radius = 1.0;
// act
- PolyhedronsSet polySet = createSphere(new Point3D(1, 2, 3), radius, 8, 16);
+ PolyhedronsSet polySet = createSphere(Point3D.of(1, 2, 3), radius, 8, 16);
// assert
Assert.assertEquals(sphereVolume(radius), polySet.getSize(), approximationTolerance);
Assert.assertEquals(sphereSurface(radius), polySet.getBoundarySize(), approximationTolerance);
- EuclideanTestUtils.assertCoordinatesEqual(new Point3D(1, 2, 3), polySet.getBarycenter(), TEST_TOLERANCE);
+ EuclideanTestUtils.assertCoordinatesEqual(Point3D.of(1, 2, 3), polySet.getBarycenter(), TEST_TOLERANCE);
Assert.assertFalse(polySet.isEmpty());
Assert.assertFalse(polySet.isFull());
checkPoints(Region.Location.OUTSIDE, polySet,
- new Point3D(-0.1, 2, 3),
- new Point3D(2.1, 2, 3),
- new Point3D(1, 0.9, 3),
- new Point3D(1, 3.1, 3),
- new Point3D(1, 2, 1.9),
- new Point3D(1, 2, 4.1),
- new Point3D(1.6, 2.6, 3.6));
+ Point3D.of(-0.1, 2, 3),
+ Point3D.of(2.1, 2, 3),
+ Point3D.of(1, 0.9, 3),
+ Point3D.of(1, 3.1, 3),
+ Point3D.of(1, 2, 1.9),
+ Point3D.of(1, 2, 4.1),
+ Point3D.of(1.6, 2.6, 3.6));
checkPoints(Region.Location.INSIDE, polySet,
- new Point3D(1, 2, 3),
- new Point3D(0.1, 2, 3),
- new Point3D(1.9, 2, 3),
- new Point3D(1, 2.1, 3),
- new Point3D(1, 2.9, 3),
- new Point3D(1, 2, 2.1),
- new Point3D(1, 2, 3.9),
- new Point3D(1.5, 2.5, 3.5));
+ Point3D.of(1, 2, 3),
+ Point3D.of(0.1, 2, 3),
+ Point3D.of(1.9, 2, 3),
+ Point3D.of(1, 2.1, 3),
+ Point3D.of(1, 2.9, 3),
+ Point3D.of(1, 2, 2.1),
+ Point3D.of(1, 2, 3.9),
+ Point3D.of(1.5, 2.5, 3.5));
}
@Test
public void testIsometry() {
// arrange
- Point3D vertex1 = new Point3D(1.1, 2.2, 3.3);
- Point3D vertex2 = new Point3D(2.0, 2.4, 4.2);
- Point3D vertex3 = new Point3D(2.8, 3.3, 3.7);
- Point3D vertex4 = new Point3D(1.0, 3.6, 4.5);
+ Point3D vertex1 = Point3D.of(1.1, 2.2, 3.3);
+ Point3D vertex2 = Point3D.of(2.0, 2.4, 4.2);
+ Point3D vertex3 = Point3D.of(2.8, 3.3, 3.7);
+ Point3D vertex4 = Point3D.of(1.0, 3.6, 4.5);
// act
PolyhedronsSet tree =
@@ -541,9 +541,9 @@ public class PolyhedronsSetTest {
// assert
Point3D barycenter = tree.getBarycenter();
- Vector3D s = new Vector3D(10.2, 4.3, -6.7);
- Point3D c = new Point3D(-0.2, 2.1, -3.2);
- Rotation r = new Rotation(new Vector3D(6.2, -4.4, 2.1), 0.12, RotationConvention.VECTOR_OPERATOR);
+ Vector3D s = Vector3D.of(10.2, 4.3, -6.7);
+ Point3D c = Point3D.of(-0.2, 2.1, -3.2);
+ Rotation r = new Rotation(Vector3D.of(6.2, -4.4, 2.1), 0.12, RotationConvention.VECTOR_OPERATOR);
tree = tree.rotate(c, r).translate(s);
@@ -626,7 +626,7 @@ public class PolyhedronsSetTest {
new PolyhedronsSet(x - l, x + l, y - w, y + w, z - w, z + w, TEST_TOLERANCE);
// assert
- EuclideanTestUtils.assertCoordinatesEqual(new Point3D(x, y, z), tree.getBarycenter(), TEST_TOLERANCE);
+ EuclideanTestUtils.assertCoordinatesEqual(Point3D.of(x, y, z), tree.getBarycenter(), TEST_TOLERANCE);
Assert.assertEquals(8 * l * w * w, tree.getSize(), TEST_TOLERANCE);
Assert.assertEquals(8 * w * (2 * l + w), tree.getBoundarySize(), TEST_TOLERANCE);
}
@@ -651,7 +651,7 @@ public class PolyhedronsSetTest {
PolyhedronsSet tree = (PolyhedronsSet) factory.union(xBeam, factory.union(yBeam, zBeam));
// assert
- EuclideanTestUtils.assertCoordinatesEqual(new Point3D(x, y, z), tree.getBarycenter(), TEST_TOLERANCE);
+ EuclideanTestUtils.assertCoordinatesEqual(Point3D.of(x, y, z), tree.getBarycenter(), TEST_TOLERANCE);
Assert.assertEquals(8 * w * w * (3 * l - 2 * w), tree.getSize(), TEST_TOLERANCE);
Assert.assertEquals(24 * w * (2 * l - w), tree.getBoundarySize(), TEST_TOLERANCE);
}
@@ -682,9 +682,9 @@ public class PolyhedronsSetTest {
int idxA = indices[idx] * 3;
int idxB = indices[idx + 1] * 3;
int idxC = indices[idx + 2] * 3;
- Point3D v_1 = new Point3D(coords[idxA], coords[idxA + 1], coords[idxA + 2]);
- Point3D v_2 = new Point3D(coords[idxB], coords[idxB + 1], coords[idxB + 2]);
- Point3D v_3 = new Point3D(coords[idxC], coords[idxC + 1], coords[idxC + 2]);
+ Point3D v_1 = Point3D.of(coords[idxA], coords[idxA + 1], coords[idxA + 2]);
+ Point3D v_2 = Point3D.of(coords[idxB], coords[idxB + 1], coords[idxB + 2]);
+ Point3D v_3 = Point3D.of(coords[idxC], coords[idxC + 1], coords[idxC + 2]);
Point3D[] vertices = {v_1, v_2, v_3};
Plane polyPlane = new Plane(v_1, v_2, v_3, TEST_TOLERANCE);
ArrayList<SubHyperplane<Point2D>> lines = new ArrayList<>();
@@ -745,14 +745,14 @@ public class PolyhedronsSetTest {
double xmin=-1,xmax=1;
double ymin=-1,ymax=1;
double zmin=-1,zmax=1;
- verts[0]=new Point3D(xmin,ymin,zmin);
- verts[1]=new Point3D(xmax,ymin,zmin);
- verts[2]=new Point3D(xmax,ymax,zmin);
- verts[3]=new Point3D(xmin,ymax,zmin);
- verts[4]=new Point3D(xmin,ymin,zmax);
- verts[5]=new Point3D(xmax,ymin,zmax);
- verts[6]=new Point3D(xmax,ymax,zmax);
- verts[7]=new Point3D(xmin,ymax,zmax);
+ verts[0]=Point3D.of(xmin,ymin,zmin);
+ verts[1]=Point3D.of(xmax,ymin,zmin);
+ verts[2]=Point3D.of(xmax,ymax,zmin);
+ verts[3]=Point3D.of(xmin,ymax,zmin);
+ verts[4]=Point3D.of(xmin,ymin,zmax);
+ verts[5]=Point3D.of(xmax,ymin,zmax);
+ verts[6]=Point3D.of(xmax,ymax,zmax);
+ verts[7]=Point3D.of(xmin,ymax,zmax);
//
int[][] faces=new int[12][];
faces[0]=new int[]{3,1,0}; // bottom (-z)
@@ -815,7 +815,7 @@ public class PolyhedronsSetTest {
@Test
public void testCreateFromBRep_wrongNumberOfPoints() throws IOException, ParseException {
- checkError(Arrays.asList(Point3D.ZERO, new Point3D(1, 0, 0), new Point3D(0, 1, 0), new Point3D(0, 0, 1)),
+ checkError(Arrays.asList(Point3D.ZERO, Point3D.of(1, 0, 0), Point3D.of(0, 1, 0), Point3D.of(0, 0, 1)),
Arrays.asList(new int[] { 0, 1, 2 }, new int[] {2, 3}),
"");
}
@@ -849,45 +849,45 @@ public class PolyhedronsSetTest {
List<SubHyperplane<Point3D>> boundaries = createBoxBoundaries(Point3D.ZERO, 2.0, TEST_TOLERANCE);
PolyhedronsSet polySet = new PolyhedronsSet(boundaries, TEST_TOLERANCE);
- Line xPlus = new Line(Point3D.ZERO, new Point3D(1, 0, 0), TEST_TOLERANCE);
- Line xMinus = new Line(Point3D.ZERO, new Point3D(-1, 0, 0), TEST_TOLERANCE);
+ Line xPlus = new Line(Point3D.ZERO, Point3D.of(1, 0, 0), TEST_TOLERANCE);
+ Line xMinus = new Line(Point3D.ZERO, Point3D.of(-1, 0, 0), TEST_TOLERANCE);
- Line yPlus = new Line(Point3D.ZERO, new Point3D(0, 1, 0), TEST_TOLERANCE);
- Line yMinus = new Line(Point3D.ZERO, new Point3D(0, -1, 0), TEST_TOLERANCE);
+ Line yPlus = new Line(Point3D.ZERO, Point3D.of(0, 1, 0), TEST_TOLERANCE);
+ Line yMinus = new Line(Point3D.ZERO, Point3D.of(0, -1, 0), TEST_TOLERANCE);
- Line zPlus = new Line(Point3D.ZERO, new Point3D(0, 0, 1), TEST_TOLERANCE);
- Line zMinus = new Line(Point3D.ZERO, new Point3D(0, 0, -1), TEST_TOLERANCE);
+ Line zPlus = new Line(Point3D.ZERO, Point3D.of(0, 0, 1), TEST_TOLERANCE);
+ Line zMinus = new Line(Point3D.ZERO, Point3D.of(0, 0, -1), TEST_TOLERANCE);
// act/assert
- assertSubPlaneNormal(new Vector3D(-1, 0, 0), polySet.firstIntersection(new Point3D(-1.1, 0, 0), xPlus));
- assertSubPlaneNormal(new Vector3D(-1, 0, 0), polySet.firstIntersection(new Point3D(-1, 0, 0), xPlus));
- assertSubPlaneNormal(new Vector3D(1, 0, 0), polySet.firstIntersection(new Point3D(-0.9, 0, 0), xPlus));
- Assert.assertEquals(null, polySet.firstIntersection(new Point3D(1.1, 0, 0), xPlus));
-
- assertSubPlaneNormal(new Vector3D(1, 0, 0), polySet.firstIntersection(new Point3D(1.1, 0, 0), xMinus));
- assertSubPlaneNormal(new Vector3D(1, 0, 0), polySet.firstIntersection(new Point3D(1, 0, 0), xMinus));
- assertSubPlaneNormal(new Vector3D(-1, 0, 0), polySet.firstIntersection(new Point3D(0.9, 0, 0), xMinus));
- Assert.assertEquals(null, polySet.firstIntersection(new Point3D(-1.1, 0, 0), xMinus));
-
- assertSubPlaneNormal(new Vector3D(0, -1, 0), polySet.firstIntersection(new Point3D(0, -1.1, 0), yPlus));
- assertSubPlaneNormal(new Vector3D(0, -1, 0), polySet.firstIntersection(new Point3D(0, -1, 0), yPlus));
- assertSubPlaneNormal(new Vector3D(0, 1, 0), polySet.firstIntersection(new Point3D(0, -0.9, 0), yPlus));
- Assert.assertEquals(null, polySet.firstIntersection(new Point3D(0, 1.1, 0), yPlus));
-
- assertSubPlaneNormal(new Vector3D(0, 1, 0), polySet.firstIntersection(new Point3D(0, 1.1, 0), yMinus));
- assertSubPlaneNormal(new Vector3D(0, 1, 0), polySet.firstIntersection(new Point3D(0, 1, 0), yMinus));
- assertSubPlaneNormal(new Vector3D(0, -1, 0), polySet.firstIntersection(new Point3D(0, 0.9, 0), yMinus));
- Assert.assertEquals(null, polySet.firstIntersection(new Point3D(0, -1.1, 0), yMinus));
-
- assertSubPlaneNormal(new Vector3D(0, 0, -1), polySet.firstIntersection(new Point3D(0, 0, -1.1), zPlus));
- assertSubPlaneNormal(new Vector3D(0, 0, -1), polySet.firstIntersection(new Point3D(0, 0, -1), zPlus));
- assertSubPlaneNormal(new Vector3D(0, 0, 1), polySet.firstIntersection(new Point3D(0, 0, -0.9), zPlus));
- Assert.assertEquals(null, polySet.firstIntersection(new Point3D(0, 0, 1.1), zPlus));
-
- assertSubPlaneNormal(new Vector3D(0, 0, 1), polySet.firstIntersection(new Point3D(0, 0, 1.1), zMinus));
- assertSubPlaneNormal(new Vector3D(0, 0, 1), polySet.firstIntersection(new Point3D(0, 0, 1), zMinus));
- assertSubPlaneNormal(new Vector3D(0, 0, -1), polySet.firstIntersection(new Point3D(0, 0, 0.9), zMinus));
- Assert.assertEquals(null, polySet.firstIntersection(new Point3D(0, 0, -1.1), zMinus));
+ assertSubPlaneNormal(Vector3D.of(-1, 0, 0), polySet.firstIntersection(Point3D.of(-1.1, 0, 0), xPlus));
+ assertSubPlaneNormal(Vector3D.of(-1, 0, 0), polySet.firstIntersection(Point3D.of(-1, 0, 0), xPlus));
+ assertSubPlaneNormal(Vector3D.of(1, 0, 0), polySet.firstIntersection(Point3D.of(-0.9, 0, 0), xPlus));
+ Assert.assertEquals(null, polySet.firstIntersection(Point3D.of(1.1, 0, 0), xPlus));
+
+ assertSubPlaneNormal(Vector3D.of(1, 0, 0), polySet.firstIntersection(Point3D.of(1.1, 0, 0), xMinus));
+ assertSubPlaneNormal(Vector3D.of(1, 0, 0), polySet.firstIntersection(Point3D.of(1, 0, 0), xMinus));
+ assertSubPlaneNormal(Vector3D.of(-1, 0, 0), polySet.firstIntersection(Point3D.of(0.9, 0, 0), xMinus));
+ Assert.assertEquals(null, polySet.firstIntersection(Point3D.of(-1.1, 0, 0), xMinus));
+
+ assertSubPlaneNormal(Vector3D.of(0, -1, 0), polySet.firstIntersection(Point3D.of(0, -1.1, 0), yPlus));
+ assertSubPlaneNormal(Vector3D.of(0, -1, 0), polySet.firstIntersection(Point3D.of(0, -1, 0), yPlus));
+ assertSubPlaneNormal(Vector3D.of(0, 1, 0), polySet.firstIntersection(Point3D.of(0, -0.9, 0), yPlus));
+ Assert.assertEquals(null, polySet.firstIntersection(Point3D.of(0, 1.1, 0), yPlus));
+
+ assertSubPlaneNormal(Vector3D.of(0, 1, 0), polySet.firstIntersection(Point3D.of(0, 1.1, 0), yMinus));
+ assertSubPlaneNormal(Vector3D.of(0, 1, 0), polySet.firstIntersection(Point3D.of(0, 1, 0), yMinus));
+ assertSubPlaneNormal(Vector3D.of(0, -1, 0), polySet.firstIntersection(Point3D.of(0, 0.9, 0), yMinus));
+ Assert.assertEquals(null, polySet.firstIntersection(Point3D.of(0, -1.1, 0), yMinus));
+
+ assertSubPlaneNormal(Vector3D.of(0, 0, -1), polySet.firstIntersection(Point3D.of(0, 0, -1.1), zPlus));
+ assertSubPlaneNormal(Vector3D.of(0, 0, -1), polySet.firstIntersection(Point3D.of(0, 0, -1), zPlus));
+ assertSubPlaneNormal(Vector3D.of(0, 0, 1), polySet.firstIntersection(Point3D.of(0, 0, -0.9), zPlus));
+ Assert.assertEquals(null, polySet.firstIntersection(Point3D.of(0, 0, 1.1), zPlus));
+
+ assertSubPlaneNormal(Vector3D.of(0, 0, 1), polySet.firstIntersection(Point3D.of(0, 0, 1.1), zMinus));
+ assertSubPlaneNormal(Vector3D.of(0, 0, 1), polySet.firstIntersection(Point3D.of(0, 0, 1), zMinus));
+ assertSubPlaneNormal(Vector3D.of(0, 0, -1), polySet.firstIntersection(Point3D.of(0, 0, 0.9), zMinus));
+ Assert.assertEquals(null, polySet.firstIntersection(Point3D.of(0, 0, -1.1), zMinus));
}
// Issue 1211
@@ -902,7 +902,7 @@ public class PolyhedronsSetTest {
int nrays = 1000;
for (int i = 0; i < nrays; i++) {
Point3D origin = Point3D.ZERO;
- Vector3D direction = new Vector3D(2 * random.nextDouble() - 1,
+ Vector3D direction = Vector3D.of(2 * random.nextDouble() - 1,
2 * random.nextDouble() - 1,
2 * random.nextDouble() - 1).normalize();
Line line = new Line(origin, origin.add(direction), polyset.getTolerance());
@@ -922,7 +922,7 @@ public class PolyhedronsSetTest {
double size = 1.0;
double radius = size * 0.5;
PolyhedronsSet box = new PolyhedronsSet(0, size, 0, size, 0, size, TEST_TOLERANCE);
- PolyhedronsSet sphere = createSphere(new Point3D(size * 0.5, size * 0.5, size), radius, 8, 16);
+ PolyhedronsSet sphere = createSphere(Point3D.of(size * 0.5, size * 0.5, size), radius, 8, 16);
// act
PolyhedronsSet result = (PolyhedronsSet) new RegionFactory<Point3D>().union(box, sphere);
@@ -938,20 +938,20 @@ public class PolyhedronsSetTest {
Assert.assertFalse(result.isFull());
checkPoints(Region.Location.OUTSIDE, result,
- new Point3D(-0.1, 0.5, 0.5),
- new Point3D(1.1, 0.5, 0.5),
- new Point3D(0.5, -0.1, 0.5),
- new Point3D(0.5, 1.1, 0.5),
- new Point3D(0.5, 0.5, -0.1),
- new Point3D(0.5, 0.5, 1.6));
+ Point3D.of(-0.1, 0.5, 0.5),
+ Point3D.of(1.1, 0.5, 0.5),
+ Point3D.of(0.5, -0.1, 0.5),
+ Point3D.of(0.5, 1.1, 0.5),
+ Point3D.of(0.5, 0.5, -0.1),
+ Point3D.of(0.5, 0.5, 1.6));
checkPoints(Region.Location.INSIDE, result,
- new Point3D(0.1, 0.5, 0.5),
- new Point3D(0.9, 0.5, 0.5),
- new Point3D(0.5, 0.1, 0.5),
- new Point3D(0.5, 0.9, 0.5),
- new Point3D(0.5, 0.5, 0.1),
- new Point3D(0.5, 0.5, 1.4));
+ Point3D.of(0.1, 0.5, 0.5),
+ Point3D.of(0.9, 0.5, 0.5),
+ Point3D.of(0.5, 0.1, 0.5),
+ Point3D.of(0.5, 0.9, 0.5),
+ Point3D.of(0.5, 0.5, 0.1),
+ Point3D.of(0.5, 0.5, 1.4));
}
@Test
@@ -973,20 +973,20 @@ public class PolyhedronsSetTest {
Assert.assertFalse(result.isFull());
checkPoints(Region.Location.OUTSIDE, result,
- new Point3D(-1.1, 0, 0),
- new Point3D(1.1, 0, 0),
- new Point3D(0, -1.1, 0),
- new Point3D(0, 1.1, 0),
- new Point3D(0, 0, -1.1),
- new Point3D(0, 0, 1.1));
+ Point3D.of(-1.1, 0, 0),
+ Point3D.of(1.1, 0, 0),
+ Point3D.of(0, -1.1, 0),
+ Point3D.of(0, 1.1, 0),
+ Point3D.of(0, 0, -1.1),
+ Point3D.of(0, 0, 1.1));
checkPoints(Region.Location.INSIDE, result,
- new Point3D(-0.9, 0, 0),
- new Point3D(0.9, 0, 0),
- new Point3D(0, -0.9, 0),
- new Point3D(0, 0.9, 0),
- new Point3D(0, 0, -0.9),
- new Point3D(0, 0, 0.9),
+ Point3D.of(-0.9, 0, 0),
+ Point3D.of(0.9, 0, 0),
+ Point3D.of(0, -0.9, 0),
+ Point3D.of(0, 0.9, 0),
+ Point3D.of(0, 0, -0.9),
+ Point3D.of(0, 0, 0.9),
Point3D.ZERO);
}
@@ -997,7 +997,7 @@ public class PolyhedronsSetTest {
double size = 1.0;
double radius = size * 0.5;
PolyhedronsSet box = new PolyhedronsSet(0, size, 0, size, 0, size, TEST_TOLERANCE);
- PolyhedronsSet sphere = createSphere(new Point3D(size * 0.5, size * 0.5, size), radius, 8, 16);
+ PolyhedronsSet sphere = createSphere(Point3D.of(size * 0.5, size * 0.5, size), radius, 8, 16);
// act
PolyhedronsSet result = (PolyhedronsSet) new RegionFactory<Point3D>().intersection(box, sphere);
@@ -1012,20 +1012,20 @@ public class PolyhedronsSetTest {
Assert.assertFalse(result.isFull());
checkPoints(Region.Location.OUTSIDE, result,
- new Point3D(-0.1, 0.5, 1.0),
- new Point3D(1.1, 0.5, 1.0),
- new Point3D(0.5, -0.1, 1.0),
- new Point3D(0.5, 1.1, 1.0),
- new Point3D(0.5, 0.5, 0.4),
- new Point3D(0.5, 0.5, 1.1));
+ Point3D.of(-0.1, 0.5, 1.0),
+ Point3D.of(1.1, 0.5, 1.0),
+ Point3D.of(0.5, -0.1, 1.0),
+ Point3D.of(0.5, 1.1, 1.0),
+ Point3D.of(0.5, 0.5, 0.4),
+ Point3D.of(0.5, 0.5, 1.1));
checkPoints(Region.Location.INSIDE, result,
- new Point3D(0.1, 0.5, 0.9),
- new Point3D(0.9, 0.5, 0.9),
- new Point3D(0.5, 0.1, 0.9),
- new Point3D(0.5, 0.9, 0.9),
- new Point3D(0.5, 0.5, 0.6),
- new Point3D(0.5, 0.5, 0.9));
+ Point3D.of(0.1, 0.5, 0.9),
+ Point3D.of(0.9, 0.5, 0.9),
+ Point3D.of(0.5, 0.1, 0.9),
+ Point3D.of(0.5, 0.9, 0.9),
+ Point3D.of(0.5, 0.5, 0.6),
+ Point3D.of(0.5, 0.5, 0.9));
}
@Test
@@ -1047,20 +1047,20 @@ public class PolyhedronsSetTest {
Assert.assertFalse(result.isFull());
checkPoints(Region.Location.OUTSIDE, result,
- new Point3D(-1.1, 0, 0),
- new Point3D(1.1, 0, 0),
- new Point3D(0, -1.1, 0),
- new Point3D(0, 1.1, 0),
- new Point3D(0, 0, -1.1),
- new Point3D(0, 0, 1.1));
+ Point3D.of(-1.1, 0, 0),
+ Point3D.of(1.1, 0, 0),
+ Point3D.of(0, -1.1, 0),
+ Point3D.of(0, 1.1, 0),
+ Point3D.of(0, 0, -1.1),
+ Point3D.of(0, 0, 1.1));
checkPoints(Region.Location.INSIDE, result,
- new Point3D(-0.9, 0, 0),
- new Point3D(0.9, 0, 0),
- new Point3D(0, -0.9, 0),
- new Point3D(0, 0.9, 0),
- new Point3D(0, 0, -0.9),
- new Point3D(0, 0, 0.9),
+ Point3D.of(-0.9, 0, 0),
+ Point3D.of(0.9, 0, 0),
+ Point3D.of(0, -0.9, 0),
+ Point3D.of(0, 0.9, 0),
+ Point3D.of(0, 0, -0.9),
+ Point3D.of(0, 0, 0.9),
Point3D.ZERO);
}
@@ -1090,21 +1090,21 @@ public class PolyhedronsSetTest {
Assert.assertFalse(result.isFull());
checkPoints(Region.Location.OUTSIDE, result,
- new Point3D(-0.1, -0.1, -0.1),
- new Point3D(0.75, 0.75, 0.75),
- new Point3D(1.6, 1.6, 1.6));
+ Point3D.of(-0.1, -0.1, -0.1),
+ Point3D.of(0.75, 0.75, 0.75),
+ Point3D.of(1.6, 1.6, 1.6));
checkPoints(Region.Location.BOUNDARY, result,
- new Point3D(0, 0, 0),
- new Point3D(0.5, 0.5, 0.5),
- new Point3D(1, 1, 1),
- new Point3D(1.5, 1.5, 1.5));
+ Point3D.of(0, 0, 0),
+ Point3D.of(0.5, 0.5, 0.5),
+ Point3D.of(1, 1, 1),
+ Point3D.of(1.5, 1.5, 1.5));
checkPoints(Region.Location.INSIDE, result,
- new Point3D(0.1, 0.1, 0.1),
- new Point3D(0.4, 0.4, 0.4),
- new Point3D(1.1, 1.1, 1.1),
- new Point3D(1.4, 1.4, 1.4));
+ Point3D.of(0.1, 0.1, 0.1),
+ Point3D.of(0.4, 0.4, 0.4),
+ Point3D.of(1.1, 1.1, 1.1),
+ Point3D.of(1.4, 1.4, 1.4));
}
@Test
@@ -1114,7 +1114,7 @@ public class PolyhedronsSetTest {
double size = 1.0;
double radius = size * 0.5;
PolyhedronsSet box = new PolyhedronsSet(0, size, 0, size, 0, size, TEST_TOLERANCE);
- PolyhedronsSet sphere = createSphere(new Point3D(size * 0.5, size * 0.5, size), radius, 8, 16);
+ PolyhedronsSet sphere = createSphere(Point3D.of(size * 0.5, size * 0.5, size), radius, 8, 16);
// act
PolyhedronsSet result = (PolyhedronsSet) new RegionFactory<Point3D>().xor(box, sphere);
@@ -1130,21 +1130,21 @@ public class PolyhedronsSetTest {
Assert.assertFalse(result.isFull());
checkPoints(Region.Location.OUTSIDE, result,
- new Point3D(-0.1, 0.5, 0.5),
- new Point3D(1.1, 0.5, 0.5),
- new Point3D(0.5, -0.1, 0.5),
- new Point3D(0.5, 1.1, 0.5),
- new Point3D(0.5, 0.5, -0.1),
- new Point3D(0.5, 0.5, 1.6),
- new Point3D(0.5, 0.5, 0.9));
+ Point3D.of(-0.1, 0.5, 0.5),
+ Point3D.of(1.1, 0.5, 0.5),
+ Point3D.of(0.5, -0.1, 0.5),
+ Point3D.of(0.5, 1.1, 0.5),
+ Point3D.of(0.5, 0.5, -0.1),
+ Point3D.of(0.5, 0.5, 1.6),
+ Point3D.of(0.5, 0.5, 0.9));
checkPoints(Region.Location.INSIDE, result,
- new Point3D(0.1, 0.5, 0.5),
- new Point3D(0.9, 0.5, 0.5),
- new Point3D(0.5, 0.1, 0.5),
- new Point3D(0.5, 0.9, 0.5),
- new Point3D(0.5, 0.5, 0.1),
- new Point3D(0.5, 0.5, 1.4));
+ Point3D.of(0.1, 0.5, 0.5),
+ Point3D.of(0.9, 0.5, 0.5),
+ Point3D.of(0.5, 0.1, 0.5),
+ Point3D.of(0.5, 0.9, 0.5),
+ Point3D.of(0.5, 0.5, 0.1),
+ Point3D.of(0.5, 0.5, 1.4));
}
@Test
@@ -1165,18 +1165,18 @@ public class PolyhedronsSetTest {
Assert.assertFalse(result.isFull());
checkPoints(Region.Location.OUTSIDE, result,
- new Point3D(-1.1, 0, 0),
- new Point3D(1.1, 0, 0),
- new Point3D(0, -1.1, 0),
- new Point3D(0, 1.1, 0),
- new Point3D(0, 0, -1.1),
- new Point3D(0, 0, 1.1),
- new Point3D(-0.9, 0, 0),
- new Point3D(0.9, 0, 0),
- new Point3D(0, -0.9, 0),
- new Point3D(0, 0.9, 0),
- new Point3D(0, 0, -0.9),
- new Point3D(0, 0, 0.9),
+ Point3D.of(-1.1, 0, 0),
+ Point3D.of(1.1, 0, 0),
+ Point3D.of(0, -1.1, 0),
+ Point3D.of(0, 1.1, 0),
+ Point3D.of(0, 0, -1.1),
+ Point3D.of(0, 0, 1.1),
+ Point3D.of(-0.9, 0, 0),
+ Point3D.of(0.9, 0, 0),
+ Point3D.of(0, -0.9, 0),
+ Point3D.of(0, 0.9, 0),
+ Point3D.of(0, 0, -0.9),
+ Point3D.of(0, 0, 0.9),
Point3D.ZERO);
}
@@ -1187,7 +1187,7 @@ public class PolyhedronsSetTest {
double size = 1.0;
double radius = size * 0.5;
PolyhedronsSet box = new PolyhedronsSet(0, size, 0, size, 0, size, TEST_TOLERANCE);
- PolyhedronsSet sphere = createSphere(new Point3D(size * 0.5, size * 0.5, size), radius, 8, 16);
+ PolyhedronsSet sphere = createSphere(Point3D.of(size * 0.5, size * 0.5, size), radius, 8, 16);
// act
PolyhedronsSet result = (PolyhedronsSet) new RegionFactory<Point3D>().difference(box, sphere);
@@ -1202,20 +1202,20 @@ public class PolyhedronsSetTest {
Assert.assertFalse(result.isFull());
checkPoints(Region.Location.OUTSIDE, result,
- new Point3D(-0.1, 0.5, 1.0),
- new Point3D(1.1, 0.5, 1.0),
- new Point3D(0.5, -0.1, 1.0),
- new Point3D(0.5, 1.1, 1.0),
- new Point3D(0.5, 0.5, -0.1),
- new Point3D(0.5, 0.5, 0.6));
+ Point3D.of(-0.1, 0.5, 1.0),
+ Point3D.of(1.1, 0.5, 1.0),
+ Point3D.of(0.5, -0.1, 1.0),
+ Point3D.of(0.5, 1.1, 1.0),
+ Point3D.of(0.5, 0.5, -0.1),
+ Point3D.of(0.5, 0.5, 0.6));
checkPoints(Region.Location.INSIDE, result,
- new Point3D(0.1, 0.5, 0.4),
- new Point3D(0.9, 0.5, 0.4),
- new Point3D(0.5, 0.1, 0.4),
- new Point3D(0.5, 0.9, 0.4),
- new Point3D(0.5, 0.5, 0.1),
- new Point3D(0.5, 0.5, 0.4));
+ Point3D.of(0.1, 0.5, 0.4),
+ Point3D.of(0.9, 0.5, 0.4),
+ Point3D.of(0.5, 0.1, 0.4),
+ Point3D.of(0.5, 0.9, 0.4),
+ Point3D.of(0.5, 0.5, 0.1),
+ Point3D.of(0.5, 0.5, 0.4));
}
@Test
@@ -1236,18 +1236,18 @@ public class PolyhedronsSetTest {
Assert.assertFalse(result.isFull());
checkPoints(Region.Location.OUTSIDE, result,
- new Point3D(-1.1, 0, 0),
- new Point3D(1.1, 0, 0),
- new Point3D(0, -1.1, 0),
- new Point3D(0, 1.1, 0),
- new Point3D(0, 0, -1.1),
- new Point3D(0, 0, 1.1),
- new Point3D(-0.9, 0, 0),
- new Point3D(0.9, 0, 0),
- new Point3D(0, -0.9, 0),
- new Point3D(0, 0.9, 0),
- new Point3D(0, 0, -0.9),
- new Point3D(0, 0, 0.9),
+ Point3D.of(-1.1, 0, 0),
+ Point3D.of(1.1, 0, 0),
+ Point3D.of(0, -1.1, 0),
+ Point3D.of(0, 1.1, 0),
+ Point3D.of(0, 0, -1.1),
+ Point3D.of(0, 0, 1.1),
+ Point3D.of(-0.9, 0, 0),
+ Point3D.of(0.9, 0, 0),
+ Point3D.of(0, -0.9, 0),
+ Point3D.of(0, 0.9, 0),
+ Point3D.of(0, 0, -0.9),
+ Point3D.of(0, 0, 0.9),
Point3D.ZERO);
}
@@ -1258,9 +1258,9 @@ public class PolyhedronsSetTest {
double size = 1.0;
double radius = size * 0.5;
PolyhedronsSet box = new PolyhedronsSet(0, size, 0, size, 0, size, TEST_TOLERANCE);
- PolyhedronsSet sphereToAdd = createSphere(new Point3D(size * 0.5, size * 0.5, size), radius, 8, 16);
- PolyhedronsSet sphereToRemove1 = createSphere(new Point3D(size * 0.5, 0, size * 0.5), radius, 8, 16);
- PolyhedronsSet sphereToRemove2 = createSphere(new Point3D(size * 0.5, 1, size * 0.5), radius, 8, 16);
+ PolyhedronsSet sphereToAdd = createSphere(Point3D.of(size * 0.5, size * 0.5, size), radius, 8, 16);
+ PolyhedronsSet sphereToRemove1 = createSphere(Point3D.of(size * 0.5, 0, size * 0.5), radius, 8, 16);
+ PolyhedronsSet sphereToRemove2 = createSphere(Point3D.of(size * 0.5, 1, size * 0.5), radius, 8, 16);
RegionFactory<Point3D> factory = new RegionFactory<Point3D>();
@@ -1280,20 +1280,20 @@ public class PolyhedronsSetTest {
Assert.assertFalse(result.isFull());
checkPoints(Region.Location.OUTSIDE, result,
- new Point3D(-0.1, 0.5, 0.5),
- new Point3D(1.1, 0.5, 0.5),
- new Point3D(0.5, 0.4, 0.5),
- new Point3D(0.5, 0.6, 0.5),
- new Point3D(0.5, 0.5, -0.1),
- new Point3D(0.5, 0.5, 1.6));
+ Point3D.of(-0.1, 0.5, 0.5),
+ Point3D.of(1.1, 0.5, 0.5),
+ Point3D.of(0.5, 0.4, 0.5),
+ Point3D.of(0.5, 0.6, 0.5),
+ Point3D.of(0.5, 0.5, -0.1),
+ Point3D.of(0.5, 0.5, 1.6));
checkPoints(Region.Location.INSIDE, result,
- new Point3D(0.1, 0.5, 0.1),
- new Point3D(0.9, 0.5, 0.1),
- new Point3D(0.5, 0.4, 0.1),
- new Point3D(0.5, 0.6, 0.1),
- new Point3D(0.5, 0.5, 0.1),
- new Point3D(0.5, 0.5, 1.4));
+ Point3D.of(0.1, 0.5, 0.1),
+ Point3D.of(0.9, 0.5, 0.1),
+ Point3D.of(0.5, 0.4, 0.1),
+ Point3D.of(0.5, 0.6, 0.1),
+ Point3D.of(0.5, 0.5, 0.1),
+ Point3D.of(0.5, 0.5, 1.4));
}
@Test
@@ -1302,12 +1302,12 @@ public class PolyhedronsSetTest {
PolyhedronsSet polySet = new PolyhedronsSet(0, 1, 0, 1, 0, 1, TEST_TOLERANCE);
// act/assert
- checkProjectToBoundary(polySet, new Point3D(0.4, 0.5, 0.5),
- new Point3D(0, 0.5, 0.5), -0.4);
- checkProjectToBoundary(polySet, new Point3D(1.5, 0.5, 0.5),
- new Point3D(1, 0.5, 0.5), 0.5);
- checkProjectToBoundary(polySet, new Point3D(2, 2, 2),
- new Point3D(1, 1, 1), Math.sqrt(3));
+ checkProjectToBoundary(polySet, Point3D.of(0.4, 0.5, 0.5),
+ Point3D.of(0, 0.5, 0.5), -0.4);
+ checkProjectToBoundary(polySet, Point3D.of(1.5, 0.5, 0.5),
+ Point3D.of(1, 0.5, 0.5), 0.5);
+ checkProjectToBoundary(polySet, Point3D.of(2, 2, 2),
+ Point3D.of(1, 1, 1), Math.sqrt(3));
}
@Test
@@ -1317,12 +1317,12 @@ public class PolyhedronsSetTest {
polySet = (PolyhedronsSet) new RegionFactory<Point3D>().getComplement(polySet);
// act/assert
- checkProjectToBoundary(polySet, new Point3D(0.4, 0.5, 0.5),
- new Point3D(0, 0.5, 0.5), 0.4);
- checkProjectToBoundary(polySet, new Point3D(1.5, 0.5, 0.5),
- new Point3D(1, 0.5, 0.5), -0.5);
- checkProjectToBoundary(polySet, new Point3D(2, 2, 2),
- new Point3D(1, 1, 1), -Math.sqrt(3));
+ checkProjectToBoundary(polySet, Point3D.of(0.4, 0.5, 0.5),
+ Point3D.of(0, 0.5, 0.5), 0.4);
+ checkProjectToBoundary(polySet, Point3D.of(1.5, 0.5, 0.5),
+ Point3D.of(1, 0.5, 0.5), -0.5);
+ checkProjectToBoundary(polySet, Point3D.of(2, 2, 2),
+ Point3D.of(1, 1, 1), -Math.sqrt(3));
}
private void checkProjectToBoundary(PolyhedronsSet poly, Point3D toProject,
@@ -1356,54 +1356,54 @@ public class PolyhedronsSetTest {
double offset = size * 0.5;
- Plane xMinus = new Plane(center.add(new Vector3D(-offset, 0, 0)), Vector3D.MINUS_X, tolerance);
- Plane xPlus = new Plane(center.add(new Vector3D(offset, 0, 0)), Vector3D.PLUS_X, tolerance);
- Plane yPlus = new Plane(center.add(new Vector3D(0, offset, 0)), Vector3D.PLUS_Y, tolerance);
- Plane yMinus = new Plane(center.add(new Vector3D(0, -offset, 0)), Vector3D.MINUS_Y, tolerance);
- Plane zPlus = new Plane(center.add(new Vector3D(0, 0, offset)), Vector3D.PLUS_Z, tolerance);
- Plane zMinus = new Plane(center.add(new Vector3D(0, 0, -offset)), Vector3D.MINUS_Z, tolerance);
+ Plane xMinus = new Plane(center.add(Vector3D.of(-offset, 0, 0)), Vector3D.MINUS_X, tolerance);
+ Plane xPlus = new Plane(center.add(Vector3D.of(offset, 0, 0)), Vector3D.PLUS_X, tolerance);
+ Plane yPlus = new Plane(center.add(Vector3D.of(0, offset, 0)), Vector3D.PLUS_Y, tolerance);
+ Plane yMinus = new Plane(center.add(Vector3D.of(0, -offset, 0)), Vector3D.MINUS_Y, tolerance);
+ Plane zPlus = new Plane(center.add(Vector3D.of(0, 0, offset)), Vector3D.PLUS_Z, tolerance);
+ Plane zMinus = new Plane(center.add(Vector3D.of(0, 0, -offset)), Vector3D.MINUS_Z, tolerance);
// +x
boundaries.add(createSubPlane(xPlus,
- center.add(new Vector3D(offset, offset, offset)),
- center.add(new Vector3D(offset, -offset, offset)),
- center.add(new Vector3D(offset, -offset, -offset)),
- center.add(new Vector3D(offset, offset, -offset))));
+ center.add(Vector3D.of(offset, offset, offset)),
+ center.add(Vector3D.of(offset, -offset, offset)),
+ center.add(Vector3D.of(offset, -offset, -offset)),
+ center.add(Vector3D.of(offset, offset, -offset))));
// -x
boundaries.add(createSubPlane(xMinus,
- center.add(new Vector3D(-offset, -offset, offset)),
- center.add(new Vector3D(-offset, offset, offset)),
- center.add(new Vector3D(-offset, offset, -offset)),
- center.add(new Vector3D(-offset, -offset, -offset))));
+ center.add(Vector3D.of(-offset, -offset, offset)),
+ center.add(Vector3D.of(-offset, offset, offset)),
+ center.add(Vector3D.of(-offset, offset, -offset)),
+ center.add(Vector3D.of(-offset, -offset, -offset))));
// +y
boundaries.add(createSubPlane(yPlus,
- center.add(new Vector3D(-offset, offset, offset)),
- center.add(new Vector3D(offset, offset, offset)),
- center.add(new Vector3D(offset, offset, -offset)),
- center.add(new Vector3D(-offset, offset, -offset))));
+ center.add(Vector3D.of(-offset, offset, offset)),
+ center.add(Vector3D.of(offset, offset, offset)),
+ center.add(Vector3D.of(offset, offset, -offset)),
+ center.add(Vector3D.of(-offset, offset, -offset))));
// -y
boundaries.add(createSubPlane(yMinus,
- center.add(new Vector3D(-offset, -offset, offset)),
- center.add(new Vector3D(-offset, -offset, -offset)),
- center.add(new Vector3D(offset, -offset, -offset)),
- center.add(new Vector3D(offset, -offset, offset))));
+ center.add(Vector3D.of(-offset, -offset, offset)),
+ center.add(Vector3D.of(-offset, -offset, -offset)),
+ center.add(Vector3D.of(offset, -offset, -offset)),
+ center.add(Vector3D.of(offset, -offset, offset))));
// +z
boundaries.add(createSubPlane(zPlus,
- center.add(new Vector3D(-offset, -offset, offset)),
- center.add(new Vector3D(offset, -offset, offset)),
- center.add(new Vector3D(offset, offset, offset)),
- center.add(new Vector3D(-offset, offset, offset))));
+ center.add(Vector3D.of(-offset, -offset, offset)),
+ center.add(Vector3D.of(offset, -offset, offset)),
+ center.add(Vector3D.of(offset, offset, offset)),
+ center.add(Vector3D.of(-offset, offset, offset))));
// -z
boundaries.add(createSubPlane(zMinus,
- center.add(new Vector3D(-offset, -offset, -offset)),
- center.add(new Vector3D(-offset, offset, -offset)),
- center.add(new Vector3D(offset, offset, -offset)),
- center.add(new Vector3D(offset, -offset, -offset))));
+ center.add(Vector3D.of(-offset, -offset, -offset)),
+ center.add(Vector3D.of(-offset, offset, -offset)),
+ center.add(Vector3D.of(offset, offset, -offset)),
+ center.add(Vector3D.of(offset, -offset, -offset))));
return boundaries;
}
@@ -1423,8 +1423,8 @@ public class PolyhedronsSetTest {
List<Plane> planes = new ArrayList<>();
// add top and bottom planes (+/- z)
- Point3D topZ = new Point3D(center.getX(), center.getY(), center.getZ() + radius);
- Point3D bottomZ = new Point3D(center.getX(), center.getY(), center.getZ() - radius);
+ Point3D topZ = Point3D.of(center.getX(), center.getY(), center.getZ() + radius);
+ Point3D bottomZ = Point3D.of(center.getX(), center.getY(), center.getZ() - radius);
planes.add(new Plane(topZ, Vector3D.PLUS_Z, TEST_TOLERANCE));
planes.add(new Plane(bottomZ, Vector3D.MINUS_Z, TEST_TOLERANCE));
@@ -1457,7 +1457,7 @@ public class PolyhedronsSetTest {
x = Math.cos(hAngle) * stackRadius;
y = Math.sin(hAngle) * stackRadius;
- norm = new Vector3D(x, y, stackHeight).normalize();
+ norm = Vector3D.of(x, y, stackHeight).normalize();
pt = center.add(norm.scalarMultiply(adjustedRadius));
planes.add(new Plane(pt, norm, TEST_TOLERANCE));
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/RotationTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/RotationTest.java
index 875575b..ca28f44 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/RotationTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/RotationTest.java
@@ -51,22 +51,22 @@ public class RotationTest {
@Deprecated
public void testAxisAngleDeprecated() {
- Rotation r = new Rotation(new Vector3D(10, 10, 10), 2 * Math.PI / 3);
+ Rotation r = new Rotation(Vector3D.of(10, 10, 10), 2 * Math.PI / 3);
checkVector(r.applyTo(Vector3D.PLUS_X), Vector3D.PLUS_Y);
checkVector(r.applyTo(Vector3D.PLUS_Y), Vector3D.PLUS_Z);
checkVector(r.applyTo(Vector3D.PLUS_Z), Vector3D.PLUS_X);
double s = 1 / Math.sqrt(3);
- checkVector(r.getAxis(), new Vector3D(s, s, s));
+ checkVector(r.getAxis(), Vector3D.of(s, s, s));
checkAngle(r.getAngle(), 2 * Math.PI / 3);
try {
- new Rotation(new Vector3D(0, 0, 0), 2 * Math.PI / 3);
+ new Rotation(Vector3D.of(0, 0, 0), 2 * Math.PI / 3);
Assert.fail("an exception should have been thrown");
} catch (IllegalArgumentException e) {
}
r = new Rotation(Vector3D.PLUS_Z, 1.5 * Math.PI);
- checkVector(r.getAxis(), new Vector3D(0, 0, -1));
+ checkVector(r.getAxis(), Vector3D.of(0, 0, -1));
checkAngle(r.getAngle(), 0.5 * Math.PI);
r = new Rotation(Vector3D.PLUS_Y, Math.PI);
@@ -80,24 +80,24 @@ public class RotationTest {
@Test
public void testAxisAngleVectorOperator() {
- Rotation r = new Rotation(new Vector3D(10, 10, 10), 2 * Math.PI / 3, RotationConvention.VECTOR_OPERATOR);
+ Rotation r = new Rotation(Vector3D.of(10, 10, 10), 2 * Math.PI / 3, RotationConvention.VECTOR_OPERATOR);
checkVector(r.applyTo(Vector3D.PLUS_X), Vector3D.PLUS_Y);
checkVector(r.applyTo(Vector3D.PLUS_Y), Vector3D.PLUS_Z);
checkVector(r.applyTo(Vector3D.PLUS_Z), Vector3D.PLUS_X);
double s = 1 / Math.sqrt(3);
- checkVector(r.getAxis(RotationConvention.VECTOR_OPERATOR), new Vector3D( s, s, s));
- checkVector(r.getAxis(RotationConvention.FRAME_TRANSFORM), new Vector3D(-s, -s, -s));
+ checkVector(r.getAxis(RotationConvention.VECTOR_OPERATOR), Vector3D.of( s, s, s));
+ checkVector(r.getAxis(RotationConvention.FRAME_TRANSFORM), Vector3D.of(-s, -s, -s));
checkAngle(r.getAngle(), 2 * Math.PI / 3);
try {
- new Rotation(new Vector3D(0, 0, 0), 2 * Math.PI / 3, RotationConvention.VECTOR_OPERATOR);
+ new Rotation(Vector3D.of(0, 0, 0), 2 * Math.PI / 3, RotationConvention.VECTOR_OPERATOR);
Assert.fail("an exception should have been thrown");
} catch (IllegalArgumentException e) {
}
r = new Rotation(Vector3D.PLUS_Z, 1.5 * Math.PI, RotationConvention.VECTOR_OPERATOR);
- checkVector(r.getAxis(RotationConvention.VECTOR_OPERATOR), new Vector3D(0, 0, -1));
- checkVector(r.getAxis(RotationConvention.FRAME_TRANSFORM), new Vector3D(0, 0, +1));
+ checkVector(r.getAxis(RotationConvention.VECTOR_OPERATOR), Vector3D.of(0, 0, -1));
+ checkVector(r.getAxis(RotationConvention.FRAME_TRANSFORM), Vector3D.of(0, 0, +1));
checkAngle(r.getAngle(), 0.5 * Math.PI);
r = new Rotation(Vector3D.PLUS_Y, Math.PI, RotationConvention.VECTOR_OPERATOR);
@@ -113,24 +113,24 @@ public class RotationTest {
@Test
public void testAxisAngleFrameTransform() {
- Rotation r = new Rotation(new Vector3D(10, 10, 10), 2 * Math.PI / 3, RotationConvention.FRAME_TRANSFORM);
+ Rotation r = new Rotation(Vector3D.of(10, 10, 10), 2 * Math.PI / 3, RotationConvention.FRAME_TRANSFORM);
checkVector(r.applyTo(Vector3D.PLUS_X), Vector3D.PLUS_Z);
checkVector(r.applyTo(Vector3D.PLUS_Y), Vector3D.PLUS_X);
checkVector(r.applyTo(Vector3D.PLUS_Z), Vector3D.PLUS_Y);
double s = 1 / Math.sqrt(3);
- checkVector(r.getAxis(RotationConvention.FRAME_TRANSFORM), new Vector3D( s, s, s));
- checkVector(r.getAxis(RotationConvention.VECTOR_OPERATOR), new Vector3D(-s, -s, -s));
+ checkVector(r.getAxis(RotationConvention.FRAME_TRANSFORM), Vector3D.of( s, s, s));
+ checkVector(r.getAxis(RotationConvention.VECTOR_OPERATOR), Vector3D.of(-s, -s, -s));
checkAngle(r.getAngle(), 2 * Math.PI / 3);
try {
- new Rotation(new Vector3D(0, 0, 0), 2 * Math.PI / 3, RotationConvention.FRAME_TRANSFORM);
+ new Rotation(Vector3D.of(0, 0, 0), 2 * Math.PI / 3, RotationConvention.FRAME_TRANSFORM);
Assert.fail("an exception should have been thrown");
} catch (IllegalArgumentException e) {
}
r = new Rotation(Vector3D.PLUS_Z, 1.5 * Math.PI, RotationConvention.FRAME_TRANSFORM);
- checkVector(r.getAxis(RotationConvention.FRAME_TRANSFORM), new Vector3D(0, 0, -1));
- checkVector(r.getAxis(RotationConvention.VECTOR_OPERATOR), new Vector3D(0, 0, +1));
+ checkVector(r.getAxis(RotationConvention.FRAME_TRANSFORM), Vector3D.of(0, 0, -1));
+ checkVector(r.getAxis(RotationConvention.VECTOR_OPERATOR), Vector3D.of(0, 0, +1));
checkAngle(r.getAngle(), 0.5 * Math.PI);
r = new Rotation(Vector3D.PLUS_Y, Math.PI, RotationConvention.FRAME_TRANSFORM);
@@ -185,8 +185,8 @@ public class RotationTest {
@Test
public void testVectorOnePair() {
- Vector3D u = new Vector3D(3, 2, 1);
- Vector3D v = new Vector3D(-4, 2, 2);
+ Vector3D u = Vector3D.of(3, 2, 1);
+ Vector3D v = Vector3D.of(-4, 2, 2);
Rotation r = new Rotation(u, v);
checkVector(r.applyTo(u.scalarMultiply(v.getNorm())), v.scalarMultiply(u.getNorm()));
@@ -204,10 +204,10 @@ public class RotationTest {
@Test
public void testVectorTwoPairs() {
- Vector3D u1 = new Vector3D(3, 0, 0);
- Vector3D u2 = new Vector3D(0, 5, 0);
- Vector3D v1 = new Vector3D(0, 0, 2);
- Vector3D v2 = new Vector3D(-2, 0, 2);
+ Vector3D u1 = Vector3D.of(3, 0, 0);
+ Vector3D u2 = Vector3D.of(0, 5, 0);
+ Vector3D v1 = Vector3D.of(0, 0, 2);
+ Vector3D v2 = Vector3D.of(-2, 0, 2);
Rotation r = new Rotation(u1, u2, v1, v2);
checkVector(r.applyTo(Vector3D.PLUS_X), Vector3D.PLUS_Z);
checkVector(r.applyTo(Vector3D.PLUS_Y), Vector3D.MINUS_X);
@@ -223,8 +223,8 @@ public class RotationTest {
double sqrt = Math.sqrt(2) / 2;
r = new Rotation(Vector3D.PLUS_X, Vector3D.PLUS_Y,
- new Vector3D(0.5, 0.5, sqrt),
- new Vector3D(0.5, 0.5, -sqrt));
+ Vector3D.of(0.5, 0.5, sqrt),
+ Vector3D.of(0.5, 0.5, -sqrt));
checkRotation(r, sqrt, 0.5, 0.5, 0);
r = new Rotation(u1, u2, u1, u1.crossProduct(u2));
@@ -362,11 +362,11 @@ public class RotationTest {
}
checkVector(r.applyTo(Vector3D.PLUS_X),
- new Vector3D(m3[0][0], m3[1][0], m3[2][0]));
+ Vector3D.of(m3[0][0], m3[1][0], m3[2][0]));
checkVector(r.applyTo(Vector3D.PLUS_Y),
- new Vector3D(m3[0][1], m3[1][1], m3[2][1]));
+ Vector3D.of(m3[0][1], m3[1][1], m3[2][1]));
checkVector(r.applyTo(Vector3D.PLUS_Z),
- new Vector3D(m3[0][2], m3[1][2], m3[2][2]));
+ Vector3D.of(m3[0][2], m3[1][2], m3[2][2]));
double[][] m4 = { { 1.0, 0.0, 0.0 },
{ 0.0, -1.0, 0.0 },
@@ -524,7 +524,7 @@ public class RotationTest {
@Test
public void testQuaternion() {
- Rotation r1 = new Rotation(new Vector3D(2, -3, 5), 1.7, RotationConvention.VECTOR_OPERATOR);
+ Rotation r1 = new Rotation(Vector3D.of(2, -3, 5), 1.7, RotationConvention.VECTOR_OPERATOR);
double n = 23.5;
Rotation r2 = new Rotation(n * r1.getQ0(), n * r1.getQ1(),
n * r1.getQ2(), n * r1.getQ3(),
@@ -532,7 +532,7 @@ public class RotationTest {
for (double x = -0.9; x < 0.9; x += 0.2) {
for (double y = -0.9; y < 0.9; y += 0.2) {
for (double z = -0.9; z < 0.9; z += 0.2) {
- Vector3D u = new Vector3D(x, y, z);
+ Vector3D u = Vector3D.of(x, y, z);
checkVector(r2.applyTo(u), r1.applyTo(u));
}
}
@@ -546,14 +546,14 @@ public class RotationTest {
@Test
public void testApplyTo() {
- Rotation r1 = new Rotation(new Vector3D(2, -3, 5), 1.7, RotationConvention.VECTOR_OPERATOR);
- Rotation r2 = new Rotation(new Vector3D(-1, 3, 2), 0.3, RotationConvention.VECTOR_OPERATOR);
+ Rotation r1 = new Rotation(Vector3D.of(2, -3, 5), 1.7, RotationConvention.VECTOR_OPERATOR);
+ Rotation r2 = new Rotation(Vector3D.of(-1, 3, 2), 0.3, RotationConvention.VECTOR_OPERATOR);
Rotation r3 = r2.applyTo(r1);
for (double x = -0.9; x < 0.9; x += 0.2) {
for (double y = -0.9; y < 0.9; y += 0.2) {
for (double z = -0.9; z < 0.9; z += 0.2) {
- Vector3D u = new Vector3D(x, y, z);
+ Vector3D u = Vector3D.of(x, y, z);
checkVector(r2.applyTo(r1.applyTo(u)), r3.applyTo(u));
}
}
@@ -564,14 +564,14 @@ public class RotationTest {
@Test
public void testComposeVectorOperator() {
- Rotation r1 = new Rotation(new Vector3D(2, -3, 5), 1.7, RotationConvention.VECTOR_OPERATOR);
- Rotation r2 = new Rotation(new Vector3D(-1, 3, 2), 0.3, RotationConvention.VECTOR_OPERATOR);
+ Rotation r1 = new Rotation(Vector3D.of(2, -3, 5), 1.7, RotationConvention.VECTOR_OPERATOR);
+ Rotation r2 = new Rotation(Vector3D.of(-1, 3, 2), 0.3, RotationConvention.VECTOR_OPERATOR);
Rotation r3 = r2.compose(r1, RotationConvention.VECTOR_OPERATOR);
for (double x = -0.9; x < 0.9; x += 0.2) {
for (double y = -0.9; y < 0.9; y += 0.2) {
for (double z = -0.9; z < 0.9; z += 0.2) {
- Vector3D u = new Vector3D(x, y, z);
+ Vector3D u = Vector3D.of(x, y, z);
checkVector(r2.applyTo(r1.applyTo(u)), r3.applyTo(u));
}
}
@@ -582,8 +582,8 @@ public class RotationTest {
@Test
public void testComposeFrameTransform() {
- Rotation r1 = new Rotation(new Vector3D(2, -3, 5), 1.7, RotationConvention.FRAME_TRANSFORM);
- Rotation r2 = new Rotation(new Vector3D(-1, 3, 2), 0.3, RotationConvention.FRAME_TRANSFORM);
+ Rotation r1 = new Rotation(Vector3D.of(2, -3, 5), 1.7, RotationConvention.FRAME_TRANSFORM);
+ Rotation r2 = new Rotation(Vector3D.of(-1, 3, 2), 0.3, RotationConvention.FRAME_TRANSFORM);
Rotation r3 = r2.compose(r1, RotationConvention.FRAME_TRANSFORM);
Rotation r4 = r1.compose(r2, RotationConvention.VECTOR_OPERATOR);
Assert.assertEquals(0.0, Rotation.distance(r3, r4), 1.0e-15);
@@ -591,7 +591,7 @@ public class RotationTest {
for (double x = -0.9; x < 0.9; x += 0.2) {
for (double y = -0.9; y < 0.9; y += 0.2) {
for (double z = -0.9; z < 0.9; z += 0.2) {
- Vector3D u = new Vector3D(x, y, z);
+ Vector3D u = Vector3D.of(x, y, z);
checkVector(r1.applyTo(r2.applyTo(u)), r3.applyTo(u));
}
}
@@ -602,14 +602,14 @@ public class RotationTest {
@Test
public void testApplyInverseToRotation() {
- Rotation r1 = new Rotation(new Vector3D(2, -3, 5), 1.7, RotationConvention.VECTOR_OPERATOR);
- Rotation r2 = new Rotation(new Vector3D(-1, 3, 2), 0.3, RotationConvention.VECTOR_OPERATOR);
+ Rotation r1 = new Rotation(Vector3D.of(2, -3, 5), 1.7, RotationConvention.VECTOR_OPERATOR);
+ Rotation r2 = new Rotation(Vector3D.of(-1, 3, 2), 0.3, RotationConvention.VECTOR_OPERATOR);
Rotation r3 = r2.applyInverseTo(r1);
for (double x = -0.9; x < 0.9; x += 0.2) {
for (double y = -0.9; y < 0.9; y += 0.2) {
for (double z = -0.9; z < 0.9; z += 0.2) {
- Vector3D u = new Vector3D(x, y, z);
+ Vector3D u = Vector3D.of(x, y, z);
checkVector(r2.applyInverseTo(r1.applyTo(u)), r3.applyTo(u));
}
}
@@ -620,14 +620,14 @@ public class RotationTest {
@Test
public void testComposeInverseVectorOperator() {
- Rotation r1 = new Rotation(new Vector3D(2, -3, 5), 1.7, RotationConvention.VECTOR_OPERATOR);
- Rotation r2 = new Rotation(new Vector3D(-1, 3, 2), 0.3, RotationConvention.VECTOR_OPERATOR);
+ Rotation r1 = new Rotation(Vector3D.of(2, -3, 5), 1.7, RotationConvention.VECTOR_OPERATOR);
+ Rotation r2 = new Rotation(Vector3D.of(-1, 3, 2), 0.3, RotationConvention.VECTOR_OPERATOR);
Rotation r3 = r2.composeInverse(r1, RotationConvention.VECTOR_OPERATOR);
for (double x = -0.9; x < 0.9; x += 0.2) {
for (double y = -0.9; y < 0.9; y += 0.2) {
for (double z = -0.9; z < 0.9; z += 0.2) {
- Vector3D u = new Vector3D(x, y, z);
+ Vector3D u = Vector3D.of(x, y, z);
checkVector(r2.applyInverseTo(r1.applyTo(u)), r3.applyTo(u));
}
}
@@ -638,8 +638,8 @@ public class RotationTest {
@Test
public void testComposeInverseFrameTransform() {
- Rotation r1 = new Rotation(new Vector3D(2, -3, 5), 1.7, RotationConvention.FRAME_TRANSFORM);
- Rotation r2 = new Rotation(new Vector3D(-1, 3, 2), 0.3, RotationConvention.FRAME_TRANSFORM);
+ Rotation r1 = new Rotation(Vector3D.of(2, -3, 5), 1.7, RotationConvention.FRAME_TRANSFORM);
+ Rotation r2 = new Rotation(Vector3D.of(-1, 3, 2), 0.3, RotationConvention.FRAME_TRANSFORM);
Rotation r3 = r2.composeInverse(r1, RotationConvention.FRAME_TRANSFORM);
Rotation r4 = r1.revert().composeInverse(r2.revert(), RotationConvention.VECTOR_OPERATOR);
Assert.assertEquals(0.0, Rotation.distance(r3, r4), 1.0e-15);
@@ -647,7 +647,7 @@ public class RotationTest {
for (double x = -0.9; x < 0.9; x += 0.2) {
for (double y = -0.9; y < 0.9; y += 0.2) {
for (double z = -0.9; z < 0.9; z += 0.2) {
- Vector3D u = new Vector3D(x, y, z);
+ Vector3D u = Vector3D.of(x, y, z);
checkVector(r1.applyTo(r2.applyInverseTo(u)), r3.applyTo(u));
}
}
@@ -658,12 +658,12 @@ public class RotationTest {
@Test
public void testArray() {
- Rotation r = new Rotation(new Vector3D(2, -3, 5), 1.7, RotationConvention.VECTOR_OPERATOR);
+ Rotation r = new Rotation(Vector3D.of(2, -3, 5), 1.7, RotationConvention.VECTOR_OPERATOR);
for (double x = -0.9; x < 0.9; x += 0.2) {
for (double y = -0.9; y < 0.9; y += 0.2) {
for (double z = -0.9; z < 0.9; z += 0.2) {
- Vector3D u = new Vector3D(x, y, z);
+ Vector3D u = Vector3D.of(x, y, z);
Vector3D v = r.applyTo(u);
double[] inOut = new double[] { x, y, z };
r.applyTo(inOut, inOut);
@@ -683,10 +683,10 @@ public class RotationTest {
@Test
public void testApplyInverseTo() {
- Rotation r = new Rotation(new Vector3D(2, -3, 5), 1.7, RotationConvention.VECTOR_OPERATOR);
+ Rotation r = new Rotation(Vector3D.of(2, -3, 5), 1.7, RotationConvention.VECTOR_OPERATOR);
for (double lambda = 0; lambda < 6.2; lambda += 0.2) {
for (double phi = -1.55; phi < 1.55; phi += 0.2) {
- Vector3D u = new Vector3D(Math.cos(lambda) * Math.cos(phi),
+ Vector3D u = Vector3D.of(Math.cos(lambda) * Math.cos(phi),
Math.sin(lambda) * Math.cos(phi),
Math.sin(phi));
r.applyInverseTo(r.applyTo(u));
@@ -698,7 +698,7 @@ public class RotationTest {
r = Rotation.IDENTITY;
for (double lambda = 0; lambda < 6.2; lambda += 0.2) {
for (double phi = -1.55; phi < 1.55; phi += 0.2) {
- Vector3D u = new Vector3D(Math.cos(lambda) * Math.cos(phi),
+ Vector3D u = Vector3D.of(Math.cos(lambda) * Math.cos(phi),
Math.sin(lambda) * Math.cos(phi),
Math.sin(phi));
checkVector(u, r.applyInverseTo(r.applyTo(u)));
@@ -709,7 +709,7 @@ public class RotationTest {
r = new Rotation(Vector3D.PLUS_Z, Math.PI, RotationConvention.VECTOR_OPERATOR);
for (double lambda = 0; lambda < 6.2; lambda += 0.2) {
for (double phi = -1.55; phi < 1.55; phi += 0.2) {
- Vector3D u = new Vector3D(Math.cos(lambda) * Math.cos(phi),
+ Vector3D u = Vector3D.of(Math.cos(lambda) * Math.cos(phi),
Math.sin(lambda) * Math.cos(phi),
Math.sin(phi));
checkVector(u, r.applyInverseTo(r.applyTo(u)));
@@ -721,10 +721,10 @@ public class RotationTest {
@Test
public void testIssue639() {
- Vector3D u1 = new Vector3D(-1321008684645961.0 / 268435456.0,
+ Vector3D u1 = Vector3D.of(-1321008684645961.0 / 268435456.0,
-5774608829631843.0 / 268435456.0,
-3822921525525679.0 / 4294967296.0);
- Vector3D u2 =new Vector3D( -5712344449280879.0 / 2097152.0,
+ Vector3D u2 =Vector3D.of( -5712344449280879.0 / 2097152.0,
-2275058564560979.0 / 1048576.0,
4423475992255071.0 / 65536.0);
Rotation rot = new Rotation(u1, u2, Vector3D.PLUS_X,Vector3D.PLUS_Z);
@@ -736,11 +736,11 @@ public class RotationTest {
@Test
public void testIssue801() {
- Vector3D u1 = new Vector3D(0.9999988431610581, -0.0015210774290851095, 0.0);
- Vector3D u2 = new Vector3D(0.0, 0.0, 1.0);
+ Vector3D u1 = Vector3D.of(0.9999988431610581, -0.0015210774290851095, 0.0);
+ Vector3D u2 = Vector3D.of(0.0, 0.0, 1.0);
- Vector3D v1 = new Vector3D(0.9999999999999999, 0.0, 0.0);
- Vector3D v2 = new Vector3D(0.0, 0.0, -1.0);
+ Vector3D v1 = Vector3D.of(0.9999999999999999, 0.0, 0.0);
+ Vector3D v2 = Vector3D.of(0.0, 0.0, -1.0);
Rotation quat = new Rotation(u1, u2, v1, v2);
double q2 = quat.getQ0() * quat.getQ0() +
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/SubLineTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/SubLineTest.java
index c076b9e..49e31a2 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/SubLineTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/SubLineTest.java
@@ -28,19 +28,19 @@ public class SubLineTest {
@Test
public void testEndPoints() {
- Point3D p1 = new Point3D(-1, -7, 2);
- Point3D p2 = new Point3D(7, -1, 0);
+ Point3D p1 = Point3D.of(-1, -7, 2);
+ Point3D p2 = Point3D.of(7, -1, 0);
Segment segment = new Segment(p1, p2, new Line(p1, p2, 1.0e-10));
SubLine sub = new SubLine(segment);
List<Segment> segments = sub.getSegments();
Assert.assertEquals(1, segments.size());
- Assert.assertEquals(0.0, new Point3D(-1, -7, 2).distance(segments.get(0).getStart()), 1.0e-10);
- Assert.assertEquals(0.0, new Point3D( 7, -1, 0).distance(segments.get(0).getEnd()), 1.0e-10);
+ Assert.assertEquals(0.0, Point3D.of(-1, -7, 2).distance(segments.get(0).getStart()), 1.0e-10);
+ Assert.assertEquals(0.0, Point3D.of( 7, -1, 0).distance(segments.get(0).getEnd()), 1.0e-10);
}
@Test
public void testNoEndPoints() {
- SubLine wholeLine = new Line(new Point3D(-1, 7, 2), new Point3D(7, 1, 0), 1.0e-10).wholeLine();
+ SubLine wholeLine = new Line(Point3D.of(-1, 7, 2), Point3D.of(7, 1, 0), 1.0e-10).wholeLine();
List<Segment> segments = wholeLine.getSegments();
Assert.assertEquals(1, segments.size());
Assert.assertTrue(Double.isInfinite(segments.get(0).getStart().getX()) &&
@@ -59,7 +59,7 @@ public class SubLineTest {
@Test
public void testNoSegments() {
- SubLine empty = new SubLine(new Line(new Point3D(-1, -7, 2), new Point3D(7, -1, 0), 1.0e-10),
+ SubLine empty = new SubLine(new Line(Point3D.of(-1, -7, 2), Point3D.of(7, -1, 0), 1.0e-10),
(IntervalsSet) new RegionFactory<Point1D>().getComplement(new IntervalsSet(1.0e-10)));
List<Segment> segments = empty.getSegments();
Assert.assertEquals(0, segments.size());
@@ -67,7 +67,7 @@ public class SubLineTest {
@Test
public void testSeveralSegments() {
- SubLine twoSubs = new SubLine(new Line(new Point3D(-1, -7, 2), new Point3D(7, -1, 0), 1.0e-10),
+ SubLine twoSubs = new SubLine(new Line(Point3D.of(-1, -7, 2), Point3D.of(7, -1, 0), 1.0e-10),
(IntervalsSet) new RegionFactory<Point1D>().union(new IntervalsSet(1, 2, 1.0e-10),
new IntervalsSet(3, 4, 1.0e-10)));
List<Segment> segments = twoSubs.getSegments();
@@ -76,7 +76,7 @@ public class SubLineTest {
@Test
public void testHalfInfiniteNeg() {
- SubLine empty = new SubLine(new Line(new Point3D(-1, -7, 2), new Point3D(7, -1, -2), 1.0e-10),
+ SubLine empty = new SubLine(new Line(Point3D.of(-1, -7, 2), Point3D.of(7, -1, -2), 1.0e-10),
new IntervalsSet(Double.NEGATIVE_INFINITY, 0.0, 1.0e-10));
List<Segment> segments = empty.getSegments();
Assert.assertEquals(1, segments.size());
@@ -86,16 +86,16 @@ public class SubLineTest {
segments.get(0).getStart().getY() < 0);
Assert.assertTrue(Double.isInfinite(segments.get(0).getStart().getZ()) &&
segments.get(0).getStart().getZ() > 0);
- Assert.assertEquals(0.0, new Point3D(3, -4, 0).distance(segments.get(0).getEnd()), 1.0e-10);
+ Assert.assertEquals(0.0, Point3D.of(3, -4, 0).distance(segments.get(0).getEnd()), 1.0e-10);
}
@Test
public void testHalfInfinitePos() {
- SubLine empty = new SubLine(new Line(new Point3D(-1, -7, 2), new Point3D(7, -1, -2), 1.0e-10),
+ SubLine empty = new SubLine(new Line(Point3D.of(-1, -7, 2), Point3D.of(7, -1, -2), 1.0e-10),
new IntervalsSet(0.0, Double.POSITIVE_INFINITY, 1.0e-10));
List<Segment> segments = empty.getSegments();
Assert.assertEquals(1, segments.size());
- Assert.assertEquals(0.0, new Point3D(3, -4, 0).distance(segments.get(0).getStart()), 1.0e-10);
+ Assert.assertEquals(0.0, Point3D.of(3, -4, 0).distance(segments.get(0).getStart()), 1.0e-10);
Assert.assertTrue(Double.isInfinite(segments.get(0).getEnd().getX()) &&
segments.get(0).getEnd().getX() > 0);
Assert.assertTrue(Double.isInfinite(segments.get(0).getEnd().getY()) &&
@@ -106,56 +106,56 @@ public class SubLineTest {
@Test
public void testIntersectionInsideInside() {
- SubLine sub1 = new SubLine(new Point3D(1, 1, 1), new Point3D(3, 1, 1), 1.0e-10);
- SubLine sub2 = new SubLine(new Point3D(2, 0, 0), new Point3D(2, 2, 2), 1.0e-10);
- Assert.assertEquals(0.0, new Point3D(2, 1, 1).distance(sub1.intersection(sub2, true)), 1.0e-12);
- Assert.assertEquals(0.0, new Point3D(2, 1, 1).distance(sub1.intersection(sub2, false)), 1.0e-12);
+ SubLine sub1 = new SubLine(Point3D.of(1, 1, 1), Point3D.of(3, 1, 1), 1.0e-10);
+ SubLine sub2 = new SubLine(Point3D.of(2, 0, 0), Point3D.of(2, 2, 2), 1.0e-10);
+ Assert.assertEquals(0.0, Point3D.of(2, 1, 1).distance(sub1.intersection(sub2, true)), 1.0e-12);
+ Assert.assertEquals(0.0, Point3D.of(2, 1, 1).distance(sub1.intersection(sub2, false)), 1.0e-12);
}
@Test
public void testIntersectionInsideBoundary() {
- SubLine sub1 = new SubLine(new Point3D(1, 1, 1), new Point3D(3, 1, 1), 1.0e-10);
- SubLine sub2 = new SubLine(new Point3D(2, 0, 0), new Point3D(2, 1, 1), 1.0e-10);
- Assert.assertEquals(0.0, new Point3D(2, 1, 1).distance(sub1.intersection(sub2, true)), 1.0e-12);
+ SubLine sub1 = new SubLine(Point3D.of(1, 1, 1), Point3D.of(3, 1, 1), 1.0e-10);
+ SubLine sub2 = new SubLine(Point3D.of(2, 0, 0), Point3D.of(2, 1, 1), 1.0e-10);
+ Assert.assertEquals(0.0, Point3D.of(2, 1, 1).distance(sub1.intersection(sub2, true)), 1.0e-12);
Assert.assertNull(sub1.intersection(sub2, false));
}
@Test
public void testIntersectionInsideOutside() {
- SubLine sub1 = new SubLine(new Point3D(1, 1, 1), new Point3D(3, 1, 1), 1.0e-10);
- SubLine sub2 = new SubLine(new Point3D(2, 0, 0), new Point3D(2, 0.5, 0.5), 1.0e-10);
+ SubLine sub1 = new SubLine(Point3D.of(1, 1, 1), Point3D.of(3, 1, 1), 1.0e-10);
+ SubLine sub2 = new SubLine(Point3D.of(2, 0, 0), Point3D.of(2, 0.5, 0.5), 1.0e-10);
Assert.assertNull(sub1.intersection(sub2, true));
Assert.assertNull(sub1.intersection(sub2, false));
}
@Test
public void testIntersectionBoundaryBoundary() {
- SubLine sub1 = new SubLine(new Point3D(1, 1, 1), new Point3D(2, 1, 1), 1.0e-10);
- SubLine sub2 = new SubLine(new Point3D(2, 0, 0), new Point3D(2, 1, 1), 1.0e-10);
- Assert.assertEquals(0.0, new Point3D(2, 1, 1).distance(sub1.intersection(sub2, true)), 1.0e-12);
+ SubLine sub1 = new SubLine(Point3D.of(1, 1, 1), Point3D.of(2, 1, 1), 1.0e-10);
+ SubLine sub2 = new SubLine(Point3D.of(2, 0, 0), Point3D.of(2, 1, 1), 1.0e-10);
+ Assert.assertEquals(0.0, Point3D.of(2, 1, 1).distance(sub1.intersection(sub2, true)), 1.0e-12);
Assert.assertNull(sub1.intersection(sub2, false));
}
@Test
public void testIntersectionBoundaryOutside() {
- SubLine sub1 = new SubLine(new Point3D(1, 1, 1), new Point3D(2, 1, 1), 1.0e-10);
- SubLine sub2 = new SubLine(new Point3D(2, 0, 0), new Point3D(2, 0.5, 0.5), 1.0e-10);
+ SubLine sub1 = new SubLine(Point3D.of(1, 1, 1), Point3D.of(2, 1, 1), 1.0e-10);
+ SubLine sub2 = new SubLine(Point3D.of(2, 0, 0), Point3D.of(2, 0.5, 0.5), 1.0e-10);
Assert.assertNull(sub1.intersection(sub2, true));
Assert.assertNull(sub1.intersection(sub2, false));
}
@Test
public void testIntersectionOutsideOutside() {
- SubLine sub1 = new SubLine(new Point3D(1, 1, 1), new Point3D(1.5, 1, 1), 1.0e-10);
- SubLine sub2 = new SubLine(new Point3D(2, 0, 0), new Point3D(2, 0.5, 0.5), 1.0e-10);
+ SubLine sub1 = new SubLine(Point3D.of(1, 1, 1), Point3D.of(1.5, 1, 1), 1.0e-10);
+ SubLine sub2 = new SubLine(Point3D.of(2, 0, 0), Point3D.of(2, 0.5, 0.5), 1.0e-10);
Assert.assertNull(sub1.intersection(sub2, true));
Assert.assertNull(sub1.intersection(sub2, false));
}
@Test
public void testIntersectionNotIntersecting() {
- SubLine sub1 = new SubLine(new Point3D(1, 1, 1), new Point3D(1.5, 1, 1), 1.0e-10);
- SubLine sub2 = new SubLine(new Point3D(2, 3, 0), new Point3D(2, 3, 0.5), 1.0e-10);
+ SubLine sub1 = new SubLine(Point3D.of(1, 1, 1), Point3D.of(1.5, 1, 1), 1.0e-10);
+ SubLine sub2 = new SubLine(Point3D.of(2, 3, 0), Point3D.of(2, 3, 0.5), 1.0e-10);
Assert.assertNull(sub1.intersection(sub2, true));
Assert.assertNull(sub1.intersection(sub2, false));
}
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 60ea0ad..f1bcebf 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
@@ -25,49 +25,49 @@ public class LineTest {
@Test
public void testContains() {
- Line l = new Line(new Point2D(0, 1), new Point2D(1, 2), 1.0e-10);
- Assert.assertTrue(l.contains(new Point2D(0, 1)));
- Assert.assertTrue(l.contains(new Point2D(1, 2)));
- Assert.assertTrue(l.contains(new Point2D(7, 8)));
- Assert.assertTrue(! l.contains(new Point2D(8, 7)));
+ Line l = new Line(Point2D.of(0, 1), Point2D.of(1, 2), 1.0e-10);
+ Assert.assertTrue(l.contains(Point2D.of(0, 1)));
+ Assert.assertTrue(l.contains(Point2D.of(1, 2)));
+ Assert.assertTrue(l.contains(Point2D.of(7, 8)));
+ Assert.assertTrue(! l.contains(Point2D.of(8, 7)));
}
@Test
public void testAbscissa() {
- Line l = new Line(new Point2D(2, 1), new Point2D(-2, -2), 1.0e-10);
+ Line l = new Line(Point2D.of(2, 1), Point2D.of(-2, -2), 1.0e-10);
Assert.assertEquals(0.0,
- (l.toSubSpace(new Point2D(-3, 4))).getX(),
+ (l.toSubSpace(Point2D.of(-3, 4))).getX(),
1.0e-10);
Assert.assertEquals(0.0,
- (l.toSubSpace(new Point2D( 3, -4))).getX(),
+ (l.toSubSpace(Point2D.of( 3, -4))).getX(),
1.0e-10);
Assert.assertEquals(-5.0,
- (l.toSubSpace(new Point2D( 7, -1))).getX(),
+ (l.toSubSpace(Point2D.of( 7, -1))).getX(),
1.0e-10);
Assert.assertEquals(5.0,
- (l.toSubSpace(new Point2D(-1, -7))).getX(),
+ (l.toSubSpace(Point2D.of(-1, -7))).getX(),
1.0e-10);
}
@Test
public void testOffset() {
- Line l = new Line(new Point2D(2, 1), new Point2D(-2, -2), 1.0e-10);
- Assert.assertEquals(-5.0, l.getOffset(new Point2D(5, -3)), 1.0e-10);
- Assert.assertEquals(+5.0, l.getOffset(new Point2D(-5, 2)), 1.0e-10);
+ Line l = new Line(Point2D.of(2, 1), Point2D.of(-2, -2), 1.0e-10);
+ Assert.assertEquals(-5.0, l.getOffset(Point2D.of(5, -3)), 1.0e-10);
+ Assert.assertEquals(+5.0, l.getOffset(Point2D.of(-5, 2)), 1.0e-10);
}
@Test
public void testDistance() {
- Line l = new Line(new Point2D(2, 1), new Point2D(-2, -2), 1.0e-10);
- Assert.assertEquals(+5.0, l.distance(new Point2D(5, -3)), 1.0e-10);
- Assert.assertEquals(+5.0, l.distance(new Point2D(-5, 2)), 1.0e-10);
+ Line l = new Line(Point2D.of(2, 1), Point2D.of(-2, -2), 1.0e-10);
+ Assert.assertEquals(+5.0, l.distance(Point2D.of(5, -3)), 1.0e-10);
+ Assert.assertEquals(+5.0, l.distance(Point2D.of(-5, 2)), 1.0e-10);
}
@Test
public void testPointAt() {
- Line l = new Line(new Point2D(2, 1), new Point2D(-2, -2), 1.0e-10);
+ Line l = new Line(Point2D.of(2, 1), Point2D.of(-2, -2), 1.0e-10);
for (double a = -2.0; a < 2.0; a += 0.2) {
- Point1D pA = new Point1D(a);
+ Point1D pA = Point1D.of(a);
Point2D point = l.toSpace(pA);
Assert.assertEquals(a, (l.toSubSpace(point)).getX(), 1.0e-10);
Assert.assertEquals(0.0, l.getOffset(point), 1.0e-10);
@@ -81,34 +81,34 @@ public class LineTest {
@Test
public void testOriginOffset() {
- Line l1 = new Line(new Point2D(0, 1), new Point2D(1, 2), 1.0e-10);
+ Line l1 = new Line(Point2D.of(0, 1), Point2D.of(1, 2), 1.0e-10);
Assert.assertEquals(Math.sqrt(0.5), l1.getOriginOffset(), 1.0e-10);
- Line l2 = new Line(new Point2D(1, 2), new Point2D(0, 1), 1.0e-10);
+ Line l2 = new Line(Point2D.of(1, 2), Point2D.of(0, 1), 1.0e-10);
Assert.assertEquals(-Math.sqrt(0.5), l2.getOriginOffset(), 1.0e-10);
}
@Test
public void testParallel() {
- Line l1 = new Line(new Point2D(0, 1), new Point2D(1, 2), 1.0e-10);
- Line l2 = new Line(new Point2D(2, 2), new Point2D(3, 3), 1.0e-10);
+ Line l1 = new Line(Point2D.of(0, 1), Point2D.of(1, 2), 1.0e-10);
+ Line l2 = new Line(Point2D.of(2, 2), Point2D.of(3, 3), 1.0e-10);
Assert.assertTrue(l1.isParallelTo(l2));
- Line l3 = new Line(new Point2D(1, 0), new Point2D(0.5, -0.5), 1.0e-10);
+ Line l3 = new Line(Point2D.of(1, 0), Point2D.of(0.5, -0.5), 1.0e-10);
Assert.assertTrue(l1.isParallelTo(l3));
- Line l4 = new Line(new Point2D(1, 0), new Point2D(0.5, -0.51), 1.0e-10);
+ Line l4 = new Line(Point2D.of(1, 0), Point2D.of(0.5, -0.51), 1.0e-10);
Assert.assertTrue(! l1.isParallelTo(l4));
}
@Test
public void testTransform() {
- Line l1 = new Line(new Point2D(1.0 ,1.0), new Point2D(4.0 ,1.0), 1.0e-10);
+ Line l1 = new Line(Point2D.of(1.0 ,1.0), Point2D.of(4.0 ,1.0), 1.0e-10);
Transform<Point2D, Point1D> t1 =
Line.getTransform(0.0, 0.5, -1.0, 0.0, 1.0, 1.5);
Assert.assertEquals(0.5 * Math.PI,
((Line) t1.apply(l1)).getAngle(),
1.0e-10);
- Line l2 = new Line(new Point2D(0.0, 0.0), new Point2D(1.0, 1.0), 1.0e-10);
+ Line l2 = new Line(Point2D.of(0.0, 0.0), Point2D.of(1.0, 1.0), 1.0e-10);
Transform<Point2D, Point1D> t2 =
Line.getTransform(0.0, 0.5, -1.0, 0.0, 1.0, 1.5);
Assert.assertEquals(Math.atan2(1.0, -2.0),
@@ -119,8 +119,8 @@ public class LineTest {
@Test
public void testIntersection() {
- Line l1 = new Line(new Point2D( 0, 1), new Point2D(1, 2), 1.0e-10);
- Line l2 = new Line(new Point2D(-1, 2), new Point2D(2, 1), 1.0e-10);
+ Line l1 = new Line(Point2D.of( 0, 1), Point2D.of(1, 2), 1.0e-10);
+ Line l2 = new Line(Point2D.of(-1, 2), Point2D.of(2, 1), 1.0e-10);
Point2D p = l1.intersection(l2);
Assert.assertEquals(0.5, p.getX(), 1.0e-10);
Assert.assertEquals(1.5, p.getY(), 1.0e-10);
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/NestedLoopsTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/NestedLoopsTest.java
index 26cec45..8521c9f 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/NestedLoopsTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/NestedLoopsTest.java
@@ -31,11 +31,11 @@ public class NestedLoopsTest {
@SuppressWarnings("unchecked")
@Test
public void testNestedLoops() throws Exception {
- Point2D oneOne = new Point2D(1.0, 1.0);
- Point2D oneNegativeOne = new Point2D(1.0, -1.0);
- Point2D negativeOneNegativeOne = new Point2D(-1.0, -1.0);
- Point2D negativeOneOne = new Point2D(-1.0, 1.0);
- Point2D origin = new Point2D(0, 0);
+ Point2D oneOne = Point2D.of(1.0, 1.0);
+ Point2D oneNegativeOne = Point2D.of(1.0, -1.0);
+ Point2D negativeOneNegativeOne = Point2D.of(-1.0, -1.0);
+ Point2D negativeOneOne = Point2D.of(-1.0, 1.0);
+ Point2D origin = Point2D.of(0, 0);
Point2D [] vertices = new Point2D[]{
oneOne,
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/PolygonsSetTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/PolygonsSetTest.java
index f565ea6..55eaa86 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/PolygonsSetTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/PolygonsSetTest.java
@@ -55,13 +55,13 @@ public class PolygonsSetTest {
EuclideanTestUtils.assertCoordinatesEqual(Point2D.NaN, poly.getBarycenter(), TEST_TOLERANCE);
checkPoints(Region.Location.INSIDE, poly,
- new Point2D(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY),
+ Point2D.of(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY),
Point2D.ZERO,
- new Point2D(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY));
+ Point2D.of(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY));
for (double y = -1; y < 1; y += 0.1) {
for (double x = -1; x < 1; x += 0.1) {
- EuclideanTestUtils.assertNegativeInfinity(poly.projectToBoundary(new Point2D(x, y)).getOffset());
+ EuclideanTestUtils.assertNegativeInfinity(poly.projectToBoundary(Point2D.of(x, y)).getOffset());
}
}
}
@@ -81,14 +81,14 @@ public class PolygonsSetTest {
EuclideanTestUtils.assertCoordinatesEqual(Point2D.NaN, poly.getBarycenter(), TEST_TOLERANCE);
checkPoints(Region.Location.OUTSIDE, poly,
- new Point2D(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY),
+ Point2D.of(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY),
Point2D.ZERO,
- new Point2D(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY));
+ Point2D.of(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY));
for (double y = -1; y < 1; y += 0.1) {
for (double x = -1; x < 1; x += 0.1) {
- EuclideanTestUtils.assertPositiveInfinity(poly.projectToBoundary(new Point2D(x, y)).getOffset());
+ EuclideanTestUtils.assertPositiveInfinity(poly.projectToBoundary(Point2D.of(x, y)).getOffset());
}
}
}
@@ -96,7 +96,7 @@ public class PolygonsSetTest {
@Test
public void testInfiniteLines_single() {
// arrange
- Line line = new Line(new Point2D(0, 0), new Point2D(1, 1), TEST_TOLERANCE);
+ Line line = new Line(Point2D.of(0, 0), Point2D.of(1, 1), TEST_TOLERANCE);
List<SubHyperplane<Point2D>> boundaries = new ArrayList<SubHyperplane<Point2D>>();
boundaries.add(line.wholeHyperplane());
@@ -115,25 +115,25 @@ public class PolygonsSetTest {
checkVertexLoopsEquivalent(new Point2D[][] {
{
null,
- line.toSpace(new Point1D(-Float.MAX_VALUE)),
- line.toSpace(new Point1D(Float.MAX_VALUE))
+ line.toSpace(Point1D.of(-Float.MAX_VALUE)),
+ line.toSpace(Point1D.of(Float.MAX_VALUE))
}
}, poly.getVertices());
checkPoints(Region.Location.OUTSIDE, poly,
- new Point2D(1, -1),
- new Point2D(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY));
+ Point2D.of(1, -1),
+ Point2D.of(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY));
checkPoints(Region.Location.INSIDE, poly,
- new Point2D(-1, 1),
- new Point2D(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY));
+ Point2D.of(-1, 1),
+ Point2D.of(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY));
checkPoints(Region.Location.BOUNDARY, poly, Point2D.ZERO);
}
@Test
public void testInfiniteLines_twoIntersecting() {
// arrange
- Line line1 = new Line(new Point2D(0, 0), new Point2D(1, 1), TEST_TOLERANCE);
- Line line2 = new Line(new Point2D(1, -1), new Point2D(0, 0), TEST_TOLERANCE);
+ Line line1 = new Line(Point2D.of(0, 0), Point2D.of(1, 1), TEST_TOLERANCE);
+ Line line2 = new Line(Point2D.of(1, -1), Point2D.of(0, 0), TEST_TOLERANCE);
List<SubHyperplane<Point2D>> boundaries = new ArrayList<SubHyperplane<Point2D>>();
boundaries.add(line1.wholeHyperplane());
@@ -153,25 +153,25 @@ public class PolygonsSetTest {
checkVertexLoopsEquivalent(new Point2D[][] {
{
null,
- line2.toSpace(new Point1D(-Float.MAX_VALUE)),
- line2.toSpace(new Point1D(Float.MAX_VALUE))
+ line2.toSpace(Point1D.of(-Float.MAX_VALUE)),
+ line2.toSpace(Point1D.of(Float.MAX_VALUE))
}
}, poly.getVertices());
checkPoints(Region.Location.INSIDE, poly,
- new Point2D(-1, 0),
- new Point2D(-Float.MAX_VALUE, Float.MAX_VALUE / 2.0));
+ Point2D.of(-1, 0),
+ Point2D.of(-Float.MAX_VALUE, Float.MAX_VALUE / 2.0));
checkPoints(Region.Location.OUTSIDE, poly,
- new Point2D(1, 0),
- new Point2D(Float.MAX_VALUE, Float.MAX_VALUE / 2.0));
+ Point2D.of(1, 0),
+ Point2D.of(Float.MAX_VALUE, Float.MAX_VALUE / 2.0));
checkPoints(Region.Location.BOUNDARY, poly, Point2D.ZERO);
}
@Test
public void testInfiniteLines_twoParallel_facingIn() {
// arrange
- Line line1 = new Line(new Point2D(1, 1), new Point2D(0, 1), TEST_TOLERANCE);
- Line line2 = new Line(new Point2D(0, -1), new Point2D(1, -1), TEST_TOLERANCE);
+ Line line1 = new Line(Point2D.of(1, 1), Point2D.of(0, 1), TEST_TOLERANCE);
+ Line line2 = new Line(Point2D.of(0, -1), Point2D.of(1, -1), TEST_TOLERANCE);
List<SubHyperplane<Point2D>> boundaries = new ArrayList<SubHyperplane<Point2D>>();
boundaries.add(line1.wholeHyperplane());
@@ -191,33 +191,33 @@ public class PolygonsSetTest {
checkVertexLoopsEquivalent(new Point2D[][] {
{
null,
- line1.toSpace(new Point1D(-Float.MAX_VALUE)),
- line1.toSpace(new Point1D(Float.MAX_VALUE))
+ line1.toSpace(Point1D.of(-Float.MAX_VALUE)),
+ line1.toSpace(Point1D.of(Float.MAX_VALUE))
},
{
null,
- line2.toSpace(new Point1D(-Float.MAX_VALUE)),
- line2.toSpace(new Point1D(Float.MAX_VALUE))
+ line2.toSpace(Point1D.of(-Float.MAX_VALUE)),
+ line2.toSpace(Point1D.of(Float.MAX_VALUE))
}
}, poly.getVertices());
checkPoints(Region.Location.INSIDE, poly,
- new Point2D(0, 0),
- new Point2D(0, 0.9),
- new Point2D(0, -0.9));
+ Point2D.of(0, 0),
+ Point2D.of(0, 0.9),
+ Point2D.of(0, -0.9));
checkPoints(Region.Location.OUTSIDE, poly,
- new Point2D(0, 1.1),
- new Point2D(0, -1.1));
+ Point2D.of(0, 1.1),
+ Point2D.of(0, -1.1));
checkPoints(Region.Location.BOUNDARY, poly,
- new Point2D(0, 1),
- new Point2D(0, -1));
+ Point2D.of(0, 1),
+ Point2D.of(0, -1));
}
@Test
public void testInfiniteLines_twoParallel_facingOut() {
// arrange
- Line line1 = new Line(new Point2D(0, 1), new Point2D(1, 1), TEST_TOLERANCE);
- Line line2 = new Line(new Point2D(1, -1), new Point2D(0, -1), TEST_TOLERANCE);
+ Line line1 = new Line(Point2D.of(0, 1), Point2D.of(1, 1), TEST_TOLERANCE);
+ Line line2 = new Line(Point2D.of(1, -1), Point2D.of(0, -1), TEST_TOLERANCE);
List<SubHyperplane<Point2D>> boundaries = new ArrayList<SubHyperplane<Point2D>>();
boundaries.add(line1.wholeHyperplane());
@@ -237,38 +237,38 @@ public class PolygonsSetTest {
checkVertexLoopsEquivalent(new Point2D[][] {
{
null,
- line1.toSpace(new Point1D(-Float.MAX_VALUE)),
- line1.toSpace(new Point1D(Float.MAX_VALUE))
+ line1.toSpace(Point1D.of(-Float.MAX_VALUE)),
+ line1.toSpace(Point1D.of(Float.MAX_VALUE))
},
{
null,
- line2.toSpace(new Point1D(-Float.MAX_VALUE)),
- line2.toSpace(new Point1D(Float.MAX_VALUE))
+ line2.toSpace(Point1D.of(-Float.MAX_VALUE)),
+ line2.toSpace(Point1D.of(Float.MAX_VALUE))
}
}, poly.getVertices());
checkPoints(Region.Location.OUTSIDE, poly,
- new Point2D(0, 0),
- new Point2D(0, 0.9),
- new Point2D(0, -0.9));
+ Point2D.of(0, 0),
+ Point2D.of(0, 0.9),
+ Point2D.of(0, -0.9));
checkPoints(Region.Location.INSIDE, poly,
- new Point2D(0, 1.1),
- new Point2D(0, -1.1));
+ Point2D.of(0, 1.1),
+ Point2D.of(0, -1.1));
checkPoints(Region.Location.BOUNDARY, poly,
- new Point2D(0, 1),
- new Point2D(0, -1));
+ Point2D.of(0, 1),
+ Point2D.of(0, -1));
}
@Test
public void testMixedFiniteAndInfiniteLines_explicitInfiniteBoundaries() {
// arrange
- Line line1 = new Line(new Point2D(3, 3), new Point2D(0, 3), TEST_TOLERANCE);
- Line line2 = new Line(new Point2D(0, -3), new Point2D(3, -3), TEST_TOLERANCE);
+ Line line1 = new Line(Point2D.of(3, 3), Point2D.of(0, 3), TEST_TOLERANCE);
+ Line line2 = new Line(Point2D.of(0, -3), Point2D.of(3, -3), TEST_TOLERANCE);
List<SubHyperplane<Point2D>> boundaries = new ArrayList<SubHyperplane<Point2D>>();
boundaries.add(line1.wholeHyperplane());
boundaries.add(line2.wholeHyperplane());
- boundaries.add(buildSegment(new Point2D(0, 3), new Point2D(0, -3)));
+ boundaries.add(buildSegment(Point2D.of(0, 3), Point2D.of(0, -3)));
// act
PolygonsSet poly = new PolygonsSet(boundaries, TEST_TOLERANCE);
@@ -284,25 +284,25 @@ public class PolygonsSetTest {
checkVertexLoopsEquivalent(new Point2D[][] {
{
null,
- new Point2D(1, 3), // dummy point
- new Point2D(0, 3),
- new Point2D(0, -3),
- new Point2D(1, -3) // dummy point
+ Point2D.of(1, 3), // dummy point
+ Point2D.of(0, 3),
+ Point2D.of(0, -3),
+ Point2D.of(1, -3) // dummy point
}
}, poly.getVertices());
checkPoints(Region.Location.INSIDE, poly,
- new Point2D(0.1, 2.9),
- new Point2D(0.1, 0),
- new Point2D(0.1, -2.9));
+ Point2D.of(0.1, 2.9),
+ Point2D.of(0.1, 0),
+ Point2D.of(0.1, -2.9));
checkPoints(Region.Location.OUTSIDE, poly,
- new Point2D(0, 3.1),
- new Point2D(-0.5, 0),
- new Point2D(0, -3.1));
+ Point2D.of(0, 3.1),
+ Point2D.of(-0.5, 0),
+ Point2D.of(0, -3.1));
checkPoints(Region.Location.BOUNDARY, poly,
- new Point2D(3, 3),
- new Point2D(0, 0),
- new Point2D(3, -3));
+ Point2D.of(3, 3),
+ Point2D.of(0, 0),
+ Point2D.of(3, -3));
}
// The polygon in this test is created from finite boundaries but the generated
@@ -313,11 +313,11 @@ public class PolygonsSetTest {
@Test
public void testMixedFiniteAndInfiniteLines_impliedInfiniteBoundaries() {
// arrange
- Line line = new Line(new Point2D(3, 0), new Point2D(3, 3), TEST_TOLERANCE);
+ Line line = new Line(Point2D.of(3, 0), Point2D.of(3, 3), TEST_TOLERANCE);
List<SubHyperplane<Point2D>> boundaries = new ArrayList<SubHyperplane<Point2D>>();
- boundaries.add(buildSegment(new Point2D(0, 3), new Point2D(0, 0)));
- boundaries.add(buildSegment(new Point2D(0, 0), new Point2D(3, 0)));
+ boundaries.add(buildSegment(Point2D.of(0, 3), Point2D.of(0, 0)));
+ boundaries.add(buildSegment(Point2D.of(0, 0), Point2D.of(3, 0)));
boundaries.add(new SubLine(line, new IntervalsSet(0, Double.POSITIVE_INFINITY, TEST_TOLERANCE)));
// act
@@ -334,29 +334,29 @@ public class PolygonsSetTest {
checkVertexLoopsEquivalent(new Point2D[][] {
{
null,
- new Point2D(0, 1), // dummy point
- new Point2D(0, 0),
- new Point2D(3, 0),
- new Point2D(3, 1) // dummy point
+ Point2D.of(0, 1), // dummy point
+ Point2D.of(0, 0),
+ Point2D.of(3, 0),
+ Point2D.of(3, 1) // dummy point
}
}, poly.getVertices());
checkPoints(Region.Location.INSIDE, poly,
- new Point2D(0.1, Float.MAX_VALUE),
- new Point2D(0.1, 0.1),
- new Point2D(1.5, 0.1),
- new Point2D(2.9, 0.1),
- new Point2D(2.9, Float.MAX_VALUE));
+ Point2D.of(0.1, Float.MAX_VALUE),
+ Point2D.of(0.1, 0.1),
+ Point2D.of(1.5, 0.1),
+ Point2D.of(2.9, 0.1),
+ Point2D.of(2.9, Float.MAX_VALUE));
checkPoints(Region.Location.OUTSIDE, poly,
- new Point2D(-0.1, Float.MAX_VALUE),
- new Point2D(-0.1, 0.1),
- new Point2D(1.5, -0.1),
- new Point2D(3.1, 0.1),
- new Point2D(3.1, Float.MAX_VALUE));
+ Point2D.of(-0.1, Float.MAX_VALUE),
+ Point2D.of(-0.1, 0.1),
+ Point2D.of(1.5, -0.1),
+ Point2D.of(3.1, 0.1),
+ Point2D.of(3.1, Float.MAX_VALUE));
checkPoints(Region.Location.BOUNDARY, poly,
- new Point2D(0, 1),
- new Point2D(1, 0),
- new Point2D(3, 1));
+ Point2D.of(0, 1),
+ Point2D.of(1, 0),
+ Point2D.of(3, 1));
}
@Test
@@ -369,42 +369,42 @@ public class PolygonsSetTest {
Assert.assertEquals(8.0, box.getBoundarySize(), TEST_TOLERANCE);
Assert.assertFalse(box.isEmpty());
Assert.assertFalse(box.isFull());
- EuclideanTestUtils.assertCoordinatesEqual(new Point2D(1, 0), box.getBarycenter(), TEST_TOLERANCE);
+ EuclideanTestUtils.assertCoordinatesEqual(Point2D.of(1, 0), box.getBarycenter(), TEST_TOLERANCE);
checkVertexLoopsEquivalent(new Point2D[][] {
{
- new Point2D(2, -1),
- new Point2D(2, 1),
- new Point2D(0, 1),
- new Point2D(0, -1)
+ Point2D.of(2, -1),
+ Point2D.of(2, 1),
+ Point2D.of(0, 1),
+ Point2D.of(0, -1)
}
}, box.getVertices());
checkPoints(Region.Location.INSIDE, box,
- new Point2D(0.1, 0),
- new Point2D(1.9, 0),
- new Point2D(1, 0.9),
- new Point2D(1, -0.9));
+ Point2D.of(0.1, 0),
+ Point2D.of(1.9, 0),
+ Point2D.of(1, 0.9),
+ Point2D.of(1, -0.9));
checkPoints(Region.Location.OUTSIDE, box,
- new Point2D(-0.1, 0),
- new Point2D(2.1, 0),
- new Point2D(1, -1.1),
- new Point2D(1, 1.1));
+ Point2D.of(-0.1, 0),
+ Point2D.of(2.1, 0),
+ Point2D.of(1, -1.1),
+ Point2D.of(1, 1.1));
checkPoints(Region.Location.BOUNDARY, box,
- new Point2D(0, 0),
- new Point2D(2, 0),
- new Point2D(1, 1),
- new Point2D(1, -1));
+ Point2D.of(0, 0),
+ Point2D.of(2, 0),
+ Point2D.of(1, 1),
+ Point2D.of(1, -1));
}
@Test
public void testInvertedBox() {
// arrange
List<SubHyperplane<Point2D>> boundaries = new ArrayList<SubHyperplane<Point2D>>();
- boundaries.add(buildSegment(new Point2D(0, -1), new Point2D(0, 1)));
- boundaries.add(buildSegment(new Point2D(2, 1), new Point2D(2, -1)));
- boundaries.add(buildSegment(new Point2D(0, 1), new Point2D(2, 1)));
- boundaries.add(buildSegment(new Point2D(2, -1), new Point2D(0, -1)));
+ boundaries.add(buildSegment(Point2D.of(0, -1), Point2D.of(0, 1)));
+ boundaries.add(buildSegment(Point2D.of(2, 1), Point2D.of(2, -1)));
+ boundaries.add(buildSegment(Point2D.of(0, 1), Point2D.of(2, 1)));
+ boundaries.add(buildSegment(Point2D.of(2, -1), Point2D.of(0, -1)));
// act
PolygonsSet box = new PolygonsSet(boundaries, TEST_TOLERANCE);
@@ -418,28 +418,28 @@ public class PolygonsSetTest {
checkVertexLoopsEquivalent(new Point2D[][] {
{
- new Point2D(0, -1),
- new Point2D(0, 1),
- new Point2D(2, 1),
- new Point2D(2, -1)
+ Point2D.of(0, -1),
+ Point2D.of(0, 1),
+ Point2D.of(2, 1),
+ Point2D.of(2, -1)
}
}, box.getVertices());
checkPoints(Region.Location.OUTSIDE, box,
- new Point2D(0.1, 0),
- new Point2D(1.9, 0),
- new Point2D(1, 0.9),
- new Point2D(1, -0.9));
+ Point2D.of(0.1, 0),
+ Point2D.of(1.9, 0),
+ Point2D.of(1, 0.9),
+ Point2D.of(1, -0.9));
checkPoints(Region.Location.INSIDE, box,
- new Point2D(-0.1, 0),
- new Point2D(2.1, 0),
- new Point2D(1, -1.1),
- new Point2D(1, 1.1));
+ Point2D.of(-0.1, 0),
+ Point2D.of(2.1, 0),
+ Point2D.of(1, -1.1),
+ Point2D.of(1, 1.1));
checkPoints(Region.Location.BOUNDARY, box,
- new Point2D(0, 0),
- new Point2D(2, 0),
- new Point2D(1, 1),
- new Point2D(1, -1));
+ Point2D.of(0, 0),
+ Point2D.of(2, 0),
+ Point2D.of(1, 1),
+ Point2D.of(1, -1));
}
@Test
@@ -447,16 +447,16 @@ public class PolygonsSetTest {
// arrange
Point2D[][] vertices = new Point2D[][] {
new Point2D[] {
- new Point2D(36.0, 22.0),
- new Point2D(39.0, 32.0),
- new Point2D(19.0, 32.0),
- new Point2D( 6.0, 16.0),
- new Point2D(31.0, 10.0),
- new Point2D(42.0, 16.0),
- new Point2D(34.0, 20.0),
- new Point2D(29.0, 19.0),
- new Point2D(23.0, 22.0),
- new Point2D(33.0, 25.0)
+ Point2D.of(36.0, 22.0),
+ Point2D.of(39.0, 32.0),
+ Point2D.of(19.0, 32.0),
+ Point2D.of( 6.0, 16.0),
+ Point2D.of(31.0, 10.0),
+ Point2D.of(42.0, 16.0),
+ Point2D.of(34.0, 20.0),
+ Point2D.of(29.0, 19.0),
+ Point2D.of(23.0, 22.0),
+ Point2D.of(33.0, 25.0)
}
};
@@ -465,22 +465,22 @@ public class PolygonsSetTest {
// assert
checkPoints(Region.Location.INSIDE, set,
- new Point2D(30.0, 15.0),
- new Point2D(15.0, 20.0),
- new Point2D(24.0, 25.0),
- new Point2D(35.0, 30.0),
- new Point2D(19.0, 17.0));
+ Point2D.of(30.0, 15.0),
+ Point2D.of(15.0, 20.0),
+ Point2D.of(24.0, 25.0),
+ Point2D.of(35.0, 30.0),
+ Point2D.of(19.0, 17.0));
checkPoints(Region.Location.OUTSIDE, set,
- new Point2D(50.0, 30.0),
- new Point2D(30.0, 35.0),
- new Point2D(10.0, 25.0),
- new Point2D(10.0, 10.0),
- new Point2D(40.0, 10.0),
- new Point2D(50.0, 15.0),
- new Point2D(30.0, 22.0));
+ Point2D.of(50.0, 30.0),
+ Point2D.of(30.0, 35.0),
+ Point2D.of(10.0, 25.0),
+ Point2D.of(10.0, 10.0),
+ Point2D.of(40.0, 10.0),
+ Point2D.of(50.0, 15.0),
+ Point2D.of(30.0, 22.0));
checkPoints(Region.Location.BOUNDARY, set,
- new Point2D(30.0, 32.0),
- new Point2D(34.0, 20.0));
+ Point2D.of(30.0, 32.0),
+ Point2D.of(34.0, 20.0));
checkVertexLoopsEquivalent(vertices, set.getVertices());
}
@@ -490,16 +490,16 @@ public class PolygonsSetTest {
// arrange
Point2D[][] vertices = new Point2D[][] {
new Point2D[] {
- new Point2D( 0.0, 0.0),
- new Point2D( 0.0, 2.0),
- new Point2D(-0.1, 2.0),
- new Point2D(-0.1, 1.0),
- new Point2D(-0.3, 1.0),
- new Point2D(-0.3, 1.5),
- new Point2D(-1.3, 1.5),
- new Point2D(-1.3, 2.0),
- new Point2D(-1.8, 2.0),
- new Point2D(-1.8 - 1.0 / Math.sqrt(2.0),
+ Point2D.of( 0.0, 0.0),
+ Point2D.of( 0.0, 2.0),
+ Point2D.of(-0.1, 2.0),
+ Point2D.of(-0.1, 1.0),
+ Point2D.of(-0.3, 1.0),
+ Point2D.of(-0.3, 1.5),
+ Point2D.of(-1.3, 1.5),
+ Point2D.of(-1.3, 2.0),
+ Point2D.of(-1.8, 2.0),
+ Point2D.of(-1.8 - 1.0 / Math.sqrt(2.0),
2.0 - 1.0 / Math.sqrt(2.0))
}
};
@@ -518,15 +518,15 @@ public class PolygonsSetTest {
// arrange
Point2D[][] vertices = new Point2D[][] {
new Point2D[] {
- new Point2D(0.0, 0.0),
- new Point2D(3.0, 0.0),
- new Point2D(3.0, 3.0),
- new Point2D(0.0, 3.0)
+ Point2D.of(0.0, 0.0),
+ Point2D.of(3.0, 0.0),
+ Point2D.of(3.0, 3.0),
+ Point2D.of(0.0, 3.0)
}, new Point2D[] {
- new Point2D(1.0, 2.0),
- new Point2D(2.0, 2.0),
- new Point2D(2.0, 1.0),
- new Point2D(1.0, 1.0)
+ Point2D.of(1.0, 2.0),
+ Point2D.of(2.0, 2.0),
+ Point2D.of(2.0, 1.0),
+ Point2D.of(1.0, 1.0)
}
};
@@ -535,34 +535,34 @@ public class PolygonsSetTest {
// assert
checkPoints(Region.Location.INSIDE, set, new Point2D[] {
- new Point2D(0.5, 0.5),
- new Point2D(1.5, 0.5),
- new Point2D(2.5, 0.5),
- new Point2D(0.5, 1.5),
- new Point2D(2.5, 1.5),
- new Point2D(0.5, 2.5),
- new Point2D(1.5, 2.5),
- new Point2D(2.5, 2.5),
- new Point2D(0.5, 1.0)
+ Point2D.of(0.5, 0.5),
+ Point2D.of(1.5, 0.5),
+ Point2D.of(2.5, 0.5),
+ Point2D.of(0.5, 1.5),
+ Point2D.of(2.5, 1.5),
+ Point2D.of(0.5, 2.5),
+ Point2D.of(1.5, 2.5),
+ Point2D.of(2.5, 2.5),
+ Point2D.of(0.5, 1.0)
});
checkPoints(Region.Location.OUTSIDE, set, new Point2D[] {
- new Point2D(1.5, 1.5),
- new Point2D(3.5, 1.0),
- new Point2D(4.0, 1.5),
- new Point2D(6.0, 6.0)
+ Point2D.of(1.5, 1.5),
+ Point2D.of(3.5, 1.0),
+ Point2D.of(4.0, 1.5),
+ Point2D.of(6.0, 6.0)
});
checkPoints(Region.Location.BOUNDARY, set, new Point2D[] {
- new Point2D(1.0, 1.0),
- new Point2D(1.5, 0.0),
- new Point2D(1.5, 1.0),
- new Point2D(1.5, 2.0),
- new Point2D(1.5, 3.0),
- new Point2D(3.0, 3.0)
+ Point2D.of(1.0, 1.0),
+ Point2D.of(1.5, 0.0),
+ Point2D.of(1.5, 1.0),
+ Point2D.of(1.5, 2.0),
+ Point2D.of(1.5, 3.0),
+ Point2D.of(3.0, 3.0)
});
checkVertexLoopsEquivalent(vertices, set.getVertices());
for (double x = -0.999; x < 3.999; x += 0.11) {
- Point2D v = new Point2D(x, x + 0.5);
+ Point2D v = Point2D.of(x, x + 0.5);
BoundaryProjection<Point2D> projection = set.projectToBoundary(v);
Assert.assertTrue(projection.getOriginal() == v);
Point2D p = projection.getProjected();
@@ -589,7 +589,7 @@ public class PolygonsSetTest {
} else {
Assert.assertEquals(3.0, p.getX(), TEST_TOLERANCE);
Assert.assertEquals(3.0, p.getY(), TEST_TOLERANCE);
- Assert.assertEquals(+v.distance(new Point2D(3, 3)), projection.getOffset(), TEST_TOLERANCE);
+ Assert.assertEquals(+v.distance(Point2D.of(3, 3)), projection.getOffset(), TEST_TOLERANCE);
}
}
}
@@ -599,13 +599,13 @@ public class PolygonsSetTest {
// arrange
Point2D[][] vertices = new Point2D[][] {
new Point2D[] {
- new Point2D(0.0, 1.0),
- new Point2D(2.0, 1.0),
- new Point2D(1.0, 2.0)
+ Point2D.of(0.0, 1.0),
+ Point2D.of(2.0, 1.0),
+ Point2D.of(1.0, 2.0)
}, new Point2D[] {
- new Point2D(4.0, 0.0),
- new Point2D(5.0, 1.0),
- new Point2D(3.0, 1.0)
+ Point2D.of(4.0, 0.0),
+ Point2D.of(5.0, 1.0),
+ Point2D.of(3.0, 1.0)
}
};
@@ -613,21 +613,21 @@ public class PolygonsSetTest {
PolygonsSet set = buildSet(vertices);
// assert
- Assert.assertEquals(Region.Location.INSIDE, set.checkPoint(new Point2D(1.0, 1.5)));
+ Assert.assertEquals(Region.Location.INSIDE, set.checkPoint(Point2D.of(1.0, 1.5)));
checkPoints(Region.Location.INSIDE, set, new Point2D[] {
- new Point2D(1.0, 1.5),
- new Point2D(4.5, 0.8)
+ Point2D.of(1.0, 1.5),
+ Point2D.of(4.5, 0.8)
});
checkPoints(Region.Location.OUTSIDE, set, new Point2D[] {
- new Point2D(1.0, 0.0),
- new Point2D(3.5, 1.2),
- new Point2D(2.5, 1.0),
- new Point2D(3.0, 4.0)
+ Point2D.of(1.0, 0.0),
+ Point2D.of(3.5, 1.2),
+ Point2D.of(2.5, 1.0),
+ Point2D.of(3.0, 4.0)
});
checkPoints(Region.Location.BOUNDARY, set, new Point2D[] {
- new Point2D(1.0, 1.0),
- new Point2D(3.5, 0.5),
- new Point2D(0.0, 1.0)
+ Point2D.of(1.0, 1.0),
+ Point2D.of(3.5, 0.5),
+ Point2D.of(0.0, 1.0)
});
checkVertexLoopsEquivalent(vertices, set.getVertices());
}
@@ -637,12 +637,12 @@ public class PolygonsSetTest {
// arrange
Point2D[][] vertices = new Point2D[][] {
new Point2D[] {
- new Point2D(1.0, 0.0),
- new Point2D(2.0, 1.0),
- new Point2D(3.0, 1.0),
- new Point2D(2.0, 2.0),
- new Point2D(1.0, 1.0),
- new Point2D(0.0, 1.0)
+ Point2D.of(1.0, 0.0),
+ Point2D.of(2.0, 1.0),
+ Point2D.of(3.0, 1.0),
+ Point2D.of(2.0, 2.0),
+ Point2D.of(1.0, 1.0),
+ Point2D.of(0.0, 1.0)
}
};
@@ -658,14 +658,14 @@ public class PolygonsSetTest {
// arrange
Point2D[][] vertices = new Point2D[][] {
new Point2D[] {
- new Point2D( 0.0, 0.0),
- new Point2D( 1.0, 0.0),
- new Point2D( 1.0, 1.0),
- new Point2D( 0.0, 1.0),
- new Point2D( 0.0, 0.0),
- new Point2D(-1.0, 0.0),
- new Point2D(-1.0, -1.0),
- new Point2D( 0.0, -1.0)
+ Point2D.of( 0.0, 0.0),
+ Point2D.of( 1.0, 0.0),
+ Point2D.of( 1.0, 1.0),
+ Point2D.of( 0.0, 1.0),
+ Point2D.of( 0.0, 0.0),
+ Point2D.of(-1.0, 0.0),
+ Point2D.of(-1.0, -1.0),
+ Point2D.of( 0.0, -1.0)
}
};
@@ -675,16 +675,16 @@ public class PolygonsSetTest {
// assert
checkVertexLoopsEquivalent(new Point2D[][] {
{
- new Point2D( 0.0, 0.0),
- new Point2D( 1.0, 0.0),
- new Point2D( 1.0, 1.0),
- new Point2D( 0.0, 1.0)
+ Point2D.of( 0.0, 0.0),
+ Point2D.of( 1.0, 0.0),
+ Point2D.of( 1.0, 1.0),
+ Point2D.of( 0.0, 1.0)
},
{
- new Point2D( 0.0, 0.0),
- new Point2D(-1.0, 0.0),
- new Point2D(-1.0, -1.0),
- new Point2D( 0.0, -1.0)
+ Point2D.of( 0.0, 0.0),
+ Point2D.of(-1.0, 0.0),
+ Point2D.of(-1.0, -1.0),
+ Point2D.of( 0.0, -1.0)
}
}, set.getVertices());
}
@@ -694,14 +694,14 @@ public class PolygonsSetTest {
// arrange
Point2D[][] vertices = new Point2D[][] {
new Point2D[] {
- new Point2D( 0.0, 0.0),
- new Point2D( 2.0, 0.0),
- new Point2D( 2.0, 1.0),
- new Point2D( 3.0, 1.0),
- new Point2D( 3.0, 3.0),
- new Point2D( 1.0, 3.0),
- new Point2D( 1.0, 2.0),
- new Point2D( 0.0, 2.0)
+ Point2D.of( 0.0, 0.0),
+ Point2D.of( 2.0, 0.0),
+ Point2D.of( 2.0, 1.0),
+ Point2D.of( 3.0, 1.0),
+ Point2D.of( 3.0, 3.0),
+ Point2D.of( 1.0, 3.0),
+ Point2D.of( 1.0, 2.0),
+ Point2D.of( 0.0, 2.0)
}
};
@@ -709,34 +709,34 @@ public class PolygonsSetTest {
PolygonsSet set = buildSet(vertices);
// assert
- Line l1 = new Line(new Point2D(-1.5, 0.0), Math.PI / 4, TEST_TOLERANCE);
+ Line l1 = new Line(Point2D.of(-1.5, 0.0), Math.PI / 4, TEST_TOLERANCE);
SubLine s1 = (SubLine) set.intersection(l1.wholeHyperplane());
List<Interval> i1 = ((IntervalsSet) s1.getRemainingRegion()).asList();
Assert.assertEquals(2, i1.size());
Interval v10 = i1.get(0);
- Point2D p10Lower = l1.toSpace(new Point1D(v10.getInf()));
+ Point2D p10Lower = l1.toSpace(Point1D.of(v10.getInf()));
Assert.assertEquals(0.0, p10Lower.getX(), TEST_TOLERANCE);
Assert.assertEquals(1.5, p10Lower.getY(), TEST_TOLERANCE);
- Point2D p10Upper = l1.toSpace(new Point1D(v10.getSup()));
+ Point2D p10Upper = l1.toSpace(Point1D.of(v10.getSup()));
Assert.assertEquals(0.5, p10Upper.getX(), TEST_TOLERANCE);
Assert.assertEquals(2.0, p10Upper.getY(), TEST_TOLERANCE);
Interval v11 = i1.get(1);
- Point2D p11Lower = l1.toSpace(new Point1D(v11.getInf()));
+ Point2D p11Lower = l1.toSpace(Point1D.of(v11.getInf()));
Assert.assertEquals(1.0, p11Lower.getX(), TEST_TOLERANCE);
Assert.assertEquals(2.5, p11Lower.getY(), TEST_TOLERANCE);
- Point2D p11Upper = l1.toSpace(new Point1D(v11.getSup()));
+ Point2D p11Upper = l1.toSpace(Point1D.of(v11.getSup()));
Assert.assertEquals(1.5, p11Upper.getX(), TEST_TOLERANCE);
Assert.assertEquals(3.0, p11Upper.getY(), TEST_TOLERANCE);
- Line l2 = new Line(new Point2D(-1.0, 2.0), 0, TEST_TOLERANCE);
+ Line l2 = new Line(Point2D.of(-1.0, 2.0), 0, TEST_TOLERANCE);
SubLine s2 = (SubLine) set.intersection(l2.wholeHyperplane());
List<Interval> i2 = ((IntervalsSet) s2.getRemainingRegion()).asList();
Assert.assertEquals(1, i2.size());
Interval v20 = i2.get(0);
- Point2D p20Lower = l2.toSpace(new Point1D(v20.getInf()));
+ Point2D p20Lower = l2.toSpace(Point1D.of(v20.getInf()));
Assert.assertEquals(1.0, p20Lower.getX(), TEST_TOLERANCE);
Assert.assertEquals(2.0, p20Lower.getY(), TEST_TOLERANCE);
- Point2D p20Upper = l2.toSpace(new Point1D(v20.getSup()));
+ Point2D p20Upper = l2.toSpace(Point1D.of(v20.getSup()));
Assert.assertEquals(3.0, p20Upper.getX(), TEST_TOLERANCE);
Assert.assertEquals(2.0, p20Upper.getY(), TEST_TOLERANCE);
}
@@ -746,18 +746,18 @@ public class PolygonsSetTest {
// arrange
Point2D[][] vertices1 = new Point2D[][] {
new Point2D[] {
- new Point2D(0.0, 0.0),
- new Point2D(4.0, 0.0),
- new Point2D(1.4, 1.5),
- new Point2D(0.0, 3.5)
+ Point2D.of(0.0, 0.0),
+ Point2D.of(4.0, 0.0),
+ Point2D.of(1.4, 1.5),
+ Point2D.of(0.0, 3.5)
}
};
PolygonsSet set1 = buildSet(vertices1);
Point2D[][] vertices2 = new Point2D[][] {
new Point2D[] {
- new Point2D(1.4, 0.2),
- new Point2D(2.8, -1.2),
- new Point2D(2.5, 0.6)
+ Point2D.of(1.4, 0.2),
+ Point2D.of(2.8, -1.2),
+ Point2D.of(2.5, 0.6)
}
};
PolygonsSet set2 = buildSet(vertices2);
@@ -772,13 +772,13 @@ public class PolygonsSetTest {
checkVertexLoopsEquivalent(vertices2, set2.getVertices());
checkVertexLoopsEquivalent(new Point2D[][] {
new Point2D[] {
- new Point2D(0.0, 0.0),
- new Point2D(1.6, 0.0),
- new Point2D(2.8, -1.2),
- new Point2D(2.6, 0.0),
- new Point2D(4.0, 0.0),
- new Point2D(1.4, 1.5),
- new Point2D(0.0, 3.5)
+ Point2D.of(0.0, 0.0),
+ Point2D.of(1.6, 0.0),
+ Point2D.of(2.8, -1.2),
+ Point2D.of(2.6, 0.0),
+ Point2D.of(4.0, 0.0),
+ Point2D.of(1.4, 1.5),
+ Point2D.of(0.0, 3.5)
}
}, set.getVertices());
}
@@ -788,19 +788,19 @@ public class PolygonsSetTest {
// arrange
Point2D[][] vertices1 = new Point2D[][] {
new Point2D[] {
- new Point2D( 0.0, 0.0),
- new Point2D( 2.0, 0.0),
- new Point2D( 2.0, 2.0),
- new Point2D( 0.0, 2.0)
+ Point2D.of( 0.0, 0.0),
+ Point2D.of( 2.0, 0.0),
+ Point2D.of( 2.0, 2.0),
+ Point2D.of( 0.0, 2.0)
}
};
PolygonsSet set1 = buildSet(vertices1);
Point2D[][] vertices2 = new Point2D[][] {
new Point2D[] {
- new Point2D( 1.0, 1.0),
- new Point2D( 3.0, 1.0),
- new Point2D( 3.0, 3.0),
- new Point2D( 1.0, 3.0)
+ Point2D.of( 1.0, 1.0),
+ Point2D.of( 3.0, 1.0),
+ Point2D.of( 3.0, 3.0),
+ Point2D.of( 1.0, 3.0)
}
};
PolygonsSet set2 = buildSet(vertices2);
@@ -814,41 +814,41 @@ public class PolygonsSetTest {
checkVertexLoopsEquivalent(vertices2, set2.getVertices());
checkVertexLoopsEquivalent(new Point2D[][] {
new Point2D[] {
- new Point2D( 0.0, 0.0),
- new Point2D( 2.0, 0.0),
- new Point2D( 2.0, 1.0),
- new Point2D( 3.0, 1.0),
- new Point2D( 3.0, 3.0),
- new Point2D( 1.0, 3.0),
- new Point2D( 1.0, 2.0),
- new Point2D( 0.0, 2.0)
+ Point2D.of( 0.0, 0.0),
+ Point2D.of( 2.0, 0.0),
+ Point2D.of( 2.0, 1.0),
+ Point2D.of( 3.0, 1.0),
+ Point2D.of( 3.0, 3.0),
+ Point2D.of( 1.0, 3.0),
+ Point2D.of( 1.0, 2.0),
+ Point2D.of( 0.0, 2.0)
}
}, set.getVertices());
checkPoints(Region.Location.INSIDE, set, new Point2D[] {
- new Point2D(1.0, 1.0),
- new Point2D(0.5, 0.5),
- new Point2D(2.0, 2.0),
- new Point2D(2.5, 2.5),
- new Point2D(0.5, 1.5),
- new Point2D(1.5, 1.5),
- new Point2D(1.5, 0.5),
- new Point2D(1.5, 2.5),
- new Point2D(2.5, 1.5),
- new Point2D(2.5, 2.5)
+ Point2D.of(1.0, 1.0),
+ Point2D.of(0.5, 0.5),
+ Point2D.of(2.0, 2.0),
+ Point2D.of(2.5, 2.5),
+ Point2D.of(0.5, 1.5),
+ Point2D.of(1.5, 1.5),
+ Point2D.of(1.5, 0.5),
+ Point2D.of(1.5, 2.5),
+ Point2D.of(2.5, 1.5),
+ Point2D.of(2.5, 2.5)
});
checkPoints(Region.Location.OUTSIDE, set, new Point2D[] {
- new Point2D(-0.5, 0.5),
- new Point2D( 0.5, 2.5),
- new Point2D( 2.5, 0.5),
- new Point2D( 3.5, 2.5)
+ Point2D.of(-0.5, 0.5),
+ Point2D.of( 0.5, 2.5),
+ Point2D.of( 2.5, 0.5),
+ Point2D.of( 3.5, 2.5)
});
checkPoints(Region.Location.BOUNDARY, set, new Point2D[] {
- new Point2D(0.0, 0.0),
- new Point2D(0.5, 2.0),
- new Point2D(2.0, 0.5),
- new Point2D(2.5, 1.0),
- new Point2D(3.0, 2.5)
+ Point2D.of(0.0, 0.0),
+ Point2D.of(0.5, 2.0),
+ Point2D.of(2.0, 0.5),
+ Point2D.of(2.5, 1.0),
+ Point2D.of(3.0, 2.5)
});
}
@@ -857,19 +857,19 @@ public class PolygonsSetTest {
// arrange
Point2D[][] vertices1 = new Point2D[][] {
new Point2D[] {
- new Point2D( 0.0, 0.0),
- new Point2D( 2.0, 0.0),
- new Point2D( 2.0, 2.0),
- new Point2D( 0.0, 2.0)
+ Point2D.of( 0.0, 0.0),
+ Point2D.of( 2.0, 0.0),
+ Point2D.of( 2.0, 2.0),
+ Point2D.of( 0.0, 2.0)
}
};
PolygonsSet set1 = buildSet(vertices1);
Point2D[][] vertices2 = new Point2D[][] {
new Point2D[] {
- new Point2D( 1.0, 1.0),
- new Point2D( 3.0, 1.0),
- new Point2D( 3.0, 3.0),
- new Point2D( 1.0, 3.0)
+ Point2D.of( 1.0, 1.0),
+ Point2D.of( 3.0, 1.0),
+ Point2D.of( 3.0, 3.0),
+ Point2D.of( 1.0, 3.0)
}
};
PolygonsSet set2 = buildSet(vertices2);
@@ -883,27 +883,27 @@ public class PolygonsSetTest {
checkVertexLoopsEquivalent(vertices2, set2.getVertices());
checkVertexLoopsEquivalent(new Point2D[][] {
new Point2D[] {
- new Point2D( 1.0, 1.0),
- new Point2D( 2.0, 1.0),
- new Point2D( 2.0, 2.0),
- new Point2D( 1.0, 2.0)
+ Point2D.of( 1.0, 1.0),
+ Point2D.of( 2.0, 1.0),
+ Point2D.of( 2.0, 2.0),
+ Point2D.of( 1.0, 2.0)
}
}, set.getVertices());
checkPoints(Region.Location.INSIDE, set, new Point2D[] {
- new Point2D(1.5, 1.5)
+ Point2D.of(1.5, 1.5)
});
checkPoints(Region.Location.OUTSIDE, set, new Point2D[] {
- new Point2D(0.5, 1.5),
- new Point2D(2.5, 1.5),
- new Point2D(1.5, 0.5),
- new Point2D(0.5, 0.5)
+ Point2D.of(0.5, 1.5),
+ Point2D.of(2.5, 1.5),
+ Point2D.of(1.5, 0.5),
+ Point2D.of(0.5, 0.5)
});
checkPoints(Region.Location.BOUNDARY, set, new Point2D[] {
- new Point2D(1.0, 1.0),
- new Point2D(2.0, 2.0),
- new Point2D(1.0, 1.5),
- new Point2D(1.5, 2.0)
+ Point2D.of(1.0, 1.0),
+ Point2D.of(2.0, 2.0),
+ Point2D.of(1.0, 1.5),
+ Point2D.of(1.5, 2.0)
});
}
@@ -912,19 +912,19 @@ public class PolygonsSetTest {
// arrange
Point2D[][] vertices1 = new Point2D[][] {
new Point2D[] {
- new Point2D( 0.0, 0.0),
- new Point2D( 2.0, 0.0),
- new Point2D( 2.0, 2.0),
- new Point2D( 0.0, 2.0)
+ Point2D.of( 0.0, 0.0),
+ Point2D.of( 2.0, 0.0),
+ Point2D.of( 2.0, 2.0),
+ Point2D.of( 0.0, 2.0)
}
};
PolygonsSet set1 = buildSet(vertices1);
Point2D[][] vertices2 = new Point2D[][] {
new Point2D[] {
- new Point2D( 1.0, 1.0),
- new Point2D( 3.0, 1.0),
- new Point2D( 3.0, 3.0),
- new Point2D( 1.0, 3.0)
+ Point2D.of( 1.0, 1.0),
+ Point2D.of( 3.0, 1.0),
+ Point2D.of( 3.0, 3.0),
+ Point2D.of( 1.0, 3.0)
}
};
PolygonsSet set2 = buildSet(vertices2);
@@ -938,49 +938,49 @@ public class PolygonsSetTest {
checkVertexLoopsEquivalent(vertices2, set2.getVertices());
checkVertexLoopsEquivalent(new Point2D[][] {
new Point2D[] {
- new Point2D( 0.0, 0.0),
- new Point2D( 2.0, 0.0),
- new Point2D( 2.0, 1.0),
- new Point2D( 3.0, 1.0),
- new Point2D( 3.0, 3.0),
- new Point2D( 1.0, 3.0),
- new Point2D( 1.0, 2.0),
- new Point2D( 0.0, 2.0)
+ Point2D.of( 0.0, 0.0),
+ Point2D.of( 2.0, 0.0),
+ Point2D.of( 2.0, 1.0),
+ Point2D.of( 3.0, 1.0),
+ Point2D.of( 3.0, 3.0),
+ Point2D.of( 1.0, 3.0),
+ Point2D.of( 1.0, 2.0),
+ Point2D.of( 0.0, 2.0)
},
new Point2D[] {
- new Point2D( 1.0, 1.0),
- new Point2D( 1.0, 2.0),
- new Point2D( 2.0, 2.0),
- new Point2D( 2.0, 1.0)
+ Point2D.of( 1.0, 1.0),
+ Point2D.of( 1.0, 2.0),
+ Point2D.of( 2.0, 2.0),
+ Point2D.of( 2.0, 1.0)
}
}, set.getVertices());
checkPoints(Region.Location.INSIDE, set, new Point2D[] {
- new Point2D(0.5, 0.5),
- new Point2D(2.5, 2.5),
- new Point2D(0.5, 1.5),
- new Point2D(1.5, 0.5),
- new Point2D(1.5, 2.5),
- new Point2D(2.5, 1.5),
- new Point2D(2.5, 2.5)
+ Point2D.of(0.5, 0.5),
+ Point2D.of(2.5, 2.5),
+ Point2D.of(0.5, 1.5),
+ Point2D.of(1.5, 0.5),
+ Point2D.of(1.5, 2.5),
+ Point2D.of(2.5, 1.5),
+ Point2D.of(2.5, 2.5)
});
checkPoints(Region.Location.OUTSIDE, set, new Point2D[] {
- new Point2D(-0.5, 0.5),
- new Point2D( 0.5, 2.5),
- new Point2D( 2.5, 0.5),
- new Point2D( 1.5, 1.5),
- new Point2D( 3.5, 2.5)
+ Point2D.of(-0.5, 0.5),
+ Point2D.of( 0.5, 2.5),
+ Point2D.of( 2.5, 0.5),
+ Point2D.of( 1.5, 1.5),
+ Point2D.of( 3.5, 2.5)
});
checkPoints(Region.Location.BOUNDARY, set, new Point2D[] {
- new Point2D(1.0, 1.0),
- new Point2D(2.0, 2.0),
- new Point2D(1.5, 1.0),
- new Point2D(2.0, 1.5),
- new Point2D(0.0, 0.0),
- new Point2D(0.5, 2.0),
- new Point2D(2.0, 0.5),
- new Point2D(2.5, 1.0),
- new Point2D(3.0, 2.5)
+ Point2D.of(1.0, 1.0),
+ Point2D.of(2.0, 2.0),
+ Point2D.of(1.5, 1.0),
+ Point2D.of(2.0, 1.5),
+ Point2D.of(0.0, 0.0),
+ Point2D.of(0.5, 2.0),
+ Point2D.of(2.0, 0.5),
+ Point2D.of(2.5, 1.0),
+ Point2D.of(3.0, 2.5)
});
}
@@ -989,19 +989,19 @@ public class PolygonsSetTest {
// arrange
Point2D[][] vertices1 = new Point2D[][] {
new Point2D[] {
- new Point2D( 0.0, 0.0),
- new Point2D( 2.0, 0.0),
- new Point2D( 2.0, 2.0),
- new Point2D( 0.0, 2.0)
+ Point2D.of( 0.0, 0.0),
+ Point2D.of( 2.0, 0.0),
+ Point2D.of( 2.0, 2.0),
+ Point2D.of( 0.0, 2.0)
}
};
PolygonsSet set1 = buildSet(vertices1);
Point2D[][] vertices2 = new Point2D[][] {
new Point2D[] {
- new Point2D( 1.0, 1.0),
- new Point2D( 3.0, 1.0),
- new Point2D( 3.0, 3.0),
- new Point2D( 1.0, 3.0)
+ Point2D.of( 1.0, 1.0),
+ Point2D.of( 3.0, 1.0),
+ Point2D.of( 3.0, 3.0),
+ Point2D.of( 1.0, 3.0)
}
};
PolygonsSet set2 = buildSet(vertices2);
@@ -1015,41 +1015,41 @@ public class PolygonsSetTest {
checkVertexLoopsEquivalent(vertices2, set2.getVertices());
checkVertexLoopsEquivalent(new Point2D[][] {
new Point2D[] {
- new Point2D( 0.0, 0.0),
- new Point2D( 2.0, 0.0),
- new Point2D( 2.0, 1.0),
- new Point2D( 1.0, 1.0),
- new Point2D( 1.0, 2.0),
- new Point2D( 0.0, 2.0)
+ Point2D.of( 0.0, 0.0),
+ Point2D.of( 2.0, 0.0),
+ Point2D.of( 2.0, 1.0),
+ Point2D.of( 1.0, 1.0),
+ Point2D.of( 1.0, 2.0),
+ Point2D.of( 0.0, 2.0)
}
}, set.getVertices());
checkPoints(Region.Location.INSIDE, set, new Point2D[] {
- new Point2D(0.5, 0.5),
- new Point2D(0.5, 1.5),
- new Point2D(1.5, 0.5)
+ Point2D.of(0.5, 0.5),
+ Point2D.of(0.5, 1.5),
+ Point2D.of(1.5, 0.5)
});
checkPoints(Region.Location.OUTSIDE, set, new Point2D[] {
- new Point2D( 2.5, 2.5),
- new Point2D(-0.5, 0.5),
- new Point2D( 0.5, 2.5),
- new Point2D( 2.5, 0.5),
- new Point2D( 1.5, 1.5),
- new Point2D( 3.5, 2.5),
- new Point2D( 1.5, 2.5),
- new Point2D( 2.5, 1.5),
- new Point2D( 2.0, 1.5),
- new Point2D( 2.0, 2.0),
- new Point2D( 2.5, 1.0),
- new Point2D( 2.5, 2.5),
- new Point2D( 3.0, 2.5)
+ Point2D.of( 2.5, 2.5),
+ Point2D.of(-0.5, 0.5),
+ Point2D.of( 0.5, 2.5),
+ Point2D.of( 2.5, 0.5),
+ Point2D.of( 1.5, 1.5),
+ Point2D.of( 3.5, 2.5),
+ Point2D.of( 1.5, 2.5),
+ Point2D.of( 2.5, 1.5),
+ Point2D.of( 2.0, 1.5),
+ Point2D.of( 2.0, 2.0),
+ Point2D.of( 2.5, 1.0),
+ Point2D.of( 2.5, 2.5),
+ Point2D.of( 3.0, 2.5)
});
checkPoints(Region.Location.BOUNDARY, set, new Point2D[] {
- new Point2D(1.0, 1.0),
- new Point2D(1.5, 1.0),
- new Point2D(0.0, 0.0),
- new Point2D(0.5, 2.0),
- new Point2D(2.0, 0.5)
+ Point2D.of(1.0, 1.0),
+ Point2D.of(1.5, 1.0),
+ Point2D.of(0.0, 0.0),
+ Point2D.of(0.5, 2.0),
+ Point2D.of(2.0, 0.5)
});
}
@@ -1058,19 +1058,19 @@ public class PolygonsSetTest {
// arrange
Point2D[][] vertices1 = new Point2D[][] {
new Point2D[] {
- new Point2D( 0.5, 3.5),
- new Point2D( 0.5, 4.5),
- new Point2D(-0.5, 4.5),
- new Point2D(-0.5, 3.5)
+ Point2D.of( 0.5, 3.5),
+ Point2D.of( 0.5, 4.5),
+ Point2D.of(-0.5, 4.5),
+ Point2D.of(-0.5, 3.5)
}
};
PolygonsSet set1 = buildSet(vertices1);
Point2D[][] vertices2 = new Point2D[][] {
new Point2D[] {
- new Point2D( 1.0, 2.0),
- new Point2D( 1.0, 8.0),
- new Point2D(-1.0, 8.0),
- new Point2D(-1.0, 2.0)
+ Point2D.of( 1.0, 2.0),
+ Point2D.of( 1.0, 8.0),
+ Point2D.of(-1.0, 8.0),
+ Point2D.of(-1.0, 2.0)
}
};
PolygonsSet set2 = buildSet(vertices2);
@@ -1089,13 +1089,13 @@ public class PolygonsSetTest {
double pi6 = Math.PI / 6.0;
double sqrt3 = Math.sqrt(3.0);
SubLine[] hyp = {
- new Line(new Point2D( 0.0, 1.0), 5 * pi6, TEST_TOLERANCE).wholeHyperplane(),
- new Line(new Point2D(-sqrt3, 1.0), 7 * pi6, TEST_TOLERANCE).wholeHyperplane(),
- new Line(new Point2D(-sqrt3, 1.0), 9 * pi6, TEST_TOLERANCE).wholeHyperplane(),
- new Line(new Point2D(-sqrt3, 0.0), 11 * pi6, TEST_TOLERANCE).wholeHyperplane(),
- new Line(new Point2D( 0.0, 0.0), 13 * pi6, TEST_TOLERANCE).wholeHyperplane(),
- new Line(new Point2D( 0.0, 1.0), 3 * pi6, TEST_TOLERANCE).wholeHyperplane(),
- new Line(new Point2D(-5.0 * sqrt3 / 6.0, 0.0), 9 * pi6, TEST_TOLERANCE).wholeHyperplane()
+ new Line(Point2D.of( 0.0, 1.0), 5 * pi6, TEST_TOLERANCE).wholeHyperplane(),
+ new Line(Point2D.of(-sqrt3, 1.0), 7 * pi6, TEST_TOLERANCE).wholeHyperplane(),
+ new Line(Point2D.of(-sqrt3, 1.0), 9 * pi6, TEST_TOLERANCE).wholeHyperplane(),
+ new Line(Point2D.of(-sqrt3, 0.0), 11 * pi6, TEST_TOLERANCE).wholeHyperplane(),
+ new Line(Point2D.of( 0.0, 0.0), 13 * pi6, TEST_TOLERANCE).wholeHyperplane(),
+ new Line(Point2D.of( 0.0, 1.0), 3 * pi6, TEST_TOLERANCE).wholeHyperplane(),
+ new Line(Point2D.of(-5.0 * sqrt3 / 6.0, 0.0), 9 * pi6, TEST_TOLERANCE).wholeHyperplane()
};
hyp[1] = (SubLine) hyp[1].split(hyp[0].getHyperplane()).getMinus();
hyp[2] = (SubLine) hyp[2].split(hyp[1].getHyperplane()).getMinus();
@@ -1109,7 +1109,7 @@ public class PolygonsSetTest {
}
PolygonsSet set = new PolygonsSet(tree, TEST_TOLERANCE);
SubLine splitter =
- new Line(new Point2D(-2.0 * sqrt3 / 3.0, 0.0), 9 * pi6, TEST_TOLERANCE).wholeHyperplane();
+ new Line(Point2D.of(-2.0 * sqrt3 / 3.0, 0.0), 9 * pi6, TEST_TOLERANCE).wholeHyperplane();
// act
PolygonsSet slice =
@@ -1120,7 +1120,7 @@ public class PolygonsSetTest {
// assert
Assert.assertEquals(Region.Location.OUTSIDE,
- slice.checkPoint(new Point2D(0.1, 0.5)));
+ slice.checkPoint(Point2D.of(0.1, 0.5)));
Assert.assertEquals(11.0 / 3.0, slice.getBoundarySize(), TEST_TOLERANCE);
}
@@ -1130,25 +1130,25 @@ public class PolygonsSetTest {
double h = Math.sqrt(3.0) / 2.0;
Point2D[][] vertices1 = new Point2D[][] {
new Point2D[] {
- new Point2D( 0.00, 0.1 * h),
- new Point2D( 0.05, 0.1 * h),
- new Point2D( 0.10, 0.2 * h),
- new Point2D( 0.05, 0.3 * h),
- new Point2D(-0.05, 0.3 * h),
- new Point2D(-0.10, 0.2 * h),
- new Point2D(-0.05, 0.1 * h)
+ Point2D.of( 0.00, 0.1 * h),
+ Point2D.of( 0.05, 0.1 * h),
+ Point2D.of( 0.10, 0.2 * h),
+ Point2D.of( 0.05, 0.3 * h),
+ Point2D.of(-0.05, 0.3 * h),
+ Point2D.of(-0.10, 0.2 * h),
+ Point2D.of(-0.05, 0.1 * h)
}
};
PolygonsSet set1 = buildSet(vertices1);
Point2D[][] vertices2 = new Point2D[][] {
new Point2D[] {
- new Point2D( 0.00, 0.0 * h),
- new Point2D( 0.10, 0.0 * h),
- new Point2D( 0.20, 0.2 * h),
- new Point2D( 0.10, 0.4 * h),
- new Point2D(-0.10, 0.4 * h),
- new Point2D(-0.20, 0.2 * h),
- new Point2D(-0.10, 0.0 * h)
+ Point2D.of( 0.00, 0.0 * h),
+ Point2D.of( 0.10, 0.0 * h),
+ Point2D.of( 0.20, 0.2 * h),
+ Point2D.of( 0.10, 0.4 * h),
+ Point2D.of(-0.10, 0.4 * h),
+ Point2D.of(-0.20, 0.2 * h),
+ Point2D.of(-0.10, 0.0 * h)
}
};
PolygonsSet set2 = buildSet(vertices2);
@@ -1161,86 +1161,86 @@ public class PolygonsSetTest {
public void testBug20040520() {
// arrange
BSPTree<Point2D> a0 =
- new BSPTree<>(buildSegment(new Point2D(0.85, -0.05),
- new Point2D(0.90, -0.10)),
+ new BSPTree<>(buildSegment(Point2D.of(0.85, -0.05),
+ Point2D.of(0.90, -0.10)),
new BSPTree<Point2D>(Boolean.FALSE),
new BSPTree<Point2D>(Boolean.TRUE),
null);
BSPTree<Point2D> a1 =
- new BSPTree<>(buildSegment(new Point2D(0.85, -0.10),
- new Point2D(0.90, -0.10)),
+ new BSPTree<>(buildSegment(Point2D.of(0.85, -0.10),
+ Point2D.of(0.90, -0.10)),
new BSPTree<Point2D>(Boolean.FALSE), a0, null);
BSPTree<Point2D> a2 =
- new BSPTree<>(buildSegment(new Point2D(0.90, -0.05),
- new Point2D(0.85, -0.05)),
+ new BSPTree<>(buildSegment(Point2D.of(0.90, -0.05),
+ Point2D.of(0.85, -0.05)),
new BSPTree<Point2D>(Boolean.FALSE), a1, null);
BSPTree<Point2D> a3 =
- new BSPTree<>(buildSegment(new Point2D(0.82, -0.05),
- new Point2D(0.82, -0.08)),
+ new BSPTree<>(buildSegment(Point2D.of(0.82, -0.05),
+ Point2D.of(0.82, -0.08)),
new BSPTree<Point2D>(Boolean.FALSE),
new BSPTree<Point2D>(Boolean.TRUE),
null);
BSPTree<Point2D> a4 =
- new BSPTree<>(buildHalfLine(new Point2D(0.85, -0.05),
- new Point2D(0.80, -0.05),
+ new BSPTree<>(buildHalfLine(Point2D.of(0.85, -0.05),
+ Point2D.of(0.80, -0.05),
false),
new BSPTree<Point2D>(Boolean.FALSE), a3, null);
BSPTree<Point2D> a5 =
- new BSPTree<>(buildSegment(new Point2D(0.82, -0.08),
- new Point2D(0.82, -0.18)),
+ new BSPTree<>(buildSegment(Point2D.of(0.82, -0.08),
+ Point2D.of(0.82, -0.18)),
new BSPTree<Point2D>(Boolean.FALSE),
new BSPTree<Point2D>(Boolean.TRUE),
null);
BSPTree<Point2D> a6 =
- new BSPTree<>(buildHalfLine(new Point2D(0.82, -0.18),
- new Point2D(0.85, -0.15),
+ new BSPTree<>(buildHalfLine(Point2D.of(0.82, -0.18),
+ Point2D.of(0.85, -0.15),
true),
new BSPTree<Point2D>(Boolean.FALSE), a5, null);
BSPTree<Point2D> a7 =
- new BSPTree<>(buildHalfLine(new Point2D(0.85, -0.05),
- new Point2D(0.82, -0.08),
+ new BSPTree<>(buildHalfLine(Point2D.of(0.85, -0.05),
+ Point2D.of(0.82, -0.08),
false),
a4, a6, null);
BSPTree<Point2D> a8 =
- new BSPTree<>(buildLine(new Point2D(0.85, -0.25),
- new Point2D(0.85, 0.05)),
+ new BSPTree<>(buildLine(Point2D.of(0.85, -0.25),
+ Point2D.of(0.85, 0.05)),
a2, a7, null);
BSPTree<Point2D> a9 =
- new BSPTree<>(buildLine(new Point2D(0.90, 0.05),
- new Point2D(0.90, -0.50)),
+ new BSPTree<>(buildLine(Point2D.of(0.90, 0.05),
+ Point2D.of(0.90, -0.50)),
a8, new BSPTree<Point2D>(Boolean.FALSE), null);
BSPTree<Point2D> b0 =
- new BSPTree<>(buildSegment(new Point2D(0.92, -0.12),
- new Point2D(0.92, -0.08)),
+ new BSPTree<>(buildSegment(Point2D.of(0.92, -0.12),
+ Point2D.of(0.92, -0.08)),
new BSPTree<Point2D>(Boolean.FALSE), new BSPTree<Point2D>(Boolean.TRUE),
null);
BSPTree<Point2D> b1 =
- new BSPTree<>(buildHalfLine(new Point2D(0.92, -0.08),
- new Point2D(0.90, -0.10),
+ new BSPTree<>(buildHalfLine(Point2D.of(0.92, -0.08),
+ Point2D.of(0.90, -0.10),
true),
new BSPTree<Point2D>(Boolean.FALSE), b0, null);
BSPTree<Point2D> b2 =
- new BSPTree<>(buildSegment(new Point2D(0.92, -0.18),
- new Point2D(0.92, -0.12)),
+ new BSPTree<>(buildSegment(Point2D.of(0.92, -0.18),
+ Point2D.of(0.92, -0.12)),
new BSPTree<Point2D>(Boolean.FALSE), new BSPTree<Point2D>(Boolean.TRUE),
null);
BSPTree<Point2D> b3 =
- new BSPTree<>(buildSegment(new Point2D(0.85, -0.15),
- new Point2D(0.90, -0.20)),
+ new BSPTree<>(buildSegment(Point2D.of(0.85, -0.15),
+ Point2D.of(0.90, -0.20)),
new BSPTree<Point2D>(Boolean.FALSE), b2, null);
BSPTree<Point2D> b4 =
- new BSPTree<>(buildSegment(new Point2D(0.95, -0.15),
- new Point2D(0.85, -0.05)),
+ new BSPTree<>(buildSegment(Point2D.of(0.95, -0.15),
+ Point2D.of(0.85, -0.05)),
b1, b3, null);
BSPTree<Point2D> b5 =
- new BSPTree<>(buildHalfLine(new Point2D(0.85, -0.05),
- new Point2D(0.85, -0.25),
+ new BSPTree<>(buildHalfLine(Point2D.of(0.85, -0.05),
+ Point2D.of(0.85, -0.25),
true),
new BSPTree<Point2D>(Boolean.FALSE), b4, null);
BSPTree<Point2D> b6 =
- new BSPTree<>(buildLine(new Point2D(0.0, -1.10),
- new Point2D(1.0, -0.10)),
+ new BSPTree<>(buildLine(Point2D.of(0.0, -1.10),
+ Point2D.of(1.0, -0.10)),
new BSPTree<Point2D>(Boolean.FALSE), b5, null);
// act
@@ -1250,38 +1250,38 @@ public class PolygonsSetTest {
// assert
checkPoints(Region.Location.INSIDE, c, new Point2D[] {
- new Point2D(0.83, -0.06),
- new Point2D(0.83, -0.15),
- new Point2D(0.88, -0.15),
- new Point2D(0.88, -0.09),
- new Point2D(0.88, -0.07),
- new Point2D(0.91, -0.18),
- new Point2D(0.91, -0.10)
+ Point2D.of(0.83, -0.06),
+ Point2D.of(0.83, -0.15),
+ Point2D.of(0.88, -0.15),
+ Point2D.of(0.88, -0.09),
+ Point2D.of(0.88, -0.07),
+ Point2D.of(0.91, -0.18),
+ Point2D.of(0.91, -0.10)
});
checkPoints(Region.Location.OUTSIDE, c, new Point2D[] {
- new Point2D(0.80, -0.10),
- new Point2D(0.83, -0.50),
- new Point2D(0.83, -0.20),
- new Point2D(0.83, -0.02),
- new Point2D(0.87, -0.50),
- new Point2D(0.87, -0.20),
- new Point2D(0.87, -0.02),
- new Point2D(0.91, -0.20),
- new Point2D(0.91, -0.08),
- new Point2D(0.93, -0.15)
+ Point2D.of(0.80, -0.10),
+ Point2D.of(0.83, -0.50),
+ Point2D.of(0.83, -0.20),
+ Point2D.of(0.83, -0.02),
+ Point2D.of(0.87, -0.50),
+ Point2D.of(0.87, -0.20),
+ Point2D.of(0.87, -0.02),
+ Point2D.of(0.91, -0.20),
+ Point2D.of(0.91, -0.08),
+ Point2D.of(0.93, -0.15)
});
checkVertexLoopsEquivalent(new Point2D[][] {
new Point2D[] {
- new Point2D(0.85, -0.15),
- new Point2D(0.90, -0.20),
- new Point2D(0.92, -0.18),
- new Point2D(0.92, -0.08),
- new Point2D(0.90, -0.10),
- new Point2D(0.90, -0.05),
- new Point2D(0.82, -0.05),
- new Point2D(0.82, -0.18),
+ Point2D.of(0.85, -0.15),
+ Point2D.of(0.90, -0.20),
+ Point2D.of(0.92, -0.18),
+ Point2D.of(0.92, -0.08),
+ Point2D.of(0.90, -0.10),
+ Point2D.of(0.90, -0.05),
+ Point2D.of(0.82, -0.05),
+ Point2D.of(0.82, -0.18),
}
}, c.getVertices());
}
@@ -1290,14 +1290,14 @@ public class PolygonsSetTest {
public void testBug20041003() {
// arrange
Line[] l = {
- new Line(new Point2D(0.0, 0.625000007541172),
- new Point2D(1.0, 0.625000007541172), TEST_TOLERANCE),
- new Line(new Point2D(-0.19204433621902645, 0.0),
- new Point2D(-0.19204433621902645, 1.0), TEST_TOLERANCE),
- new Line(new Point2D(-0.40303524786887, 0.4248364535319128),
- new Point2D(-1.12851149797877, -0.2634107480798909), TEST_TOLERANCE),
- new Line(new Point2D(0.0, 2.0),
- new Point2D(1.0, 2.0), TEST_TOLERANCE)
+ new Line(Point2D.of(0.0, 0.625000007541172),
+ Point2D.of(1.0, 0.625000007541172), TEST_TOLERANCE),
+ new Line(Point2D.of(-0.19204433621902645, 0.0),
+ Point2D.of(-0.19204433621902645, 1.0), TEST_TOLERANCE),
+ new Line(Point2D.of(-0.40303524786887, 0.4248364535319128),
+ Point2D.of(-1.12851149797877, -0.2634107480798909), TEST_TOLERANCE),
+ new Line(Point2D.of(0.0, 2.0),
+ Point2D.of(1.0, 2.0), TEST_TOLERANCE)
};
BSPTree<Point2D> node1 =
@@ -1340,181 +1340,181 @@ public class PolygonsSetTest {
public void testSqueezedHexa() {
// act
PolygonsSet set = new PolygonsSet(TEST_TOLERANCE,
- new Point2D(-6, -4), new Point2D(-8, -8), new Point2D( 8, -8),
- new Point2D( 6, -4), new Point2D(10, 4), new Point2D(-10, 4));
+ Point2D.of(-6, -4), Point2D.of(-8, -8), Point2D.of( 8, -8),
+ Point2D.of( 6, -4), Point2D.of(10, 4), Point2D.of(-10, 4));
// assert
- Assert.assertEquals(Location.OUTSIDE, set.checkPoint(new Point2D(0, 6)));
+ Assert.assertEquals(Location.OUTSIDE, set.checkPoint(Point2D.of(0, 6)));
}
@Test
public void testIssue880Simplified() {
// arrange
Point2D[] vertices1 = new Point2D[] {
- new Point2D( 90.13595870833188, 38.33604606376991),
- new Point2D( 90.14047850603913, 38.34600084496253),
- new Point2D( 90.11045289492762, 38.36801537312368),
- new Point2D( 90.10871471476526, 38.36878044144294),
- new Point2D( 90.10424901707671, 38.374300101757),
- new Point2D( 90.0979455456843, 38.373578376172475),
- new Point2D( 90.09081227075944, 38.37526295920463),
- new Point2D( 90.09081378927135, 38.375193883266434)
+ Point2D.of( 90.13595870833188, 38.33604606376991),
+ Point2D.of( 90.14047850603913, 38.34600084496253),
+ Point2D.of( 90.11045289492762, 38.36801537312368),
+ Point2D.of( 90.10871471476526, 38.36878044144294),
+ Point2D.of( 90.10424901707671, 38.374300101757),
+ Point2D.of( 90.0979455456843, 38.373578376172475),
+ Point2D.of( 90.09081227075944, 38.37526295920463),
+ Point2D.of( 90.09081378927135, 38.375193883266434)
};
// act
PolygonsSet set1 = new PolygonsSet(TEST_TOLERANCE, vertices1);
// assert
- Assert.assertEquals(Location.OUTSIDE, set1.checkPoint(new Point2D(90.12, 38.32)));
- Assert.assertEquals(Location.OUTSIDE, set1.checkPoint(new Point2D(90.135, 38.355)));
+ Assert.assertEquals(Location.OUTSIDE, set1.checkPoint(Point2D.of(90.12, 38.32)));
+ Assert.assertEquals(Location.OUTSIDE, set1.checkPoint(Point2D.of(90.135, 38.355)));
}
@Test
public void testIssue880Complete() {
Point2D[] vertices1 = new Point2D[] {
- new Point2D( 90.08714908223715, 38.370299337260235),
- new Point2D( 90.08709517675004, 38.3702895991413),
- new Point2D( 90.08401538704919, 38.368849330127944),
- new Point2D( 90.08258210430711, 38.367634558585564),
- new Point2D( 90.08251455106665, 38.36763409247078),
- new Point2D( 90.08106599752608, 38.36761621664249),
- new Point2D( 90.08249585300035, 38.36753627557965),
- new Point2D( 90.09075743352184, 38.35914647644972),
- new Point2D( 90.09099945896571, 38.35896264724079),
- new Point2D( 90.09269383800086, 38.34595756121246),
- new Point2D( 90.09638631543191, 38.3457988093121),
- new Point2D( 90.09666417351019, 38.34523360999418),
- new Point2D( 90.1297082145872, 38.337670454923625),
- new Point2D( 90.12971687748956, 38.337669827794684),
- new Point2D( 90.1240820219179, 38.34328502001131),
- new Point2D( 90.13084259656404, 38.34017811765017),
- new Point2D( 90.13378567942857, 38.33860579180606),
- new Point2D( 90.13519557833206, 38.33621054663689),
- new Point2D( 90.13545616732307, 38.33614965452864),
- new Point2D( 90.13553111202748, 38.33613962818305),
- new Point2D( 90.1356903436448, 38.33610227127048),
- new Point2D( 90.13576283227428, 38.33609255422783),
- new Point2D( 90.13595870833188, 38.33604606376991),
- new Point2D( 90.1361556630693, 38.3360024198866),
- new Point2D( 90.13622408795709, 38.335987048115726),
- new Point2D( 90.13696189099994, 38.33581914328681),
- new Point2D( 90.13746655304897, 38.33616706665265),
- new Point2D( 90.13845973716064, 38.33650776167099),
- new Point2D( 90.13950901827667, 38.3368469456463),
- new Point2D( 90.14393814424852, 38.337591835857495),
- new Point2D( 90.14483839716831, 38.337076122362475),
- new Point2D( 90.14565474433601, 38.33769000964429),
- new Point2D( 90.14569421179482, 38.3377117256905),
- new Point2D( 90.14577067124333, 38.33770883625908),
- new Point2D( 90.14600350631684, 38.337714326520995),
- new Point2D( 90.14600355139731, 38.33771435193319),
- new Point2D( 90.14600369112401, 38.33771443882085),
- new Point2D( 90.14600382486884, 38.33771453466096),
- new Point2D( 90.14600395205912, 38.33771463904344),
- new Point2D( 90.14600407214999, 38.337714751520764),
- new Point2D( 90.14600418462749, 38.337714871611695),
- new Point2D( 90.14600422249327, 38.337714915811034),
- new Point2D( 90.14867838361471, 38.34113888210675),
- new Point2D( 90.14923750157374, 38.341582537502575),
- new Point2D( 90.14877083250991, 38.34160685841391),
- new Point2D( 90.14816667319519, 38.34244232585684),
- new Point2D( 90.14797696744586, 38.34248455284745),
- new Point2D( 90.14484318014337, 38.34385573215269),
- new Point2D( 90.14477919958296, 38.3453797747614),
- new Point2D( 90.14202393306448, 38.34464324839456),
- new Point2D( 90.14198920640195, 38.344651155237216),
- new Point2D( 90.14155207025175, 38.34486424263724),
- new Point2D( 90.1415196143314, 38.344871730519),
- new Point2D( 90.14128611910814, 38.34500196593859),
- new Point2D( 90.14047850603913, 38.34600084496253),
- new Point2D( 90.14045907000337, 38.34601860032171),
- new Point2D( 90.14039496493928, 38.346223030432384),
- new Point2D( 90.14037626063737, 38.346240203360026),
- new Point2D( 90.14030005823724, 38.34646920000705),
- new Point2D( 90.13799164754806, 38.34903093011013),
- new Point2D( 90.11045289492762, 38.36801537312368),
- new Point2D( 90.10871471476526, 38.36878044144294),
- new Point2D( 90.10424901707671, 38.374300101757),
- new Point2D( 90.10263482039932, 38.37310041316073),
- new Point2D( 90.09834601753448, 38.373615053823414),
- new Point2D( 90.0979455456843, 38.373578376172475),
- new Point2D( 90.09086514328669, 38.37527884194668),
- new Point2D( 90.09084931407364, 38.37590801712463),
- new Point2D( 90.09081227075944, 38.37526295920463),
- new Point2D( 90.09081378927135, 38.375193883266434)
+ Point2D.of( 90.08714908223715, 38.370299337260235),
+ Point2D.of( 90.08709517675004, 38.3702895991413),
+ Point2D.of( 90.08401538704919, 38.368849330127944),
+ Point2D.of( 90.08258210430711, 38.367634558585564),
+ Point2D.of( 90.08251455106665, 38.36763409247078),
+ Point2D.of( 90.08106599752608, 38.36761621664249),
+ Point2D.of( 90.08249585300035, 38.36753627557965),
+ Point2D.of( 90.09075743352184, 38.35914647644972),
+ Point2D.of( 90.09099945896571, 38.35896264724079),
+ Point2D.of( 90.09269383800086, 38.34595756121246),
+ Point2D.of( 90.09638631543191, 38.3457988093121),
+ Point2D.of( 90.09666417351019, 38.34523360999418),
+ Point2D.of( 90.1297082145872, 38.337670454923625),
+ Point2D.of( 90.12971687748956, 38.337669827794684),
+ Point2D.of( 90.1240820219179, 38.34328502001131),
+ Point2D.of( 90.13084259656404, 38.34017811765017),
+ Point2D.of( 90.13378567942857, 38.33860579180606),
+ Point2D.of( 90.13519557833206, 38.33621054663689),
+ Point2D.of( 90.13545616732307, 38.33614965452864),
+ Point2D.of( 90.13553111202748, 38.33613962818305),
+ Point2D.of( 90.1356903436448, 38.33610227127048),
+ Point2D.of( 90.13576283227428, 38.33609255422783),
+ Point2D.of( 90.13595870833188, 38.33604606376991),
+ Point2D.of( 90.1361556630693, 38.3360024198866),
+ Point2D.of( 90.13622408795709, 38.335987048115726),
+ Point2D.of( 90.13696189099994, 38.33581914328681),
+ Point2D.of( 90.13746655304897, 38.33616706665265),
+ Point2D.of( 90.13845973716064, 38.33650776167099),
+ Point2D.of( 90.13950901827667, 38.3368469456463),
+ Point2D.of( 90.14393814424852, 38.337591835857495),
+ Point2D.of( 90.14483839716831, 38.337076122362475),
+ Point2D.of( 90.14565474433601, 38.33769000964429),
+ Point2D.of( 90.14569421179482, 38.3377117256905),
+ Point2D.of( 90.14577067124333, 38.33770883625908),
+ Point2D.of( 90.14600350631684, 38.337714326520995),
+ Point2D.of( 90.14600355139731, 38.33771435193319),
+ Point2D.of( 90.14600369112401, 38.33771443882085),
+ Point2D.of( 90.14600382486884, 38.33771453466096),
+ Point2D.of( 90.14600395205912, 38.33771463904344),
+ Point2D.of( 90.14600407214999, 38.337714751520764),
+ Point2D.of( 90.14600418462749, 38.337714871611695),
+ Point2D.of( 90.14600422249327, 38.337714915811034),
+ Point2D.of( 90.14867838361471, 38.34113888210675),
+ Point2D.of( 90.14923750157374, 38.341582537502575),
+ Point2D.of( 90.14877083250991, 38.34160685841391),
+ Point2D.of( 90.14816667319519, 38.34244232585684),
+ Point2D.of( 90.14797696744586, 38.34248455284745),
+ Point2D.of( 90.14484318014337, 38.34385573215269),
+ Point2D.of( 90.14477919958296, 38.3453797747614),
+ Point2D.of( 90.14202393306448, 38.34464324839456),
+ Point2D.of( 90.14198920640195, 38.344651155237216),
+ Point2D.of( 90.14155207025175, 38.34486424263724),
+ Point2D.of( 90.1415196143314, 38.344871730519),
+ Point2D.of( 90.14128611910814, 38.34500196593859),
+ Point2D.of( 90.14047850603913, 38.34600084496253),
+ Point2D.of( 90.14045907000337, 38.34601860032171),
+ Point2D.of( 90.14039496493928, 38.346223030432384),
+ Point2D.of( 90.14037626063737, 38.346240203360026),
+ Point2D.of( 90.14030005823724, 38.34646920000705),
+ Point2D.of( 90.13799164754806, 38.34903093011013),
+ Point2D.of( 90.11045289492762, 38.36801537312368),
+ Point2D.of( 90.10871471476526, 38.36878044144294),
+ Point2D.of( 90.10424901707671, 38.374300101757),
+ Point2D.of( 90.10263482039932, 38.37310041316073),
+ Point2D.of( 90.09834601753448, 38.373615053823414),
+ Point2D.of( 90.0979455456843, 38.373578376172475),
+ Point2D.of( 90.09086514328669, 38.37527884194668),
+ Point2D.of( 90.09084931407364, 38.37590801712463),
+ Point2D.of( 90.09081227075944, 38.37526295920463),
+ Point2D.of( 90.09081378927135, 38.375193883266434)
};
PolygonsSet set1 = new PolygonsSet(1.0e-8, vertices1);
- Assert.assertEquals(Location.OUTSIDE, set1.checkPoint(new Point2D(90.0905, 38.3755)));
- Assert.assertEquals(Location.INSIDE, set1.checkPoint(new Point2D(90.09084, 38.3755)));
- Assert.assertEquals(Location.OUTSIDE, set1.checkPoint(new Point2D(90.0913, 38.3755)));
- Assert.assertEquals(Location.INSIDE, set1.checkPoint(new Point2D(90.1042, 38.3739)));
- Assert.assertEquals(Location.INSIDE, set1.checkPoint(new Point2D(90.1111, 38.3673)));
- Assert.assertEquals(Location.OUTSIDE, set1.checkPoint(new Point2D(90.0959, 38.3457)));
+ Assert.assertEquals(Location.OUTSIDE, set1.checkPoint(Point2D.of(90.0905, 38.3755)));
+ Assert.assertEquals(Location.INSIDE, set1.checkPoint(Point2D.of(90.09084, 38.3755)));
+ Assert.assertEquals(Location.OUTSIDE, set1.checkPoint(Point2D.of(90.0913, 38.3755)));
+ Assert.assertEquals(Location.INSIDE, set1.checkPoint(Point2D.of(90.1042, 38.3739)));
+ Assert.assertEquals(Location.INSIDE, set1.checkPoint(Point2D.of(90.1111, 38.3673)));
+ Assert.assertEquals(Location.OUTSIDE, set1.checkPoint(Point2D.of(90.0959, 38.3457)));
Point2D[] vertices2 = new Point2D[] {
- new Point2D( 90.13067558880044, 38.36977255037573),
- new Point2D( 90.12907570488, 38.36817308242706),
- new Point2D( 90.1342774136516, 38.356886880294724),
- new Point2D( 90.13090330629757, 38.34664392676211),
- new Point2D( 90.13078571364593, 38.344904617518466),
- new Point2D( 90.1315602208914, 38.3447185040846),
- new Point2D( 90.1316336226821, 38.34470643148342),
- new Point2D( 90.134020944832, 38.340936644972885),
- new Point2D( 90.13912536387306, 38.335497255122334),
- new Point2D( 90.1396178806582, 38.334878075552126),
- new Point2D( 90.14083049696671, 38.33316530644106),
- new Point2D( 90.14145252901329, 38.33152722916191),
- new Point2D( 90.1404779335565, 38.32863516047786),
- new Point2D( 90.14282712131586, 38.327504432532066),
- new Point2D( 90.14616669875488, 38.3237354115015),
- new Point2D( 90.14860976050608, 38.315714862457924),
- new Point2D( 90.14999277782437, 38.3164932507504),
- new Point2D( 90.15005207194997, 38.316534677663356),
- new Point2D( 90.15508513859612, 38.31878731691609),
- new Point2D( 90.15919938519221, 38.31852743183782),
- new Point2D( 90.16093758658837, 38.31880662005153),
- new Point2D( 90.16099420184912, 38.318825953291594),
- new Point2D( 90.1665411125756, 38.31859497874757),
- new Point2D( 90.16999653861313, 38.32505772048029),
- new Point2D( 90.17475243391698, 38.32594398441148),
- new Point2D( 90.17940844844992, 38.327427213761325),
- new Point2D( 90.20951909541378, 38.330616833491774),
- new Point2D( 90.2155400467941, 38.331746223670336),
- new Point2D( 90.21559881391778, 38.33175551425302),
- new Point2D( 90.21916646426041, 38.332584299620805),
- new Point2D( 90.23863749852285, 38.34778978875795),
- new Point2D( 90.25459855175802, 38.357790570608984),
- new Point2D( 90.25964298227257, 38.356918010203174),
- new Point2D( 90.26024593994703, 38.361692743151366),
- new Point2D( 90.26146187570015, 38.36311080550837),
- new Point2D( 90.26614159359622, 38.36510808579902),
- new Point2D( 90.26621342936448, 38.36507942500333),
- new Point2D( 90.26652190211962, 38.36494042196722),
- new Point2D( 90.26621240678867, 38.365113172030874),
- new Point2D( 90.26614057102057, 38.365141832826794),
- new Point2D( 90.26380080055299, 38.3660381760273),
- new Point2D( 90.26315345241, 38.36670658276421),
- new Point2D( 90.26251574942881, 38.367490323488084),
- new Point2D( 90.26247873448426, 38.36755266444749),
- new Point2D( 90.26234628016698, 38.36787989125406),
- new Point2D( 90.26214559424784, 38.36945909356126),
- new Point2D( 90.25861728442555, 38.37200753430875),
- new Point2D( 90.23905557537864, 38.375405314295904),
- new Point2D( 90.22517251874075, 38.38984691662256),
- new Point2D( 90.22549955153215, 38.3911564273979),
- new Point2D( 90.22434386063355, 38.391476432092134),
- new Point2D( 90.22147729457276, 38.39134652252034),
- new Point2D( 90.22142070120117, 38.391349167741964),
- new Point2D( 90.20665060751588, 38.39475580900313),
- new Point2D( 90.20042268367109, 38.39842558622888),
- new Point2D( 90.17423771242085, 38.402727751805344),
- new Point2D( 90.16756796257476, 38.40913898597597),
- new Point2D( 90.16728283954308, 38.411255399912875),
- new Point2D( 90.16703538220418, 38.41136059866693),
- new Point2D( 90.16725865657685, 38.41013618805954),
- new Point2D( 90.16746107640665, 38.40902614307544),
- new Point2D( 90.16122795307462, 38.39773101873203)
+ Point2D.of( 90.13067558880044, 38.36977255037573),
+ Point2D.of( 90.12907570488, 38.36817308242706),
+ Point2D.of( 90.1342774136516, 38.356886880294724),
+ Point2D.of( 90.13090330629757, 38.34664392676211),
+ Point2D.of( 90.13078571364593, 38.344904617518466),
+ Point2D.of( 90.1315602208914, 38.3447185040846),
+ Point2D.of( 90.1316336226821, 38.34470643148342),
+ Point2D.of( 90.134020944832, 38.340936644972885),
+ Point2D.of( 90.13912536387306, 38.335497255122334),
+ Point2D.of( 90.1396178806582, 38.334878075552126),
+ Point2D.of( 90.14083049696671, 38.33316530644106),
+ Point2D.of( 90.14145252901329, 38.33152722916191),
+ Point2D.of( 90.1404779335565, 38.32863516047786),
+ Point2D.of( 90.14282712131586, 38.327504432532066),
+ Point2D.of( 90.14616669875488, 38.3237354115015),
+ Point2D.of( 90.14860976050608, 38.315714862457924),
+ Point2D.of( 90.14999277782437, 38.3164932507504),
+ Point2D.of( 90.15005207194997, 38.316534677663356),
+ Point2D.of( 90.15508513859612, 38.31878731691609),
+ Point2D.of( 90.15919938519221, 38.31852743183782),
+ Point2D.of( 90.16093758658837, 38.31880662005153),
+ Point2D.of( 90.16099420184912, 38.318825953291594),
+ Point2D.of( 90.1665411125756, 38.31859497874757),
+ Point2D.of( 90.16999653861313, 38.32505772048029),
+ Point2D.of( 90.17475243391698, 38.32594398441148),
+ Point2D.of( 90.17940844844992, 38.327427213761325),
+ Point2D.of( 90.20951909541378, 38.330616833491774),
+ Point2D.of( 90.2155400467941, 38.331746223670336),
+ Point2D.of( 90.21559881391778, 38.33175551425302),
+ Point2D.of( 90.21916646426041, 38.332584299620805),
+ Point2D.of( 90.23863749852285, 38.34778978875795),
+ Point2D.of( 90.25459855175802, 38.357790570608984),
+ Point2D.of( 90.25964298227257, 38.356918010203174),
+ Point2D.of( 90.26024593994703, 38.361692743151366),
+ Point2D.of( 90.26146187570015, 38.36311080550837),
+ Point2D.of( 90.26614159359622, 38.36510808579902),
+ Point2D.of( 90.26621342936448, 38.36507942500333),
+ Point2D.of( 90.26652190211962, 38.36494042196722),
+ Point2D.of( 90.26621240678867, 38.365113172030874),
+ Point2D.of( 90.26614057102057, 38.365141832826794),
+ Point2D.of( 90.26380080055299, 38.3660381760273),
+ Point2D.of( 90.26315345241, 38.36670658276421),
+ Point2D.of( 90.26251574942881, 38.367490323488084),
+ Point2D.of( 90.26247873448426, 38.36755266444749),
+ Point2D.of( 90.26234628016698, 38.36787989125406),
+ Point2D.of( 90.26214559424784, 38.36945909356126),
+ Point2D.of( 90.25861728442555, 38.37200753430875),
+ Point2D.of( 90.23905557537864, 38.375405314295904),
+ Point2D.of( 90.22517251874075, 38.38984691662256),
+ Point2D.of( 90.22549955153215, 38.3911564273979),
+ Point2D.of( 90.22434386063355, 38.391476432092134),
+ Point2D.of( 90.22147729457276, 38.39134652252034),
+ Point2D.of( 90.22142070120117, 38.391349167741964),
+ Point2D.of( 90.20665060751588, 38.39475580900313),
+ Point2D.of( 90.20042268367109, 38.39842558622888),
+ Point2D.of( 90.17423771242085, 38.402727751805344),
+ Point2D.of( 90.16756796257476, 38.40913898597597),
+ Point2D.of( 90.16728283954308, 38.411255399912875),
+ Point2D.of( 90.16703538220418, 38.41136059866693),
+ Point2D.of( 90.16725865657685, 38.41013618805954),
+ Point2D.of( 90.16746107640665, 38.40902614307544),
+ Point2D.of( 90.16122795307462, 38.39773101873203)
};
PolygonsSet set2 = new PolygonsSet(1.0e-8, vertices2);
PolygonsSet set = (PolygonsSet) new
@@ -1553,17 +1553,17 @@ public class PolygonsSetTest {
public void testIssue1162() {
// arrange
PolygonsSet p = new PolygonsSet(TEST_TOLERANCE,
- new Point2D(4.267199999996532, -11.928637756014894),
- new Point2D(4.267200000026445, -14.12360595809307),
- new Point2D(9.144000000273694, -14.12360595809307),
- new Point2D(9.144000000233383, -11.928637756020067));
+ Point2D.of(4.267199999996532, -11.928637756014894),
+ Point2D.of(4.267200000026445, -14.12360595809307),
+ Point2D.of(9.144000000273694, -14.12360595809307),
+ Point2D.of(9.144000000233383, -11.928637756020067));
PolygonsSet w = new PolygonsSet(TEST_TOLERANCE,
- new Point2D(2.56735636510452512E-9, -11.933116461089332),
- new Point2D(2.56735636510452512E-9, -12.393225665247766),
- new Point2D(2.56735636510452512E-9, -27.785625665247778),
- new Point2D(4.267200000030211, -27.785625665247778),
- new Point2D(4.267200000030211, -11.933116461089332));
+ Point2D.of(2.56735636510452512E-9, -11.933116461089332),
+ Point2D.of(2.56735636510452512E-9, -12.393225665247766),
+ Point2D.of(2.56735636510452512E-9, -27.785625665247778),
+ Point2D.of(4.267200000030211, -27.785625665247778),
+ Point2D.of(4.267200000030211, -11.933116461089332));
// act/assert
Assert.assertFalse(p.contains(w));
@@ -1575,10 +1575,10 @@ public class PolygonsSetTest {
// arrange
RegionFactory<Point2D> factory = new RegionFactory<>();
- Point2D pA = new Point2D(0.0, 1.0);
- Point2D pB = new Point2D(0.0, 0.0);
- Point2D pC = new Point2D(1.0 / 64.0, 0.0);
- Point2D pD = new Point2D(1.0 / 64.0, 1.0);
+ Point2D pA = Point2D.of(0.0, 1.0);
+ Point2D pB = Point2D.of(0.0, 0.0);
+ Point2D pC = Point2D.of(1.0 / 64.0, 0.0);
+ Point2D pD = Point2D.of(1.0 / 64.0, 1.0);
// if tolerance is smaller than rectangle width, the rectangle is computed accurately
Hyperplane<Point2D>[] h1 = new Line[] {
@@ -1605,10 +1605,10 @@ public class PolygonsSetTest {
// arrange
RegionFactory<Point2D> factory = new RegionFactory<>();
- Point2D pA = new Point2D(0.0, 1.0);
- Point2D pB = new Point2D(0.0, 0.0);
- Point2D pC = new Point2D(1.0 / 64.0, 0.0);
- Point2D pD = new Point2D(1.0 / 64.0, 1.0);
+ Point2D pA = Point2D.of(0.0, 1.0);
+ Point2D pB = Point2D.of(0.0, 0.0);
+ Point2D pC = Point2D.of(1.0 / 64.0, 0.0);
+ Point2D pD = Point2D.of(1.0 / 64.0, 1.0);
Hyperplane<Point2D>[] h2 = new Line[] {
new Line(pA, pB, 1.0 / 16),
@@ -1629,18 +1629,18 @@ public class PolygonsSetTest {
public void testInconsistentHyperplanes() {
// act
double tolerance = TEST_TOLERANCE;
- new RegionFactory<Point2D>().buildConvex(new Line(new Point2D(0, 0), new Point2D(0, 1), tolerance),
- new Line(new Point2D(1, 1), new Point2D(1, 0), tolerance));
+ new RegionFactory<Point2D>().buildConvex(new Line(Point2D.of(0, 0), Point2D.of(0, 1), tolerance),
+ new Line(Point2D.of(1, 1), Point2D.of(1, 0), tolerance));
}
@Test
public void testBoundarySimplification() {
// a simple square will result in a 4 cuts and 5 leafs tree
PolygonsSet square = new PolygonsSet(TEST_TOLERANCE,
- new Point2D(0, 0),
- new Point2D(1, 0),
- new Point2D(1, 1),
- new Point2D(0, 1));
+ Point2D.of(0, 0),
+ Point2D.of(1, 0),
+ Point2D.of(1, 1),
+ Point2D.of(0, 1));
Point2D[][] squareBoundary = square.getVertices();
Assert.assertEquals(1, squareBoundary.length);
Assert.assertEquals(4, squareBoundary[0].length);
@@ -1651,7 +1651,7 @@ public class PolygonsSetTest {
// splitting the square in two halves increases the BSP tree
// with 3 more cuts and 3 more leaf nodes
- SubLine cut = new Line(new Point2D(0.5, 0.5), 0.0, square.getTolerance()).wholeHyperplane();
+ SubLine cut = new Line(Point2D.of(0.5, 0.5), 0.0, square.getTolerance()).wholeHyperplane();
PolygonsSet splitSquare = new PolygonsSet(square.getTree(false).split(cut),
square.getTolerance());
Counter splitSquareCount = new Counter();
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 d5ca735..f9c71e2 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
@@ -23,20 +23,20 @@ public class SegmentTest {
@Test
public void testDistance() {
- Point2D start = new Point2D(2, 2);
- Point2D end = new Point2D(-2, -2);
+ Point2D start = Point2D.of(2, 2);
+ Point2D end = Point2D.of(-2, -2);
Segment segment = new Segment(start, end, new Line(start, end, 1.0e-10));
// distance to center of segment
- Assert.assertEquals(Math.sqrt(2), segment.distance(new Point2D(1, -1)), 1.0e-10);
+ Assert.assertEquals(Math.sqrt(2), segment.distance(Point2D.of(1, -1)), 1.0e-10);
// distance a point on segment
- Assert.assertEquals(Math.sin(Math.PI / 4.0), segment.distance(new Point2D(0, -1)), 1.0e-10);
+ Assert.assertEquals(Math.sin(Math.PI / 4.0), segment.distance(Point2D.of(0, -1)), 1.0e-10);
// distance to end point
- Assert.assertEquals(Math.sqrt(8), segment.distance(new Point2D(0, 4)), 1.0e-10);
+ Assert.assertEquals(Math.sqrt(8), segment.distance(Point2D.of(0, 4)), 1.0e-10);
// distance to start point
- Assert.assertEquals(Math.sqrt(8), segment.distance(new Point2D(0, -4)), 1.0e-10);
+ Assert.assertEquals(Math.sqrt(8), segment.distance(Point2D.of(0, -4)), 1.0e-10);
}
}
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 246491a..94a282d 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
@@ -28,19 +28,19 @@ public class SubLineTest {
@Test
public void testEndPoints() {
- Point2D p1 = new Point2D(-1, -7);
- Point2D p2 = new Point2D(7, -1);
+ Point2D p1 = Point2D.of(-1, -7);
+ Point2D p2 = Point2D.of(7, -1);
Segment segment = new Segment(p1, p2, new Line(p1, p2, 1.0e-10));
SubLine sub = new SubLine(segment);
List<Segment> segments = sub.getSegments();
Assert.assertEquals(1, segments.size());
- Assert.assertEquals(0.0, new Point2D(-1, -7).distance(segments.get(0).getStart()), 1.0e-10);
- Assert.assertEquals(0.0, new Point2D( 7, -1).distance(segments.get(0).getEnd()), 1.0e-10);
+ Assert.assertEquals(0.0, Point2D.of(-1, -7).distance(segments.get(0).getStart()), 1.0e-10);
+ Assert.assertEquals(0.0, Point2D.of( 7, -1).distance(segments.get(0).getEnd()), 1.0e-10);
}
@Test
public void testNoEndPoints() {
- SubLine wholeLine = new Line(new Point2D(-1, 7), new Point2D(7, 1), 1.0e-10).wholeHyperplane();
+ SubLine wholeLine = new Line(Point2D.of(-1, 7), Point2D.of(7, 1), 1.0e-10).wholeHyperplane();
List<Segment> segments = wholeLine.getSegments();
Assert.assertEquals(1, segments.size());
Assert.assertTrue(Double.isInfinite(segments.get(0).getStart().getX()) &&
@@ -55,7 +55,7 @@ public class SubLineTest {
@Test
public void testNoSegments() {
- SubLine empty = new SubLine(new Line(new Point2D(-1, -7), new Point2D(7, -1), 1.0e-10),
+ SubLine empty = new SubLine(new Line(Point2D.of(-1, -7), Point2D.of(7, -1), 1.0e-10),
new RegionFactory<Point1D>().getComplement(new IntervalsSet(1.0e-10)));
List<Segment> segments = empty.getSegments();
Assert.assertEquals(0, segments.size());
@@ -63,7 +63,7 @@ public class SubLineTest {
@Test
public void testSeveralSegments() {
- SubLine twoSubs = new SubLine(new Line(new Point2D(-1, -7), new Point2D(7, -1), 1.0e-10),
+ SubLine twoSubs = new SubLine(new Line(Point2D.of(-1, -7), Point2D.of(7, -1), 1.0e-10),
new RegionFactory<Point1D>().union(new IntervalsSet(1, 2, 1.0e-10),
new IntervalsSet(3, 4, 1.0e-10)));
List<Segment> segments = twoSubs.getSegments();
@@ -72,7 +72,7 @@ public class SubLineTest {
@Test
public void testHalfInfiniteNeg() {
- SubLine empty = new SubLine(new Line(new Point2D(-1, -7), new Point2D(7, -1), 1.0e-10),
+ SubLine empty = new SubLine(new Line(Point2D.of(-1, -7), Point2D.of(7, -1), 1.0e-10),
new IntervalsSet(Double.NEGATIVE_INFINITY, 0.0, 1.0e-10));
List<Segment> segments = empty.getSegments();
Assert.assertEquals(1, segments.size());
@@ -80,16 +80,16 @@ public class SubLineTest {
segments.get(0).getStart().getX() < 0);
Assert.assertTrue(Double.isInfinite(segments.get(0).getStart().getY()) &&
segments.get(0).getStart().getY() < 0);
- Assert.assertEquals(0.0, new Point2D(3, -4).distance(segments.get(0).getEnd()), 1.0e-10);
+ Assert.assertEquals(0.0, Point2D.of(3, -4).distance(segments.get(0).getEnd()), 1.0e-10);
}
@Test
public void testHalfInfinitePos() {
- SubLine empty = new SubLine(new Line(new Point2D(-1, -7), new Point2D(7, -1), 1.0e-10),
+ SubLine empty = new SubLine(new Line(Point2D.of(-1, -7), Point2D.of(7, -1), 1.0e-10),
new IntervalsSet(0.0, Double.POSITIVE_INFINITY, 1.0e-10));
List<Segment> segments = empty.getSegments();
Assert.assertEquals(1, segments.size());
- Assert.assertEquals(0.0, new Point2D(3, -4).distance(segments.get(0).getStart()), 1.0e-10);
+ Assert.assertEquals(0.0, Point2D.of(3, -4).distance(segments.get(0).getStart()), 1.0e-10);
Assert.assertTrue(Double.isInfinite(segments.get(0).getEnd().getX()) &&
segments.get(0).getEnd().getX() > 0);
Assert.assertTrue(Double.isInfinite(segments.get(0).getEnd().getY()) &&
@@ -98,56 +98,56 @@ public class SubLineTest {
@Test
public void testIntersectionInsideInside() {
- SubLine sub1 = new SubLine(new Point2D(1, 1), new Point2D(3, 1), 1.0e-10);
- SubLine sub2 = new SubLine(new Point2D(2, 0), new Point2D(2, 2), 1.0e-10);
- Assert.assertEquals(0.0, new Point2D(2, 1).distance(sub1.intersection(sub2, true)), 1.0e-12);
- Assert.assertEquals(0.0, new Point2D(2, 1).distance(sub1.intersection(sub2, false)), 1.0e-12);
+ SubLine sub1 = new SubLine(Point2D.of(1, 1), Point2D.of(3, 1), 1.0e-10);
+ SubLine sub2 = new SubLine(Point2D.of(2, 0), Point2D.of(2, 2), 1.0e-10);
+ Assert.assertEquals(0.0, Point2D.of(2, 1).distance(sub1.intersection(sub2, true)), 1.0e-12);
+ Assert.assertEquals(0.0, Point2D.of(2, 1).distance(sub1.intersection(sub2, false)), 1.0e-12);
}
@Test
public void testIntersectionInsideBoundary() {
- SubLine sub1 = new SubLine(new Point2D(1, 1), new Point2D(3, 1), 1.0e-10);
- SubLine sub2 = new SubLine(new Point2D(2, 0), new Point2D(2, 1), 1.0e-10);
- Assert.assertEquals(0.0, new Point2D(2, 1).distance(sub1.intersection(sub2, true)), 1.0e-12);
+ SubLine sub1 = new SubLine(Point2D.of(1, 1), Point2D.of(3, 1), 1.0e-10);
+ SubLine sub2 = new SubLine(Point2D.of(2, 0), Point2D.of(2, 1), 1.0e-10);
+ Assert.assertEquals(0.0, Point2D.of(2, 1).distance(sub1.intersection(sub2, true)), 1.0e-12);
Assert.assertNull(sub1.intersection(sub2, false));
}
@Test
public void testIntersectionInsideOutside() {
- SubLine sub1 = new SubLine(new Point2D(1, 1), new Point2D(3, 1), 1.0e-10);
- SubLine sub2 = new SubLine(new Point2D(2, 0), new Point2D(2, 0.5), 1.0e-10);
+ SubLine sub1 = new SubLine(Point2D.of(1, 1), Point2D.of(3, 1), 1.0e-10);
+ SubLine sub2 = new SubLine(Point2D.of(2, 0), Point2D.of(2, 0.5), 1.0e-10);
Assert.assertNull(sub1.intersection(sub2, true));
Assert.assertNull(sub1.intersection(sub2, false));
}
@Test
public void testIntersectionBoundaryBoundary() {
- SubLine sub1 = new SubLine(new Point2D(1, 1), new Point2D(2, 1), 1.0e-10);
- SubLine sub2 = new SubLine(new Point2D(2, 0), new Point2D(2, 1), 1.0e-10);
- Assert.assertEquals(0.0, new Point2D(2, 1).distance(sub1.intersection(sub2, true)), 1.0e-12);
+ SubLine sub1 = new SubLine(Point2D.of(1, 1), Point2D.of(2, 1), 1.0e-10);
+ SubLine sub2 = new SubLine(Point2D.of(2, 0), Point2D.of(2, 1), 1.0e-10);
+ Assert.assertEquals(0.0, Point2D.of(2, 1).distance(sub1.intersection(sub2, true)), 1.0e-12);
Assert.assertNull(sub1.intersection(sub2, false));
}
@Test
public void testIntersectionBoundaryOutside() {
- SubLine sub1 = new SubLine(new Point2D(1, 1), new Point2D(2, 1), 1.0e-10);
- SubLine sub2 = new SubLine(new Point2D(2, 0), new Point2D(2, 0.5), 1.0e-10);
+ SubLine sub1 = new SubLine(Point2D.of(1, 1), Point2D.of(2, 1), 1.0e-10);
+ SubLine sub2 = new SubLine(Point2D.of(2, 0), Point2D.of(2, 0.5), 1.0e-10);
Assert.assertNull(sub1.intersection(sub2, true));
Assert.assertNull(sub1.intersection(sub2, false));
}
@Test
public void testIntersectionOutsideOutside() {
- SubLine sub1 = new SubLine(new Point2D(1, 1), new Point2D(1.5, 1), 1.0e-10);
- SubLine sub2 = new SubLine(new Point2D(2, 0), new Point2D(2, 0.5), 1.0e-10);
+ SubLine sub1 = new SubLine(Point2D.of(1, 1), Point2D.of(1.5, 1), 1.0e-10);
+ SubLine sub2 = new SubLine(Point2D.of(2, 0), Point2D.of(2, 0.5), 1.0e-10);
Assert.assertNull(sub1.intersection(sub2, true));
Assert.assertNull(sub1.intersection(sub2, false));
}
@Test
public void testIntersectionParallel() {
- final SubLine sub1 = new SubLine(new Point2D(0, 1), new Point2D(0, 2), 1.0e-10);
- final SubLine sub2 = new SubLine(new Point2D(66, 3), new Point2D(66, 4), 1.0e-10);
+ final SubLine sub1 = new SubLine(Point2D.of(0, 1), Point2D.of(0, 2), 1.0e-10);
+ final SubLine sub2 = new SubLine(Point2D.of(66, 3), Point2D.of(66, 4), 1.0e-10);
Assert.assertNull(sub1.intersection(sub2, true));
Assert.assertNull(sub1.intersection(sub2, false));
}
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 1e7c0b9..00947b0 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
@@ -85,10 +85,10 @@ public abstract class ConvexHullGenerator2DAbstractTest {
@Test
public void testAllIdentical() {
final Collection<Point2D> points = new ArrayList<>();
- points.add(new Point2D(1, 1));
- points.add(new Point2D(1, 1));
- points.add(new Point2D(1, 1));
- points.add(new Point2D(1, 1));
+ points.add(Point2D.of(1, 1));
+ points.add(Point2D.of(1, 1));
+ points.add(Point2D.of(1, 1));
+ points.add(Point2D.of(1, 1));
final ConvexHull2D hull = generator.generate(points);
Assert.assertTrue(hull.getVertices().length == 1);
@@ -110,11 +110,11 @@ public abstract class ConvexHullGenerator2DAbstractTest {
@Test
public void testCollinearPoints() {
final Collection<Point2D> points = new ArrayList<>();
- points.add(new Point2D(1, 1));
- points.add(new Point2D(2, 2));
- points.add(new Point2D(2, 4));
- points.add(new Point2D(4, 1));
- points.add(new Point2D(10, 1));
+ points.add(Point2D.of(1, 1));
+ points.add(Point2D.of(2, 2));
+ points.add(Point2D.of(2, 4));
+ points.add(Point2D.of(4, 1));
+ points.add(Point2D.of(10, 1));
final ConvexHull2D hull = generator.generate(points);
checkConvexHull(points, hull);
@@ -123,11 +123,11 @@ public abstract class ConvexHullGenerator2DAbstractTest {
@Test
public void testCollinearPointsReverse() {
final Collection<Point2D> points = new ArrayList<>();
- points.add(new Point2D(1, 1));
- points.add(new Point2D(2, 2));
- points.add(new Point2D(2, 4));
- points.add(new Point2D(10, 1));
- points.add(new Point2D(4, 1));
+ points.add(Point2D.of(1, 1));
+ points.add(Point2D.of(2, 2));
+ points.add(Point2D.of(2, 4));
+ points.add(Point2D.of(10, 1));
+ points.add(Point2D.of(4, 1));
final ConvexHull2D hull = generator.generate(points);
checkConvexHull(points, hull);
@@ -136,11 +136,11 @@ public abstract class ConvexHullGenerator2DAbstractTest {
@Test
public void testCollinearPointsIncluded() {
final Collection<Point2D> points = new ArrayList<>();
- points.add(new Point2D(1, 1));
- points.add(new Point2D(2, 2));
- points.add(new Point2D(2, 4));
- points.add(new Point2D(4, 1));
- points.add(new Point2D(10, 1));
+ points.add(Point2D.of(1, 1));
+ points.add(Point2D.of(2, 2));
+ points.add(Point2D.of(2, 4));
+ points.add(Point2D.of(4, 1));
+ points.add(Point2D.of(10, 1));
final ConvexHull2D hull = createConvexHullGenerator(true).generate(points);
checkConvexHull(points, hull, true);
@@ -149,11 +149,11 @@ public abstract class ConvexHullGenerator2DAbstractTest {
@Test
public void testCollinearPointsIncludedReverse() {
final Collection<Point2D> points = new ArrayList<>();
- points.add(new Point2D(1, 1));
- points.add(new Point2D(2, 2));
- points.add(new Point2D(2, 4));
- points.add(new Point2D(10, 1));
- points.add(new Point2D(4, 1));
+ points.add(Point2D.of(1, 1));
+ points.add(Point2D.of(2, 2));
+ points.add(Point2D.of(2, 4));
+ points.add(Point2D.of(10, 1));
+ points.add(Point2D.of(4, 1));
final ConvexHull2D hull = createConvexHullGenerator(true).generate(points);
checkConvexHull(points, hull, true);
@@ -162,11 +162,11 @@ public abstract class ConvexHullGenerator2DAbstractTest {
@Test
public void testIdenticalPoints() {
final Collection<Point2D> points = new ArrayList<>();
- points.add(new Point2D(1, 1));
- points.add(new Point2D(2, 2));
- points.add(new Point2D(2, 4));
- points.add(new Point2D(4, 1));
- points.add(new Point2D(1, 1));
+ points.add(Point2D.of(1, 1));
+ points.add(Point2D.of(2, 2));
+ points.add(Point2D.of(2, 4));
+ points.add(Point2D.of(4, 1));
+ points.add(Point2D.of(1, 1));
final ConvexHull2D hull = generator.generate(points);
checkConvexHull(points, hull);
@@ -175,11 +175,11 @@ public abstract class ConvexHullGenerator2DAbstractTest {
@Test
public void testIdenticalPoints2() {
final Collection<Point2D> points = new ArrayList<>();
- points.add(new Point2D(1, 1));
- points.add(new Point2D(2, 2));
- points.add(new Point2D(2, 4));
- points.add(new Point2D(4, 1));
- points.add(new Point2D(1, 1));
+ points.add(Point2D.of(1, 1));
+ points.add(Point2D.of(2, 2));
+ points.add(Point2D.of(2, 4));
+ points.add(Point2D.of(4, 1));
+ points.add(Point2D.of(1, 1));
final ConvexHull2D hull = createConvexHullGenerator(true).generate(points);
checkConvexHull(points, hull, true);
@@ -188,11 +188,11 @@ public abstract class ConvexHullGenerator2DAbstractTest {
@Test
public void testClosePoints() {
final Collection<Point2D> points = new ArrayList<>();
- points.add(new Point2D(1, 1));
- points.add(new Point2D(2, 2));
- points.add(new Point2D(2, 4));
- points.add(new Point2D(4, 1));
- points.add(new Point2D(1.00001, 1));
+ points.add(Point2D.of(1, 1));
+ points.add(Point2D.of(2, 2));
+ points.add(Point2D.of(2, 4));
+ points.add(Point2D.of(4, 1));
+ points.add(Point2D.of(1.00001, 1));
final ConvexHull2D hull = generator.generate(points);
checkConvexHull(points, hull);
@@ -203,16 +203,16 @@ public abstract class ConvexHullGenerator2DAbstractTest {
// MATH-1135: check that collinear points on the hull are handled correctly
// when only a minimal hull shall be constructed
final Collection<Point2D> points = new ArrayList<>();
- points.add(new Point2D(7.3152, 34.7472));
- points.add(new Point2D(6.400799999999997, 34.747199999999985));
- points.add(new Point2D(5.486399999999997, 34.7472));
- points.add(new Point2D(4.876799999999999, 34.7472));
- points.add(new Point2D(4.876799999999999, 34.1376));
- points.add(new Point2D(4.876799999999999, 30.48));
- points.add(new Point2D(6.0959999999999965, 30.48));
- points.add(new Point2D(6.0959999999999965, 34.1376));
- points.add(new Point2D(7.315199999999996, 34.1376));
- points.add(new Point2D(7.3152, 30.48));
+ points.add(Point2D.of(7.3152, 34.7472));
+ points.add(Point2D.of(6.400799999999997, 34.747199999999985));
+ points.add(Point2D.of(5.486399999999997, 34.7472));
+ points.add(Point2D.of(4.876799999999999, 34.7472));
+ points.add(Point2D.of(4.876799999999999, 34.1376));
+ points.add(Point2D.of(4.876799999999999, 30.48));
+ points.add(Point2D.of(6.0959999999999965, 30.48));
+ points.add(Point2D.of(6.0959999999999965, 34.1376));
+ points.add(Point2D.of(7.315199999999996, 34.1376));
+ points.add(Point2D.of(7.3152, 30.48));
final ConvexHull2D hull = createConvexHullGenerator(false).generate(points);
checkConvexHull(points, hull);
@@ -227,10 +227,10 @@ public abstract class ConvexHullGenerator2DAbstractTest {
List<Point2D> points = new ArrayList<>();
// first case: 3 points are collinear
- points.add(new Point2D(16.078200000000184, -36.52519999989808));
- points.add(new Point2D(19.164300000000186, -36.52519999989808));
- points.add(new Point2D(19.1643, -25.28136477910407));
- points.add(new Point2D(19.1643, -17.678400000004157));
+ points.add(Point2D.of(16.078200000000184, -36.52519999989808));
+ points.add(Point2D.of(19.164300000000186, -36.52519999989808));
+ points.add(Point2D.of(19.1643, -25.28136477910407));
+ points.add(Point2D.of(19.1643, -17.678400000004157));
ConvexHull2D hull = createConvexHullGenerator(false).generate(points);
checkConvexHull(points, hull);
@@ -241,15 +241,15 @@ public abstract class ConvexHullGenerator2DAbstractTest {
points.clear();
// second case: multiple points are collinear
- points.add(new Point2D(0, -29.959696875));
- points.add(new Point2D(0, -31.621809375));
- points.add(new Point2D(0, -28.435696875));
- points.add(new Point2D(0, -33.145809375));
- points.add(new Point2D(3.048, -33.145809375));
- points.add(new Point2D(3.048, -31.621809375));
- points.add(new Point2D(3.048, -29.959696875));
- points.add(new Point2D(4.572, -33.145809375));
- points.add(new Point2D(4.572, -28.435696875));
+ points.add(Point2D.of(0, -29.959696875));
+ points.add(Point2D.of(0, -31.621809375));
+ points.add(Point2D.of(0, -28.435696875));
+ points.add(Point2D.of(0, -33.145809375));
+ points.add(Point2D.of(3.048, -33.145809375));
+ points.add(Point2D.of(3.048, -31.621809375));
+ points.add(Point2D.of(3.048, -29.959696875));
+ points.add(Point2D.of(4.572, -33.145809375));
+ points.add(Point2D.of(4.572, -28.435696875));
hull = createConvexHullGenerator(false).generate(points);
checkConvexHull(points, hull);
@@ -315,26 +315,26 @@ public abstract class ConvexHullGenerator2DAbstractTest {
{ 11, -1 }, { 11, 0 }, { 11, 1 } };
for (int[] line : data) {
- points.add(new Point2D(line[0], line[1]));
+ points.add(Point2D.of(line[0], line[1]));
}
Point2D[] referenceHull = new Point2D[] {
- new Point2D(-11.0, -1.0),
- new Point2D(-10.0, -3.0),
- new Point2D( -6.0, -7.0),
- new Point2D( -3.0, -8.0),
- new Point2D( 3.0, -8.0),
- new Point2D( 6.0, -7.0),
- new Point2D( 10.0, -3.0),
- new Point2D( 11.0, -1.0),
- new Point2D( 11.0, 1.0),
- new Point2D( 10.0, 3.0),
- new Point2D( 6.0, 7.0),
- new Point2D( 3.0, 8.0),
- new Point2D( -3.0, 8.0),
- new Point2D( -6.0, 7.0),
- new Point2D(-10.0, 3.0),
- new Point2D(-11.0, 1.0),
+ Point2D.of(-11.0, -1.0),
+ Point2D.of(-10.0, -3.0),
+ Point2D.of( -6.0, -7.0),
+ Point2D.of( -3.0, -8.0),
+ Point2D.of( 3.0, -8.0),
+ Point2D.of( 6.0, -7.0),
+ Point2D.of( 10.0, -3.0),
+ Point2D.of( 11.0, -1.0),
+ Point2D.of( 11.0, 1.0),
+ Point2D.of( 10.0, 3.0),
+ Point2D.of( 6.0, 7.0),
+ Point2D.of( 3.0, 8.0),
+ Point2D.of( -3.0, 8.0),
+ Point2D.of( -6.0, 7.0),
+ Point2D.of(-10.0, 3.0),
+ Point2D.of(-11.0, 1.0),
};
ConvexHull2D convHull = generator.generate(points);
@@ -361,7 +361,7 @@ public abstract class ConvexHullGenerator2DAbstractTest {
List<Point2D> points = new ArrayList<>(size);
// fill the cloud with a random distribution of points
for (int i = 0; i < size; i++) {
- points.add(new Point2D(random.nextDouble() * 2.0 - 1.0, random.nextDouble() * 2.0 - 1.0));
+ points.add(Point2D.of(random.nextDouble() * 2.0 - 1.0, random.nextDouble() * 2.0 - 1.0));
}
return points;
}
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 a19e99a..86f513d 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
@@ -38,14 +38,14 @@ public class MonotoneChainTest extends ConvexHullGenerator2DAbstractTest {
public void testConvergenceException() {
final Collection<Point2D> points = new ArrayList<>();
- points.add(new Point2D(1, 1));
- points.add(new Point2D(1, 5));
- points.add(new Point2D(0, 7));
- points.add(new Point2D(1, 10));
- points.add(new Point2D(1, 20));
- points.add(new Point2D(20, 20));
- points.add(new Point2D(20, 40));
- points.add(new Point2D(40, 1));
+ points.add(Point2D.of(1, 1));
+ points.add(Point2D.of(1, 5));
+ points.add(Point2D.of(0, 7));
+ points.add(Point2D.of(1, 10));
+ points.add(Point2D.of(1, 20));
+ points.add(Point2D.of(20, 20));
+ points.add(Point2D.of(20, 40));
+ points.add(Point2D.of(40, 1));
@SuppressWarnings("unused")
final ConvexHull2D hull = new MonotoneChain(true, 2).generate(points);
diff --git a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/SphericalCoordinates.java b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/SphericalCoordinates.java
index d8dc614..d9d959f 100644
--- a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/SphericalCoordinates.java
+++ b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/SphericalCoordinates.java
@@ -110,7 +110,7 @@ public class SphericalCoordinates implements Serializable {
this.phi = phi;
// Cartesian coordinates
- this.v = new Vector3D(r * cosTheta * sinPhi,
+ this.v = Vector3D.of(r * cosTheta * sinPhi,
r * sinTheta * sinPhi,
r * cosPhi);
@@ -386,7 +386,7 @@ public class SphericalCoordinates implements Serializable {
* @return replacement {@link SphericalCoordinates}
*/
private Object readResolve() {
- return new SphericalCoordinates(new Vector3D(x, y, z));
+ return new SphericalCoordinates(Vector3D.of(x, y, z));
}
}
diff --git a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/S1Point.java b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/S1Point.java
index da4f85c..8f7b19c 100644
--- a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/S1Point.java
+++ b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/S1Point.java
@@ -46,7 +46,7 @@ public class S1Point implements Point<S1Point> {
*/
public S1Point(final double alpha) {
this(PlaneAngleRadians.normalizeBetweenZeroAndTwoPi(alpha),
- new Vector2D(Math.cos(alpha), Math.sin(alpha)));
+ Vector2D.of(Math.cos(alpha), Math.sin(alpha)));
}
/** Build a point from its internal components.
diff --git a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/S2Point.java b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/S2Point.java
index 4542e26..567e666 100644
--- a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/S2Point.java
+++ b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/S2Point.java
@@ -118,7 +118,7 @@ public class S2Point implements Point<S2Point> {
final double cosPhi = Math.cos(phi);
final double sinPhi = Math.sin(phi);
- return new Vector3D(cosTheta * sinPhi, sinTheta * sinPhi, cosPhi);
+ return Vector3D.of(cosTheta * sinPhi, sinTheta * sinPhi, cosPhi);
}
diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/SphericalCoordinatesTest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/SphericalCoordinatesTest.java
index 892814b..db3b76e 100644
--- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/SphericalCoordinatesTest.java
+++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/SphericalCoordinatesTest.java
@@ -28,43 +28,43 @@ public class SphericalCoordinatesTest {
public void testCoordinatesStoC() {
double piO2 = 0.5 * Math.PI;
SphericalCoordinates sc1 = new SphericalCoordinates(2.0, 0, piO2);
- Assert.assertEquals(0, sc1.getCartesian().distance(new Vector3D(2, 0, 0)), 1.0e-10);
+ Assert.assertEquals(0, sc1.getCartesian().distance(Vector3D.of(2, 0, 0)), 1.0e-10);
SphericalCoordinates sc2 = new SphericalCoordinates(2.0, piO2, piO2);
- Assert.assertEquals(0, sc2.getCartesian().distance(new Vector3D(0, 2, 0)), 1.0e-10);
+ Assert.assertEquals(0, sc2.getCartesian().distance(Vector3D.of(0, 2, 0)), 1.0e-10);
SphericalCoordinates sc3 = new SphericalCoordinates(2.0, Math.PI, piO2);
- Assert.assertEquals(0, sc3.getCartesian().distance(new Vector3D(-2, 0, 0)), 1.0e-10);
+ Assert.assertEquals(0, sc3.getCartesian().distance(Vector3D.of(-2, 0, 0)), 1.0e-10);
SphericalCoordinates sc4 = new SphericalCoordinates(2.0, -piO2, piO2);
- Assert.assertEquals(0, sc4.getCartesian().distance(new Vector3D(0, -2, 0)), 1.0e-10);
+ Assert.assertEquals(0, sc4.getCartesian().distance(Vector3D.of(0, -2, 0)), 1.0e-10);
SphericalCoordinates sc5 = new SphericalCoordinates(2.0, 1.23456, 0);
- Assert.assertEquals(0, sc5.getCartesian().distance(new Vector3D(0, 0, 2)), 1.0e-10);
+ Assert.assertEquals(0, sc5.getCartesian().distance(Vector3D.of(0, 0, 2)), 1.0e-10);
SphericalCoordinates sc6 = new SphericalCoordinates(2.0, 6.54321, Math.PI);
- Assert.assertEquals(0, sc6.getCartesian().distance(new Vector3D(0, 0, -2)), 1.0e-10);
+ Assert.assertEquals(0, sc6.getCartesian().distance(Vector3D.of(0, 0, -2)), 1.0e-10);
}
@Test
public void testCoordinatesCtoS() {
double piO2 = 0.5 * Math.PI;
- SphericalCoordinates sc1 = new SphericalCoordinates(new Vector3D(2, 0, 0));
+ SphericalCoordinates sc1 = new SphericalCoordinates(Vector3D.of(2, 0, 0));
Assert.assertEquals(2, sc1.getR(), 1.0e-10);
Assert.assertEquals(0, sc1.getTheta(), 1.0e-10);
Assert.assertEquals(piO2, sc1.getPhi(), 1.0e-10);
- SphericalCoordinates sc2 = new SphericalCoordinates(new Vector3D(0, 2, 0));
+ SphericalCoordinates sc2 = new SphericalCoordinates(Vector3D.of(0, 2, 0));
Assert.assertEquals(2, sc2.getR(), 1.0e-10);
Assert.assertEquals(piO2, sc2.getTheta(), 1.0e-10);
Assert.assertEquals(piO2, sc2.getPhi(), 1.0e-10);
- SphericalCoordinates sc3 = new SphericalCoordinates(new Vector3D(-2, 0, 0));
+ SphericalCoordinates sc3 = new SphericalCoordinates(Vector3D.of(-2, 0, 0));
Assert.assertEquals(2, sc3.getR(), 1.0e-10);
Assert.assertEquals(Math.PI, sc3.getTheta(), 1.0e-10);
Assert.assertEquals(piO2, sc3.getPhi(), 1.0e-10);
- SphericalCoordinates sc4 = new SphericalCoordinates(new Vector3D(0, -2, 0));
+ SphericalCoordinates sc4 = new SphericalCoordinates(Vector3D.of(0, -2, 0));
Assert.assertEquals(2, sc4.getR(), 1.0e-10);
Assert.assertEquals(-piO2, sc4.getTheta(), 1.0e-10);
Assert.assertEquals(piO2, sc4.getPhi(), 1.0e-10);
- SphericalCoordinates sc5 = new SphericalCoordinates(new Vector3D(0, 0, 2));
+ SphericalCoordinates sc5 = new SphericalCoordinates(Vector3D.of(0, 0, 2));
Assert.assertEquals(2, sc5.getR(), 1.0e-10);
// don't check theta on poles, as it is singular
Assert.assertEquals(0, sc5.getPhi(), 1.0e-10);
- SphericalCoordinates sc6 = new SphericalCoordinates(new Vector3D(0, 0, -2));
+ SphericalCoordinates sc6 = new SphericalCoordinates(Vector3D.of(0, 0, -2));
Assert.assertEquals(2, sc6.getR(), 1.0e-10);
// don't check theta on poles, as it is singular
Assert.assertEquals(Math.PI, sc6.getPhi(), 1.0e-10);
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 313e455..b5a1211 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
@@ -110,7 +110,7 @@ public class SphericalTestUtils {
@Override
public Circle parseHyperplane()
throws IOException, ParseException {
- return new Circle(new Vector3D(getNumber(), getNumber(), getNumber()), getNumber());
+ return new Circle(Vector3D.of(getNumber(), getNumber(), getNumber()), getNumber());
}
};
diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/CircleTest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/CircleTest.java
index 7458ee9..a958dcf 100644
--- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/CircleTest.java
+++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/CircleTest.java
@@ -36,7 +36,7 @@ public class CircleTest {
@Test
public void testEquator() {
- Circle circle = new Circle(new Vector3D(0, 0, 1000), 1.0e-10).copySelf();
+ Circle circle = new Circle(Vector3D.of(0, 0, 1000), 1.0e-10).copySelf();
Assert.assertEquals(Vector3D.PLUS_Z, circle.getPole());
Assert.assertEquals(1.0e-10, circle.getTolerance(), 1.0e-20);
circle.revertSelf();
@@ -83,7 +83,7 @@ public class CircleTest {
@Test
public void testPhase() {
Circle circle = new Circle(new S2Point(1.2, 2.5), new S2Point(-4.3, 0), 1.0e-10);
- Vector3D p = new Vector3D(1, 2, -4);
+ Vector3D p = Vector3D.of(1, 2, -4);
Vector3D samePhase = circle.getPointAt(circle.getPhase(p));
Assert.assertEquals(0.0,
Vector3D.angle(Vector3D.crossProduct(circle.getPole(), p),
@@ -101,7 +101,7 @@ public class CircleTest {
Circle circle = new Circle(new S2Point(1.2, 2.5), new S2Point(-4.3, 0), 1.0e-10);
Assert.assertEquals(0.0, circle.toSubSpace(new S2Point(circle.getXAxis())).getAlpha(), 1.0e-10);
Assert.assertEquals(0.5 * Math.PI, circle.toSubSpace(new S2Point(circle.getYAxis())).getAlpha(), 1.0e-10);
- Vector3D p = new Vector3D(1, 2, -4);
+ Vector3D p = Vector3D.of(1, 2, -4);
Assert.assertEquals(circle.getPhase(p), circle.toSubSpace(new S2Point(p)).getAlpha(), 1.0e-10);
}
diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/SphericalPolygonsSetTest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/SphericalPolygonsSetTest.java
index 0152188..0f52671 100644
--- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/SphericalPolygonsSetTest.java
+++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/SphericalPolygonsSetTest.java
@@ -156,7 +156,7 @@ public class SphericalPolygonsSetTest {
Assert.assertEquals(3, count);
Assert.assertEquals(0.0,
- octant.getBarycenter().distance(new S2Point(new Vector3D(1, 1, 1))),
+ octant.getBarycenter().distance(new S2Point(Vector3D.of(1, 1, 1))),
1.0e-10);
Assert.assertEquals(0.5 * Math.PI, octant.getSize(), 1.0e-10);
@@ -166,7 +166,7 @@ public class SphericalPolygonsSetTest {
EnclosingBall<S2Point> reversedCap =
((SphericalPolygonsSet) factory.getComplement(octant)).getEnclosingCap();
- Assert.assertEquals(0, reversedCap.getCenter().distance(new S2Point(new Vector3D(-1, -1, -1))), 1.0e-10);
+ Assert.assertEquals(0, reversedCap.getCenter().distance(new S2Point(Vector3D.of(-1, -1, -1))), 1.0e-10);
Assert.assertEquals(Math.PI - Math.asin(1.0 / Math.sqrt(3)), reversedCap.getRadius(), 1.0e-10);
}
@@ -274,14 +274,14 @@ public class SphericalPolygonsSetTest {
boundary.add(create(Vector3D.PLUS_Z, Vector3D.MINUS_Y, Vector3D.PLUS_X, tol, 0.0, 0.5 * Math.PI));
SphericalPolygonsSet polygon = new SphericalPolygonsSet(boundary, tol);
- Assert.assertEquals(Location.OUTSIDE, polygon.checkPoint(new S2Point(new Vector3D( 1, 1, 1).normalize())));
- Assert.assertEquals(Location.INSIDE, polygon.checkPoint(new S2Point(new Vector3D(-1, 1, 1).normalize())));
- Assert.assertEquals(Location.INSIDE, polygon.checkPoint(new S2Point(new Vector3D(-1, -1, 1).normalize())));
- Assert.assertEquals(Location.INSIDE, polygon.checkPoint(new S2Point(new Vector3D( 1, -1, 1).normalize())));
- Assert.assertEquals(Location.OUTSIDE, polygon.checkPoint(new S2Point(new Vector3D( 1, 1, -1).normalize())));
- Assert.assertEquals(Location.OUTSIDE, polygon.checkPoint(new S2Point(new Vector3D(-1, 1, -1).normalize())));
- Assert.assertEquals(Location.INSIDE, polygon.checkPoint(new S2Point(new Vector3D(-1, -1, -1).normalize())));
- Assert.assertEquals(Location.OUTSIDE, polygon.checkPoint(new S2Point(new Vector3D( 1, -1, -1).normalize())));
+ Assert.assertEquals(Location.OUTSIDE, polygon.checkPoint(new S2Point(Vector3D.of( 1, 1, 1).normalize())));
+ Assert.assertEquals(Location.INSIDE, polygon.checkPoint(new S2Point(Vector3D.of(-1, 1, 1).normalize())));
+ Assert.assertEquals(Location.INSIDE, polygon.checkPoint(new S2Point(Vector3D.of(-1, -1, 1).normalize())));
+ Assert.assertEquals(Location.INSIDE, polygon.checkPoint(new S2Point(Vector3D.of( 1, -1, 1).normalize())));
+ Assert.assertEquals(Location.OUTSIDE, polygon.checkPoint(new S2Point(Vector3D.of( 1, 1, -1).normalize())));
+ Assert.assertEquals(Location.OUTSIDE, polygon.checkPoint(new S2Point(Vector3D.of(-1, 1, -1).normalize())));
+ Assert.assertEquals(Location.INSIDE, polygon.checkPoint(new S2Point(Vector3D.of(-1, -1, -1).normalize())));
+ Assert.assertEquals(Location.OUTSIDE, polygon.checkPoint(new S2Point(Vector3D.of( 1, -1, -1).normalize())));
Assert.assertEquals(Geometry.TWO_PI, polygon.getSize(), 1.0e-10);
Assert.assertEquals(3 * Math.PI, polygon.getBoundarySize(), 1.0e-10);
@@ -366,7 +366,7 @@ public class SphericalPolygonsSetTest {
public void testPartWithHole() {
double tol = 0.01;
double alpha = 0.7;
- S2Point center = new S2Point(new Vector3D(1, 1, 1));
+ S2Point center = new S2Point(Vector3D.of(1, 1, 1));
SphericalPolygonsSet hexa = new SphericalPolygonsSet(center.getVector(), Vector3D.PLUS_Z, alpha, 6, tol);
SphericalPolygonsSet hole = new SphericalPolygonsSet(tol,
new S2Point(Math.PI / 6, Math.PI / 3),
@@ -395,7 +395,7 @@ public class SphericalPolygonsSetTest {
@Test
public void testConcentricSubParts() {
double tol = 0.001;
- Vector3D center = new Vector3D(1, 1, 1);
+ Vector3D center = Vector3D.of(1, 1, 1);
SphericalPolygonsSet hexaOut = new SphericalPolygonsSet(center, Vector3D.PLUS_Z, 0.9, 6, tol);
SphericalPolygonsSet hexaIn = new SphericalPolygonsSet(center, Vector3D.PLUS_Z, 0.8, 6, tol);
SphericalPolygonsSet pentaOut = new SphericalPolygonsSet(center, Vector3D.PLUS_Z, 0.7, 5, tol);
diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/SubCircleTest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/SubCircleTest.java
index 6cd5618..69a3950 100644
--- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/SubCircleTest.java
+++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/SubCircleTest.java
@@ -110,9 +110,9 @@ public class SubCircleTest {
public void testSideSplitConsistency() {
double tolerance = 1.0e-6;
- Circle hyperplane = new Circle(new Vector3D(9.738804529764676E-5, -0.6772824575010357, -0.7357230887208355),
+ Circle hyperplane = new Circle(Vector3D.of(9.738804529764676E-5, -0.6772824575010357, -0.7357230887208355),
tolerance);
- SubCircle sub = new SubCircle(new Circle(new Vector3D(2.1793884139073498E-4, 0.9790647032675541, -0.20354915700704285),
+ SubCircle sub = new SubCircle(new Circle(Vector3D.of(2.1793884139073498E-4, 0.9790647032675541, -0.20354915700704285),
tolerance),
new ArcsSet(4.7121441684170700, 4.7125386635004760, tolerance));
SplitSubHyperplane<S2Point> split = sub.split(hyperplane);