http://git-wip-us.apache.org/repos/asf/commons-math/blob/b815d2af/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/SegmentTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/SegmentTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/SegmentTest.java index 6c2ea15..41f9d77 100644 --- a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/SegmentTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/SegmentTest.java @@ -18,7 +18,7 @@ package org.apache.commons.math4.geometry.euclidean.twod; import org.apache.commons.math4.geometry.euclidean.twod.Line; import org.apache.commons.math4.geometry.euclidean.twod.Segment; -import org.apache.commons.math4.geometry.euclidean.twod.Vector2D; +import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D; import org.apache.commons.math4.util.FastMath; import org.junit.Assert; import org.junit.Test; @@ -27,20 +27,20 @@ public class SegmentTest { @Test public void testDistance() { - Vector2D start = new Vector2D(2, 2); - Vector2D end = new Vector2D(-2, -2); + Coordinates2D start = new Coordinates2D(2, 2); + Coordinates2D end = new Coordinates2D(-2, -2); Segment segment = new Segment(start, end, new Line(start, end, 1.0e-10)); // distance to center of segment - Assert.assertEquals(FastMath.sqrt(2), segment.distance(new Vector2D(1, -1)), 1.0e-10); + Assert.assertEquals(FastMath.sqrt(2), segment.distance(new Coordinates2D(1, -1)), 1.0e-10); // distance a point on segment - Assert.assertEquals(FastMath.sin(Math.PI / 4.0), segment.distance(new Vector2D(0, -1)), 1.0e-10); + Assert.assertEquals(FastMath.sin(Math.PI / 4.0), segment.distance(new Coordinates2D(0, -1)), 1.0e-10); // distance to end point - Assert.assertEquals(FastMath.sqrt(8), segment.distance(new Vector2D(0, 4)), 1.0e-10); + Assert.assertEquals(FastMath.sqrt(8), segment.distance(new Coordinates2D(0, 4)), 1.0e-10); // distance to start point - Assert.assertEquals(FastMath.sqrt(8), segment.distance(new Vector2D(0, -4)), 1.0e-10); + Assert.assertEquals(FastMath.sqrt(8), segment.distance(new Coordinates2D(0, -4)), 1.0e-10); } }
http://git-wip-us.apache.org/repos/asf/commons-math/blob/b815d2af/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/SubLineTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/SubLineTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/SubLineTest.java index 249c5d7..c59ab8c 100644 --- a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/SubLineTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/SubLineTest.java @@ -23,7 +23,7 @@ import org.apache.commons.math4.geometry.euclidean.oned.IntervalsSet; import org.apache.commons.math4.geometry.euclidean.twod.Line; import org.apache.commons.math4.geometry.euclidean.twod.Segment; import org.apache.commons.math4.geometry.euclidean.twod.SubLine; -import org.apache.commons.math4.geometry.euclidean.twod.Vector2D; +import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D; import org.apache.commons.math4.geometry.partitioning.RegionFactory; import org.junit.Assert; import org.junit.Test; @@ -32,19 +32,19 @@ public class SubLineTest { @Test public void testEndPoints() { - Vector2D p1 = new Vector2D(-1, -7); - Vector2D p2 = new Vector2D(7, -1); + Coordinates2D p1 = new Coordinates2D(-1, -7); + Coordinates2D p2 = new Coordinates2D(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 Vector2D(-1, -7).distance(segments.get(0).getStart()), 1.0e-10); - Assert.assertEquals(0.0, new Vector2D( 7, -1).distance(segments.get(0).getEnd()), 1.0e-10); + Assert.assertEquals(0.0, new Coordinates2D(-1, -7).distance(segments.get(0).getStart()), 1.0e-10); + Assert.assertEquals(0.0, new Coordinates2D( 7, -1).distance(segments.get(0).getEnd()), 1.0e-10); } @Test public void testNoEndPoints() { - SubLine wholeLine = new Line(new Vector2D(-1, 7), new Vector2D(7, 1), 1.0e-10).wholeHyperplane(); + SubLine wholeLine = new Line(new Coordinates2D(-1, 7), new Coordinates2D(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()) && @@ -59,7 +59,7 @@ public class SubLineTest { @Test public void testNoSegments() { - SubLine empty = new SubLine(new Line(new Vector2D(-1, -7), new Vector2D(7, -1), 1.0e-10), + SubLine empty = new SubLine(new Line(new Coordinates2D(-1, -7), new Coordinates2D(7, -1), 1.0e-10), new RegionFactory<Euclidean1D>().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 Vector2D(-1, -7), new Vector2D(7, -1), 1.0e-10), + SubLine twoSubs = new SubLine(new Line(new Coordinates2D(-1, -7), new Coordinates2D(7, -1), 1.0e-10), new RegionFactory<Euclidean1D>().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 Vector2D(-1, -7), new Vector2D(7, -1), 1.0e-10), + SubLine empty = new SubLine(new Line(new Coordinates2D(-1, -7), new Coordinates2D(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()); @@ -84,16 +84,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 Vector2D(3, -4).distance(segments.get(0).getEnd()), 1.0e-10); + Assert.assertEquals(0.0, new Coordinates2D(3, -4).distance(segments.get(0).getEnd()), 1.0e-10); } @Test public void testHalfInfinitePos() { - SubLine empty = new SubLine(new Line(new Vector2D(-1, -7), new Vector2D(7, -1), 1.0e-10), + SubLine empty = new SubLine(new Line(new Coordinates2D(-1, -7), new Coordinates2D(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 Vector2D(3, -4).distance(segments.get(0).getStart()), 1.0e-10); + Assert.assertEquals(0.0, new Coordinates2D(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()) && @@ -102,56 +102,56 @@ public class SubLineTest { @Test public void testIntersectionInsideInside() { - SubLine sub1 = new SubLine(new Vector2D(1, 1), new Vector2D(3, 1), 1.0e-10); - SubLine sub2 = new SubLine(new Vector2D(2, 0), new Vector2D(2, 2), 1.0e-10); - Assert.assertEquals(0.0, new Vector2D(2, 1).distance(sub1.intersection(sub2, true)), 1.0e-12); - Assert.assertEquals(0.0, new Vector2D(2, 1).distance(sub1.intersection(sub2, false)), 1.0e-12); + SubLine sub1 = new SubLine(new Coordinates2D(1, 1), new Coordinates2D(3, 1), 1.0e-10); + SubLine sub2 = new SubLine(new Coordinates2D(2, 0), new Coordinates2D(2, 2), 1.0e-10); + Assert.assertEquals(0.0, new Coordinates2D(2, 1).distance(sub1.intersection(sub2, true)), 1.0e-12); + Assert.assertEquals(0.0, new Coordinates2D(2, 1).distance(sub1.intersection(sub2, false)), 1.0e-12); } @Test public void testIntersectionInsideBoundary() { - SubLine sub1 = new SubLine(new Vector2D(1, 1), new Vector2D(3, 1), 1.0e-10); - SubLine sub2 = new SubLine(new Vector2D(2, 0), new Vector2D(2, 1), 1.0e-10); - Assert.assertEquals(0.0, new Vector2D(2, 1).distance(sub1.intersection(sub2, true)), 1.0e-12); + SubLine sub1 = new SubLine(new Coordinates2D(1, 1), new Coordinates2D(3, 1), 1.0e-10); + SubLine sub2 = new SubLine(new Coordinates2D(2, 0), new Coordinates2D(2, 1), 1.0e-10); + Assert.assertEquals(0.0, new Coordinates2D(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 Vector2D(1, 1), new Vector2D(3, 1), 1.0e-10); - SubLine sub2 = new SubLine(new Vector2D(2, 0), new Vector2D(2, 0.5), 1.0e-10); + SubLine sub1 = new SubLine(new Coordinates2D(1, 1), new Coordinates2D(3, 1), 1.0e-10); + SubLine sub2 = new SubLine(new Coordinates2D(2, 0), new Coordinates2D(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 Vector2D(1, 1), new Vector2D(2, 1), 1.0e-10); - SubLine sub2 = new SubLine(new Vector2D(2, 0), new Vector2D(2, 1), 1.0e-10); - Assert.assertEquals(0.0, new Vector2D(2, 1).distance(sub1.intersection(sub2, true)), 1.0e-12); + SubLine sub1 = new SubLine(new Coordinates2D(1, 1), new Coordinates2D(2, 1), 1.0e-10); + SubLine sub2 = new SubLine(new Coordinates2D(2, 0), new Coordinates2D(2, 1), 1.0e-10); + Assert.assertEquals(0.0, new Coordinates2D(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 Vector2D(1, 1), new Vector2D(2, 1), 1.0e-10); - SubLine sub2 = new SubLine(new Vector2D(2, 0), new Vector2D(2, 0.5), 1.0e-10); + SubLine sub1 = new SubLine(new Coordinates2D(1, 1), new Coordinates2D(2, 1), 1.0e-10); + SubLine sub2 = new SubLine(new Coordinates2D(2, 0), new Coordinates2D(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 Vector2D(1, 1), new Vector2D(1.5, 1), 1.0e-10); - SubLine sub2 = new SubLine(new Vector2D(2, 0), new Vector2D(2, 0.5), 1.0e-10); + SubLine sub1 = new SubLine(new Coordinates2D(1, 1), new Coordinates2D(1.5, 1), 1.0e-10); + SubLine sub2 = new SubLine(new Coordinates2D(2, 0), new Coordinates2D(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 Vector2D(0, 1), new Vector2D(0, 2), 1.0e-10); - final SubLine sub2 = new SubLine(new Vector2D(66, 3), new Vector2D(66, 4), 1.0e-10); + final SubLine sub1 = new SubLine(new Coordinates2D(0, 1), new Coordinates2D(0, 2), 1.0e-10); + final SubLine sub2 = new SubLine(new Coordinates2D(66, 3), new Coordinates2D(66, 4), 1.0e-10); Assert.assertNull(sub1.intersection(sub2, true)); Assert.assertNull(sub1.intersection(sub2, false)); } http://git-wip-us.apache.org/repos/asf/commons-math/blob/b815d2af/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2DFormatAbstractTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2DFormatAbstractTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2DFormatAbstractTest.java index ef1c765..491a04d 100644 --- a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2DFormatAbstractTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2DFormatAbstractTest.java @@ -22,7 +22,7 @@ import java.text.ParsePosition; import java.util.Locale; import org.apache.commons.math4.exception.MathParseException; -import org.apache.commons.math4.geometry.euclidean.twod.Vector2D; +import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D; import org.apache.commons.math4.geometry.euclidean.twod.Vector2DFormat; import org.junit.Assert; import org.junit.Test; @@ -45,7 +45,7 @@ public abstract class Vector2DFormatAbstractTest { @Test public void testSimpleNoDecimals() { - Vector2D c = new Vector2D(1, 1); + Coordinates2D c = new Coordinates2D(1, 1); String expected = "{1; 1}"; String actual = vector2DFormat.format(c); Assert.assertEquals(expected, actual); @@ -53,7 +53,7 @@ public abstract class Vector2DFormatAbstractTest { @Test public void testSimpleWithDecimals() { - Vector2D c = new Vector2D(1.23, 1.43); + Coordinates2D c = new Coordinates2D(1.23, 1.43); String expected = "{1" + getDecimalCharacter() + "23; 1" + getDecimalCharacter() + @@ -64,7 +64,7 @@ public abstract class Vector2DFormatAbstractTest { @Test public void testSimpleWithDecimalsTrunc() { - Vector2D c = new Vector2D(1.232323232323, 1.434343434343); + Coordinates2D c = new Coordinates2D(1.232323232323, 1.434343434343); String expected = "{1" + getDecimalCharacter() + "2323232323; 1" + getDecimalCharacter() + @@ -75,7 +75,7 @@ public abstract class Vector2DFormatAbstractTest { @Test public void testNegativeX() { - Vector2D c = new Vector2D(-1.232323232323, 1.43); + Coordinates2D c = new Coordinates2D(-1.232323232323, 1.43); String expected = "{-1" + getDecimalCharacter() + "2323232323; 1" + getDecimalCharacter() + @@ -86,7 +86,7 @@ public abstract class Vector2DFormatAbstractTest { @Test public void testNegativeY() { - Vector2D c = new Vector2D(1.23, -1.434343434343); + Coordinates2D c = new Coordinates2D(1.23, -1.434343434343); String expected = "{1" + getDecimalCharacter() + "23; -1" + getDecimalCharacter() + @@ -97,7 +97,7 @@ public abstract class Vector2DFormatAbstractTest { @Test public void testNegativeZ() { - Vector2D c = new Vector2D(1.23, 1.43); + Coordinates2D c = new Coordinates2D(1.23, 1.43); String expected = "{1" + getDecimalCharacter() + "23; 1" + getDecimalCharacter() + @@ -108,7 +108,7 @@ public abstract class Vector2DFormatAbstractTest { @Test public void testNonDefaultSetting() { - Vector2D c = new Vector2D(1, 1); + Coordinates2D c = new Coordinates2D(1, 1); String expected = "[1 : 1]"; String actual = vector2DFormatSquare.format(c); Assert.assertEquals(expected, actual); @@ -119,7 +119,7 @@ public abstract class Vector2DFormatAbstractTest { Locale defaultLocal = Locale.getDefault(); Locale.setDefault(getLocale()); - Vector2D c = new Vector2D(232.22222222222, -342.3333333333); + Coordinates2D c = new Coordinates2D(232.22222222222, -342.3333333333); String expected = "{232" + getDecimalCharacter() + "2222222222; -342" + getDecimalCharacter() + @@ -132,7 +132,7 @@ public abstract class Vector2DFormatAbstractTest { @Test public void testNan() { - Vector2D c = Vector2D.NaN; + Coordinates2D c = Coordinates2D.NaN; String expected = "{(NaN); (NaN)}"; String actual = vector2DFormat.format(c); Assert.assertEquals(expected, actual); @@ -140,7 +140,7 @@ public abstract class Vector2DFormatAbstractTest { @Test public void testPositiveInfinity() { - Vector2D c = Vector2D.POSITIVE_INFINITY; + Coordinates2D c = Coordinates2D.POSITIVE_INFINITY; String expected = "{(Infinity); (Infinity)}"; String actual = vector2DFormat.format(c); Assert.assertEquals(expected, actual); @@ -148,7 +148,7 @@ public abstract class Vector2DFormatAbstractTest { @Test public void tesNegativeInfinity() { - Vector2D c = Vector2D.NEGATIVE_INFINITY; + Coordinates2D c = Coordinates2D.NEGATIVE_INFINITY; String expected = "{(-Infinity); (-Infinity)}"; String actual = vector2DFormat.format(c); Assert.assertEquals(expected, actual); @@ -157,14 +157,14 @@ public abstract class Vector2DFormatAbstractTest { @Test public void testParseSimpleNoDecimals() throws MathParseException { String source = "{1; 1}"; - Vector2D expected = new Vector2D(1, 1); - Vector2D actual = vector2DFormat.parse(source); + Coordinates2D expected = new Coordinates2D(1, 1); + Coordinates2D actual = vector2DFormat.parse(source); Assert.assertEquals(expected, actual); } @Test public void testParseIgnoredWhitespace() { - Vector2D expected = new Vector2D(1, 1); + Coordinates2D expected = new Coordinates2D(1, 1); ParsePosition pos1 = new ParsePosition(0); String source1 = "{1;1}"; Assert.assertEquals(expected, vector2DFormat.parse(source1, pos1)); @@ -181,8 +181,8 @@ public abstract class Vector2DFormatAbstractTest { "{1" + getDecimalCharacter() + "23; 1" + getDecimalCharacter() + "43}"; - Vector2D expected = new Vector2D(1.23, 1.43); - Vector2D actual = vector2DFormat.parse(source); + Coordinates2D expected = new Coordinates2D(1.23, 1.43); + Coordinates2D actual = vector2DFormat.parse(source); Assert.assertEquals(expected, actual); } @@ -192,8 +192,8 @@ public abstract class Vector2DFormatAbstractTest { "{1" + getDecimalCharacter() + "2323; 1" + getDecimalCharacter() + "4343}"; - Vector2D expected = new Vector2D(1.2323, 1.4343); - Vector2D actual = vector2DFormat.parse(source); + Coordinates2D expected = new Coordinates2D(1.2323, 1.4343); + Coordinates2D actual = vector2DFormat.parse(source); Assert.assertEquals(expected, actual); } @@ -203,8 +203,8 @@ public abstract class Vector2DFormatAbstractTest { "{-1" + getDecimalCharacter() + "2323; 1" + getDecimalCharacter() + "4343}"; - Vector2D expected = new Vector2D(-1.2323, 1.4343); - Vector2D actual = vector2DFormat.parse(source); + Coordinates2D expected = new Coordinates2D(-1.2323, 1.4343); + Coordinates2D actual = vector2DFormat.parse(source); Assert.assertEquals(expected, actual); } @@ -214,8 +214,8 @@ public abstract class Vector2DFormatAbstractTest { "{1" + getDecimalCharacter() + "2323; -1" + getDecimalCharacter() + "4343}"; - Vector2D expected = new Vector2D(1.2323, -1.4343); - Vector2D actual = vector2DFormat.parse(source); + Coordinates2D expected = new Coordinates2D(1.2323, -1.4343); + Coordinates2D actual = vector2DFormat.parse(source); Assert.assertEquals(expected, actual); } @@ -225,8 +225,8 @@ public abstract class Vector2DFormatAbstractTest { "{1" + getDecimalCharacter() + "2323; 1" + getDecimalCharacter() + "4343}"; - Vector2D expected = new Vector2D(1.2323, 1.4343); - Vector2D actual = vector2DFormat.parse(source); + Coordinates2D expected = new Coordinates2D(1.2323, 1.4343); + Coordinates2D actual = vector2DFormat.parse(source); Assert.assertEquals(expected, actual); } @@ -236,8 +236,8 @@ public abstract class Vector2DFormatAbstractTest { "{-1" + getDecimalCharacter() + "2323; -1" + getDecimalCharacter() + "4343}"; - Vector2D expected = new Vector2D(-1.2323, -1.4343); - Vector2D actual = vector2DFormat.parse(source); + Coordinates2D expected = new Coordinates2D(-1.2323, -1.4343); + Coordinates2D actual = vector2DFormat.parse(source); Assert.assertEquals(expected, actual); } @@ -247,8 +247,8 @@ public abstract class Vector2DFormatAbstractTest { "{0" + getDecimalCharacter() + "0; -1" + getDecimalCharacter() + "4343}"; - Vector2D expected = new Vector2D(0.0, -1.4343); - Vector2D actual = vector2DFormat.parse(source); + Coordinates2D expected = new Coordinates2D(0.0, -1.4343); + Coordinates2D actual = vector2DFormat.parse(source); Assert.assertEquals(expected, actual); } @@ -258,30 +258,30 @@ public abstract class Vector2DFormatAbstractTest { "[1" + getDecimalCharacter() + "2323 : 1" + getDecimalCharacter() + "4343]"; - Vector2D expected = new Vector2D(1.2323, 1.4343); - Vector2D actual = vector2DFormatSquare.parse(source); + Coordinates2D expected = new Coordinates2D(1.2323, 1.4343); + Coordinates2D actual = vector2DFormatSquare.parse(source); Assert.assertEquals(expected, actual); } @Test public void testParseNan() throws MathParseException { String source = "{(NaN); (NaN)}"; - Vector2D actual = vector2DFormat.parse(source); - Assert.assertEquals(Vector2D.NaN, actual); + Coordinates2D actual = vector2DFormat.parse(source); + Assert.assertEquals(Coordinates2D.NaN, actual); } @Test public void testParsePositiveInfinity() throws MathParseException { String source = "{(Infinity); (Infinity)}"; - Vector2D actual = vector2DFormat.parse(source); - Assert.assertEquals(Vector2D.POSITIVE_INFINITY, actual); + Coordinates2D actual = vector2DFormat.parse(source); + Assert.assertEquals(Coordinates2D.POSITIVE_INFINITY, actual); } @Test public void testParseNegativeInfinity() throws MathParseException { String source = "{(-Infinity); (-Infinity)}"; - Vector2D actual = vector2DFormat.parse(source); - Assert.assertEquals(Vector2D.NEGATIVE_INFINITY, actual); + Coordinates2D actual = vector2DFormat.parse(source); + Assert.assertEquals(Coordinates2D.NEGATIVE_INFINITY, actual); } @Test http://git-wip-us.apache.org/repos/asf/commons-math/blob/b815d2af/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2DTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2DTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2DTest.java index 18c3649..77b68d1 100644 --- a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2DTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2DTest.java @@ -28,11 +28,11 @@ public class Vector2DTest { @Test public void testScaledVectorTripleConstructor() { - Vector2D oneOne = new Vector2D(1.0,1.0); - Vector2D oneTwo = new Vector2D(1.0,2.0); - Vector2D oneThree = new Vector2D(1.0,3.0); + Coordinates2D oneOne = new Coordinates2D(1.0,1.0); + Coordinates2D oneTwo = new Coordinates2D(1.0,2.0); + Coordinates2D oneThree = new Coordinates2D(1.0,3.0); - Vector2D tripleCombo = new Vector2D(3.0, oneOne, 1.0, oneTwo, 2.5, oneThree); + Coordinates2D tripleCombo = new Coordinates2D(3.0, oneOne, 1.0, oneTwo, 2.5, oneThree); Assert.assertEquals(3.0 * 1 + 1.0 * 1 + 2.5 * 1,tripleCombo.getX(), EPS); Assert.assertEquals(3.0 * 1 + 1.0 * 2 + 2.5 * 3,tripleCombo.getY(), EPS); @@ -40,12 +40,12 @@ public class Vector2DTest { @Test public void testScaledVectorQuadrupleConstructor() { - Vector2D oneOne = new Vector2D(1.0, 1.0); - Vector2D oneTwo = new Vector2D(1.0, 2.0); - Vector2D oneThree = new Vector2D(1.0, 3.0); - Vector2D oneFour = new Vector2D(1.0, 4.0); + Coordinates2D oneOne = new Coordinates2D(1.0, 1.0); + Coordinates2D oneTwo = new Coordinates2D(1.0, 2.0); + Coordinates2D oneThree = new Coordinates2D(1.0, 3.0); + Coordinates2D oneFour = new Coordinates2D(1.0, 4.0); - Vector2D tripleCombo = new Vector2D(3.0, oneOne, 1.0, oneTwo, 2.5, oneThree, 2.0, oneFour); + Coordinates2D tripleCombo = new Coordinates2D(3.0, oneOne, 1.0, oneTwo, 2.5, oneThree, 2.0, oneFour); Assert.assertEquals(3.0 * 1.0 + 1.0 * 1.0 + 2.5 * 1.0 + 2.0 * 1.0,tripleCombo.getX(), EPS); Assert.assertEquals(3.0 * 1.0 + 1.0 * 2.0 + 2.5 * 3.0 + 2.0 * 4.0,tripleCombo.getY(), EPS); @@ -55,7 +55,7 @@ public class Vector2DTest { public void testConstructorExceptions() { double[] v = new double[] {0.0, 1.0, 2.0}; try { - new Vector2D(v); + new Coordinates2D(v); } catch (Exception e) { Assert.assertTrue(e instanceof DimensionMismatchException); @@ -64,7 +64,7 @@ public class Vector2DTest { @Test public void testToArray() { - Vector2D oneTwo = new Vector2D(1.0, 2.0); + Coordinates2D oneTwo = new Coordinates2D(1.0, 2.0); double[] array = oneTwo.toArray(); Assert.assertEquals(1.0, array[0], EPS); Assert.assertEquals(2.0, array[1], EPS); @@ -72,72 +72,72 @@ public class Vector2DTest { @Test public void testGetZero() { - Vector2D zero = (new Vector2D(1.0, 1.0)).getZero(); + Coordinates2D zero = (new Coordinates2D(1.0, 1.0)).getZero(); Assert.assertEquals(0.0, zero.getX(), EPS); Assert.assertEquals(0.0, zero.getY(), EPS); } @Test public void testNorm1() { - Vector2D oneTwo = new Vector2D(-1.0, 2.0); + Coordinates2D oneTwo = new Coordinates2D(-1.0, 2.0); Assert.assertEquals(3.0, oneTwo.getNorm1(), EPS); } @Test public void testNormSq() { - Vector2D oneTwo = new Vector2D(-1.0, 2.0); + Coordinates2D oneTwo = new Coordinates2D(-1.0, 2.0); Assert.assertEquals(5.0, oneTwo.getNormSq(), EPS); } @Test public void testNormInf() { - Vector2D oneTwo = new Vector2D(-1.0, 2.0); + Coordinates2D oneTwo = new Coordinates2D(-1.0, 2.0); Assert.assertEquals(2.0, oneTwo.getNormInf(), EPS); } @Test public void testVectorAddition() { - Vector2D minusOneTwo = new Vector2D(-1.0,2.0); - Vector2D threeFive = new Vector2D(3.0,5.0); - Vector2D addition = minusOneTwo.add(threeFive); + Coordinates2D minusOneTwo = new Coordinates2D(-1.0,2.0); + Coordinates2D threeFive = new Coordinates2D(3.0,5.0); + Coordinates2D addition = minusOneTwo.add(threeFive); Assert.assertEquals(2.0, addition.getX(), EPS); Assert.assertEquals(7.0, addition.getY(), EPS); } @Test public void testScaledVectorAddition() { - Vector2D minusOneTwo = new Vector2D(-1.0,2.0); - Vector2D threeFive = new Vector2D(3.0,5.0); - Vector2D addition = minusOneTwo.add(2.0, threeFive); + Coordinates2D minusOneTwo = new Coordinates2D(-1.0,2.0); + Coordinates2D threeFive = new Coordinates2D(3.0,5.0); + Coordinates2D addition = minusOneTwo.add(2.0, threeFive); Assert.assertEquals(5.0, addition.getX(), EPS); Assert.assertEquals(12.0, addition.getY(), EPS); } @Test public void testVectorSubtraction() { - Vector2D minusOneTwo = new Vector2D(-1.0,2.0); - Vector2D threeFive = new Vector2D(3.0,5.0); - Vector2D addition = minusOneTwo.subtract(threeFive); + Coordinates2D minusOneTwo = new Coordinates2D(-1.0,2.0); + Coordinates2D threeFive = new Coordinates2D(3.0,5.0); + Coordinates2D addition = minusOneTwo.subtract(threeFive); Assert.assertEquals(-4.0, addition.getX(), EPS); Assert.assertEquals(-3.0, addition.getY(), EPS); } @Test public void testScaledVectorSubtraction() { - Vector2D minusOneTwo = new Vector2D(-1.0,2.0); - Vector2D threeFive = new Vector2D(3.0,5.0); - Vector2D addition = minusOneTwo.subtract(2.0, threeFive); + Coordinates2D minusOneTwo = new Coordinates2D(-1.0,2.0); + Coordinates2D threeFive = new Coordinates2D(3.0,5.0); + Coordinates2D addition = minusOneTwo.subtract(2.0, threeFive); Assert.assertEquals(-7.0, addition.getX(), EPS); Assert.assertEquals(-8.0, addition.getY(), EPS); } @Test public void testNormalize() { - Vector2D minusOneTwo = new Vector2D(-1.0,2.0); - Vector2D normalizedMinusOneTwo = minusOneTwo.normalize(); + Coordinates2D minusOneTwo = new Coordinates2D(-1.0,2.0); + Coordinates2D normalizedMinusOneTwo = minusOneTwo.normalize(); Assert.assertEquals(-1.0/FastMath.sqrt(5), normalizedMinusOneTwo.getX(), EPS); Assert.assertEquals(2.0/FastMath.sqrt(5), normalizedMinusOneTwo.getY(), EPS); - Vector2D zero = minusOneTwo.getZero(); + Coordinates2D zero = minusOneTwo.getZero(); try { zero.normalize(); } @@ -148,88 +148,88 @@ public class Vector2DTest { @Test public void testAngle() { - Vector2D oneOne = new Vector2D(1.0, 1.0); + Coordinates2D oneOne = new Coordinates2D(1.0, 1.0); try { - Vector2D.angle(oneOne.getZero(), oneOne.getZero()); + Coordinates2D.angle(oneOne.getZero(), oneOne.getZero()); } catch (Exception e) { Assert.assertTrue(e instanceof MathArithmeticException); } - Vector2D oneZero = new Vector2D(1.0,0.0); - double angle = Vector2D.angle(oneOne, oneZero); + Coordinates2D oneZero = new Coordinates2D(1.0,0.0); + double angle = Coordinates2D.angle(oneOne, oneZero); Assert.assertEquals(FastMath.PI/4, angle, EPS); - Assert.assertEquals(0.004999958333958323, Vector2D.angle(new Vector2D(20.0,0.0), new Vector2D(20.0,0.1)), EPS); + Assert.assertEquals(0.004999958333958323, Coordinates2D.angle(new Coordinates2D(20.0,0.0), new Coordinates2D(20.0,0.1)), EPS); } @Test public void testNegate() { - Vector2D oneOne = new Vector2D(1.0,1.0); - Vector2D negated = oneOne.negate(); + Coordinates2D oneOne = new Coordinates2D(1.0,1.0); + Coordinates2D negated = oneOne.negate(); Assert.assertEquals(-1.0, negated.getX(), EPS); Assert.assertEquals(-1.0, negated.getY(), EPS); } @Test public void testIsInfinite() { - Vector2D oneOne = new Vector2D(1.0, 1.0); - Vector2D infiniteVector = new Vector2D(Double.POSITIVE_INFINITY, 0.0); + Coordinates2D oneOne = new Coordinates2D(1.0, 1.0); + Coordinates2D infiniteVector = new Coordinates2D(Double.POSITIVE_INFINITY, 0.0); Assert.assertFalse(oneOne.isInfinite()); Assert.assertTrue(infiniteVector.isInfinite()); } @Test public void testDistance1() { - Vector2D oneOne = new Vector2D(1.0,1.0); - Vector2D fiveEleven = new Vector2D(5.0,11.0); + Coordinates2D oneOne = new Coordinates2D(1.0,1.0); + Coordinates2D fiveEleven = new Coordinates2D(5.0,11.0); double distance1 = oneOne.distance1(fiveEleven); Assert.assertEquals(14.0, distance1, EPS); } @Test public void testDistanceInf() { - Vector2D oneOne = new Vector2D(1.0,1.0); - Vector2D fiveEleven = new Vector2D(5.0,11.0); + Coordinates2D oneOne = new Coordinates2D(1.0,1.0); + Coordinates2D fiveEleven = new Coordinates2D(5.0,11.0); double distanceInf = oneOne.distanceInf(fiveEleven); - double staticDistanceInf = Vector2D.distanceInf(oneOne, fiveEleven); + double staticDistanceInf = Coordinates2D.distanceInf(oneOne, fiveEleven); Assert.assertEquals(10.0, distanceInf, EPS); Assert.assertEquals(distanceInf, staticDistanceInf, EPS); } @Test public void testDistanceSq() { - Vector2D oneFive = new Vector2D(1.0, 5.0); - Vector2D fourOne = new Vector2D(4.0, 1.0); + Coordinates2D oneFive = new Coordinates2D(1.0, 5.0); + Coordinates2D fourOne = new Coordinates2D(4.0, 1.0); double distanceSq = oneFive.distanceSq(fourOne); - double staticDistanceSq = Vector2D.distanceSq(oneFive, fourOne); + double staticDistanceSq = Coordinates2D.distanceSq(oneFive, fourOne); Assert.assertEquals(25.0, distanceSq, EPS); Assert.assertEquals(distanceSq, staticDistanceSq, EPS); } @Test public void testHashCode() { - int hashCode = (new Vector2D(1.0,1.0)).hashCode(); + int hashCode = (new Coordinates2D(1.0,1.0)).hashCode(); Assert.assertEquals(887095296, hashCode); - Assert.assertEquals(542, (new Vector2D(Double.NaN, Double.NaN)).hashCode()); + Assert.assertEquals(542, (new Coordinates2D(Double.NaN, Double.NaN)).hashCode()); } @Test public void testToString() { - Assert.assertEquals("{1; 2}", (new Vector2D(1.0,2.0)).toString()); + Assert.assertEquals("{1; 2}", (new Coordinates2D(1.0,2.0)).toString()); } @Test public void testCrossProduct() { - Vector2D p1 = new Vector2D(1, 1); - Vector2D p2 = new Vector2D(2, 2); + Coordinates2D p1 = new Coordinates2D(1, 1); + Coordinates2D p2 = new Coordinates2D(2, 2); - Vector2D p3 = new Vector2D(3, 3); + Coordinates2D p3 = new Coordinates2D(3, 3); Assert.assertEquals(0.0, p3.crossProduct(p1, p2), EPS); - Vector2D p4 = new Vector2D(1, 2); + Coordinates2D p4 = new Coordinates2D(1, 2); Assert.assertEquals(1.0, p4.crossProduct(p1, p2), EPS); - Vector2D p5 = new Vector2D(2, 1); + Coordinates2D p5 = new Coordinates2D(2, 1); Assert.assertEquals(-1.0, p5.crossProduct(p1, p2), EPS); } } http://git-wip-us.apache.org/repos/asf/commons-math/blob/b815d2af/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/AklToussaintHeuristicTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/AklToussaintHeuristicTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/AklToussaintHeuristicTest.java index 219e5b2..d91016a 100644 --- a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/AklToussaintHeuristicTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/AklToussaintHeuristicTest.java @@ -18,7 +18,7 @@ package org.apache.commons.math4.geometry.euclidean.twod.hull; import java.util.Collection; -import org.apache.commons.math4.geometry.euclidean.twod.Vector2D; +import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D; import org.apache.commons.math4.geometry.euclidean.twod.hull.AklToussaintHeuristic; import org.apache.commons.math4.geometry.euclidean.twod.hull.ConvexHullGenerator2D; import org.apache.commons.math4.geometry.euclidean.twod.hull.MonotoneChain; @@ -34,7 +34,7 @@ public class AklToussaintHeuristicTest extends ConvexHullGenerator2DAbstractTest } @Override - protected Collection<Vector2D> reducePoints(Collection<Vector2D> points) { + protected Collection<Coordinates2D> reducePoints(Collection<Coordinates2D> points) { return AklToussaintHeuristic.reducePoints(points); } http://git-wip-us.apache.org/repos/asf/commons-math/blob/b815d2af/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHullGenerator2DAbstractTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHullGenerator2DAbstractTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHullGenerator2DAbstractTest.java index 818c109..7f2fc7e 100644 --- a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHullGenerator2DAbstractTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHullGenerator2DAbstractTest.java @@ -24,7 +24,7 @@ import java.util.List; import org.apache.commons.math4.exception.NullArgumentException; import org.apache.commons.math4.geometry.euclidean.twod.Euclidean2D; -import org.apache.commons.math4.geometry.euclidean.twod.Vector2D; +import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D; import org.apache.commons.math4.geometry.euclidean.twod.hull.ConvexHull2D; import org.apache.commons.math4.geometry.euclidean.twod.hull.ConvexHullGenerator2D; import org.apache.commons.math4.geometry.partitioning.Region; @@ -49,7 +49,7 @@ public abstract class ConvexHullGenerator2DAbstractTest { protected abstract ConvexHullGenerator2D createConvexHullGenerator(boolean includeCollinearPoints); - protected Collection<Vector2D> reducePoints(Collection<Vector2D> points) { + protected Collection<Coordinates2D> reducePoints(Collection<Coordinates2D> points) { // do nothing by default, may be overridden by other tests return points; } @@ -70,14 +70,14 @@ public abstract class ConvexHullGenerator2DAbstractTest { @Test public void testEmpty() { - ConvexHull2D hull = generator.generate(Collections.<Vector2D>emptyList()); + ConvexHull2D hull = generator.generate(Collections.<Coordinates2D>emptyList()); Assert.assertTrue(hull.getVertices().length == 0); Assert.assertTrue(hull.getLineSegments().length == 0); } @Test public void testOnePoint() { - List<Vector2D> points = createRandomPoints(1); + List<Coordinates2D> points = createRandomPoints(1); ConvexHull2D hull = generator.generate(points); Assert.assertTrue(hull.getVertices().length == 1); Assert.assertTrue(hull.getLineSegments().length == 0); @@ -85,7 +85,7 @@ public abstract class ConvexHullGenerator2DAbstractTest { @Test public void testTwoPoints() { - List<Vector2D> points = createRandomPoints(2); + List<Coordinates2D> points = createRandomPoints(2); ConvexHull2D hull = generator.generate(points); Assert.assertTrue(hull.getVertices().length == 2); Assert.assertTrue(hull.getLineSegments().length == 1); @@ -93,11 +93,11 @@ public abstract class ConvexHullGenerator2DAbstractTest { @Test public void testAllIdentical() { - final Collection<Vector2D> points = new ArrayList<>(); - points.add(new Vector2D(1, 1)); - points.add(new Vector2D(1, 1)); - points.add(new Vector2D(1, 1)); - points.add(new Vector2D(1, 1)); + final Collection<Coordinates2D> points = new ArrayList<>(); + points.add(new Coordinates2D(1, 1)); + points.add(new Coordinates2D(1, 1)); + points.add(new Coordinates2D(1, 1)); + points.add(new Coordinates2D(1, 1)); final ConvexHull2D hull = generator.generate(points); Assert.assertTrue(hull.getVertices().length == 1); @@ -110,7 +110,7 @@ public abstract class ConvexHullGenerator2DAbstractTest { // randomize the size from 4 to 100 int size = (int) FastMath.floor(random.nextDouble() * 96.0 + 4.0); - List<Vector2D> points = createRandomPoints(size); + List<Coordinates2D> points = createRandomPoints(size); ConvexHull2D hull = generator.generate(reducePoints(points)); checkConvexHull(points, hull); } @@ -118,12 +118,12 @@ public abstract class ConvexHullGenerator2DAbstractTest { @Test public void testCollinearPoints() { - final Collection<Vector2D> points = new ArrayList<>(); - points.add(new Vector2D(1, 1)); - points.add(new Vector2D(2, 2)); - points.add(new Vector2D(2, 4)); - points.add(new Vector2D(4, 1)); - points.add(new Vector2D(10, 1)); + final Collection<Coordinates2D> points = new ArrayList<>(); + points.add(new Coordinates2D(1, 1)); + points.add(new Coordinates2D(2, 2)); + points.add(new Coordinates2D(2, 4)); + points.add(new Coordinates2D(4, 1)); + points.add(new Coordinates2D(10, 1)); final ConvexHull2D hull = generator.generate(points); checkConvexHull(points, hull); @@ -131,12 +131,12 @@ public abstract class ConvexHullGenerator2DAbstractTest { @Test public void testCollinearPointsReverse() { - final Collection<Vector2D> points = new ArrayList<>(); - points.add(new Vector2D(1, 1)); - points.add(new Vector2D(2, 2)); - points.add(new Vector2D(2, 4)); - points.add(new Vector2D(10, 1)); - points.add(new Vector2D(4, 1)); + final Collection<Coordinates2D> points = new ArrayList<>(); + points.add(new Coordinates2D(1, 1)); + points.add(new Coordinates2D(2, 2)); + points.add(new Coordinates2D(2, 4)); + points.add(new Coordinates2D(10, 1)); + points.add(new Coordinates2D(4, 1)); final ConvexHull2D hull = generator.generate(points); checkConvexHull(points, hull); @@ -144,12 +144,12 @@ public abstract class ConvexHullGenerator2DAbstractTest { @Test public void testCollinearPointsIncluded() { - final Collection<Vector2D> points = new ArrayList<>(); - points.add(new Vector2D(1, 1)); - points.add(new Vector2D(2, 2)); - points.add(new Vector2D(2, 4)); - points.add(new Vector2D(4, 1)); - points.add(new Vector2D(10, 1)); + final Collection<Coordinates2D> points = new ArrayList<>(); + points.add(new Coordinates2D(1, 1)); + points.add(new Coordinates2D(2, 2)); + points.add(new Coordinates2D(2, 4)); + points.add(new Coordinates2D(4, 1)); + points.add(new Coordinates2D(10, 1)); final ConvexHull2D hull = createConvexHullGenerator(true).generate(points); checkConvexHull(points, hull, true); @@ -157,12 +157,12 @@ public abstract class ConvexHullGenerator2DAbstractTest { @Test public void testCollinearPointsIncludedReverse() { - final Collection<Vector2D> points = new ArrayList<>(); - points.add(new Vector2D(1, 1)); - points.add(new Vector2D(2, 2)); - points.add(new Vector2D(2, 4)); - points.add(new Vector2D(10, 1)); - points.add(new Vector2D(4, 1)); + final Collection<Coordinates2D> points = new ArrayList<>(); + points.add(new Coordinates2D(1, 1)); + points.add(new Coordinates2D(2, 2)); + points.add(new Coordinates2D(2, 4)); + points.add(new Coordinates2D(10, 1)); + points.add(new Coordinates2D(4, 1)); final ConvexHull2D hull = createConvexHullGenerator(true).generate(points); checkConvexHull(points, hull, true); @@ -170,12 +170,12 @@ public abstract class ConvexHullGenerator2DAbstractTest { @Test public void testIdenticalPoints() { - final Collection<Vector2D> points = new ArrayList<>(); - points.add(new Vector2D(1, 1)); - points.add(new Vector2D(2, 2)); - points.add(new Vector2D(2, 4)); - points.add(new Vector2D(4, 1)); - points.add(new Vector2D(1, 1)); + final Collection<Coordinates2D> points = new ArrayList<>(); + points.add(new Coordinates2D(1, 1)); + points.add(new Coordinates2D(2, 2)); + points.add(new Coordinates2D(2, 4)); + points.add(new Coordinates2D(4, 1)); + points.add(new Coordinates2D(1, 1)); final ConvexHull2D hull = generator.generate(points); checkConvexHull(points, hull); @@ -183,12 +183,12 @@ public abstract class ConvexHullGenerator2DAbstractTest { @Test public void testIdenticalPoints2() { - final Collection<Vector2D> points = new ArrayList<>(); - points.add(new Vector2D(1, 1)); - points.add(new Vector2D(2, 2)); - points.add(new Vector2D(2, 4)); - points.add(new Vector2D(4, 1)); - points.add(new Vector2D(1, 1)); + final Collection<Coordinates2D> points = new ArrayList<>(); + points.add(new Coordinates2D(1, 1)); + points.add(new Coordinates2D(2, 2)); + points.add(new Coordinates2D(2, 4)); + points.add(new Coordinates2D(4, 1)); + points.add(new Coordinates2D(1, 1)); final ConvexHull2D hull = createConvexHullGenerator(true).generate(points); checkConvexHull(points, hull, true); @@ -196,12 +196,12 @@ public abstract class ConvexHullGenerator2DAbstractTest { @Test public void testClosePoints() { - final Collection<Vector2D> points = new ArrayList<>(); - points.add(new Vector2D(1, 1)); - points.add(new Vector2D(2, 2)); - points.add(new Vector2D(2, 4)); - points.add(new Vector2D(4, 1)); - points.add(new Vector2D(1.00001, 1)); + final Collection<Coordinates2D> points = new ArrayList<>(); + points.add(new Coordinates2D(1, 1)); + points.add(new Coordinates2D(2, 2)); + points.add(new Coordinates2D(2, 4)); + points.add(new Coordinates2D(4, 1)); + points.add(new Coordinates2D(1.00001, 1)); final ConvexHull2D hull = generator.generate(points); checkConvexHull(points, hull); @@ -211,17 +211,17 @@ public abstract class ConvexHullGenerator2DAbstractTest { public void testCollinearPointOnExistingBoundary() { // MATH-1135: check that collinear points on the hull are handled correctly // when only a minimal hull shall be constructed - final Collection<Vector2D> points = new ArrayList<>(); - points.add(new Vector2D(7.3152, 34.7472)); - points.add(new Vector2D(6.400799999999997, 34.747199999999985)); - points.add(new Vector2D(5.486399999999997, 34.7472)); - points.add(new Vector2D(4.876799999999999, 34.7472)); - points.add(new Vector2D(4.876799999999999, 34.1376)); - points.add(new Vector2D(4.876799999999999, 30.48)); - points.add(new Vector2D(6.0959999999999965, 30.48)); - points.add(new Vector2D(6.0959999999999965, 34.1376)); - points.add(new Vector2D(7.315199999999996, 34.1376)); - points.add(new Vector2D(7.3152, 30.48)); + final Collection<Coordinates2D> points = new ArrayList<>(); + points.add(new Coordinates2D(7.3152, 34.7472)); + points.add(new Coordinates2D(6.400799999999997, 34.747199999999985)); + points.add(new Coordinates2D(5.486399999999997, 34.7472)); + points.add(new Coordinates2D(4.876799999999999, 34.7472)); + points.add(new Coordinates2D(4.876799999999999, 34.1376)); + points.add(new Coordinates2D(4.876799999999999, 30.48)); + points.add(new Coordinates2D(6.0959999999999965, 30.48)); + points.add(new Coordinates2D(6.0959999999999965, 34.1376)); + points.add(new Coordinates2D(7.315199999999996, 34.1376)); + points.add(new Coordinates2D(7.3152, 30.48)); final ConvexHull2D hull = createConvexHullGenerator(false).generate(points); checkConvexHull(points, hull); @@ -233,13 +233,13 @@ public abstract class ConvexHullGenerator2DAbstractTest { // make sure that they are processed in the proper order // for each algorithm. - List<Vector2D> points = new ArrayList<>(); + List<Coordinates2D> points = new ArrayList<>(); // first case: 3 points are collinear - points.add(new Vector2D(16.078200000000184, -36.52519999989808)); - points.add(new Vector2D(19.164300000000186, -36.52519999989808)); - points.add(new Vector2D(19.1643, -25.28136477910407)); - points.add(new Vector2D(19.1643, -17.678400000004157)); + points.add(new Coordinates2D(16.078200000000184, -36.52519999989808)); + points.add(new Coordinates2D(19.164300000000186, -36.52519999989808)); + points.add(new Coordinates2D(19.1643, -25.28136477910407)); + points.add(new Coordinates2D(19.1643, -17.678400000004157)); ConvexHull2D hull = createConvexHullGenerator(false).generate(points); checkConvexHull(points, hull); @@ -250,15 +250,15 @@ public abstract class ConvexHullGenerator2DAbstractTest { points.clear(); // second case: multiple points are collinear - points.add(new Vector2D(0, -29.959696875)); - points.add(new Vector2D(0, -31.621809375)); - points.add(new Vector2D(0, -28.435696875)); - points.add(new Vector2D(0, -33.145809375)); - points.add(new Vector2D(3.048, -33.145809375)); - points.add(new Vector2D(3.048, -31.621809375)); - points.add(new Vector2D(3.048, -29.959696875)); - points.add(new Vector2D(4.572, -33.145809375)); - points.add(new Vector2D(4.572, -28.435696875)); + points.add(new Coordinates2D(0, -29.959696875)); + points.add(new Coordinates2D(0, -31.621809375)); + points.add(new Coordinates2D(0, -28.435696875)); + points.add(new Coordinates2D(0, -33.145809375)); + points.add(new Coordinates2D(3.048, -33.145809375)); + points.add(new Coordinates2D(3.048, -31.621809375)); + points.add(new Coordinates2D(3.048, -29.959696875)); + points.add(new Coordinates2D(4.572, -33.145809375)); + points.add(new Coordinates2D(4.572, -28.435696875)); hull = createConvexHullGenerator(false).generate(points); checkConvexHull(points, hull); @@ -270,7 +270,7 @@ public abstract class ConvexHullGenerator2DAbstractTest { @Test public void testIssue1123() { - List<Vector2D> points = new ArrayList<>(); + List<Coordinates2D> points = new ArrayList<>(); int[][] data = new int[][] { { -11, -1 }, { -11, 0 }, { -11, 1 }, { -10, -3 }, { -10, -2 }, { -10, -1 }, { -10, 0 }, { -10, 1 }, @@ -324,26 +324,26 @@ public abstract class ConvexHullGenerator2DAbstractTest { { 11, -1 }, { 11, 0 }, { 11, 1 } }; for (int[] line : data) { - points.add(new Vector2D(line[0], line[1])); + points.add(new Coordinates2D(line[0], line[1])); } - Vector2D[] referenceHull = new Vector2D[] { - new Vector2D(-11.0, -1.0), - new Vector2D(-10.0, -3.0), - new Vector2D( -6.0, -7.0), - new Vector2D( -3.0, -8.0), - new Vector2D( 3.0, -8.0), - new Vector2D( 6.0, -7.0), - new Vector2D( 10.0, -3.0), - new Vector2D( 11.0, -1.0), - new Vector2D( 11.0, 1.0), - new Vector2D( 10.0, 3.0), - new Vector2D( 6.0, 7.0), - new Vector2D( 3.0, 8.0), - new Vector2D( -3.0, 8.0), - new Vector2D( -6.0, 7.0), - new Vector2D(-10.0, 3.0), - new Vector2D(-11.0, 1.0), + Coordinates2D[] referenceHull = new Coordinates2D[] { + new Coordinates2D(-11.0, -1.0), + new Coordinates2D(-10.0, -3.0), + new Coordinates2D( -6.0, -7.0), + new Coordinates2D( -3.0, -8.0), + new Coordinates2D( 3.0, -8.0), + new Coordinates2D( 6.0, -7.0), + new Coordinates2D( 10.0, -3.0), + new Coordinates2D( 11.0, -1.0), + new Coordinates2D( 11.0, 1.0), + new Coordinates2D( 10.0, 3.0), + new Coordinates2D( 6.0, 7.0), + new Coordinates2D( 3.0, 8.0), + new Coordinates2D( -3.0, 8.0), + new Coordinates2D( -6.0, 7.0), + new Coordinates2D(-10.0, 3.0), + new Coordinates2D(-11.0, 1.0), }; ConvexHull2D convHull = generator.generate(points); @@ -352,7 +352,7 @@ public abstract class ConvexHullGenerator2DAbstractTest { Assert.assertEquals(274.0, hullRegion.getSize(), 1.0e-12); double perimeter = 0; for (int i = 0; i < referenceHull.length; ++i) { - perimeter += Vector2D.distance(referenceHull[i], + perimeter += Coordinates2D.distance(referenceHull[i], referenceHull[(i + 1) % referenceHull.length]); } Assert.assertEquals(perimeter, hullRegion.getBoundarySize(), 1.0e-12); @@ -365,26 +365,26 @@ public abstract class ConvexHullGenerator2DAbstractTest { // ------------------------------------------------------------------------------ - protected final List<Vector2D> createRandomPoints(int size) { + protected final List<Coordinates2D> createRandomPoints(int size) { // create the cloud container - List<Vector2D> points = new ArrayList<>(size); + List<Coordinates2D> points = new ArrayList<>(size); // fill the cloud with a random distribution of points for (int i = 0; i < size; i++) { - points.add(new Vector2D(random.nextDouble() * 2.0 - 1.0, random.nextDouble() * 2.0 - 1.0)); + points.add(new Coordinates2D(random.nextDouble() * 2.0 - 1.0, random.nextDouble() * 2.0 - 1.0)); } return points; } - protected final void checkConvexHull(final Collection<Vector2D> points, final ConvexHull2D hull) { + protected final void checkConvexHull(final Collection<Coordinates2D> points, final ConvexHull2D hull) { checkConvexHull(points, hull, false); } - protected final void checkConvexHull(final Collection<Vector2D> points, final ConvexHull2D hull, + protected final void checkConvexHull(final Collection<Coordinates2D> points, final ConvexHull2D hull, final boolean includesCollinearPoints) { checkConvexHull(points, hull, includesCollinearPoints, 1e-10); } - protected final void checkConvexHull(final Collection<Vector2D> points, final ConvexHull2D hull, + protected final void checkConvexHull(final Collection<Coordinates2D> points, final ConvexHull2D hull, final boolean includesCollinearPoints, final double tolerance) { Assert.assertNotNull(hull); Assert.assertTrue(isConvex(hull, includesCollinearPoints, tolerance)); @@ -395,16 +395,16 @@ public abstract class ConvexHullGenerator2DAbstractTest { protected final boolean isConvex(final ConvexHull2D hull, final boolean includesCollinearPoints, final double tolerance) { - final Vector2D[] points = hull.getVertices(); + final Coordinates2D[] points = hull.getVertices(); int sign = 0; for (int i = 0; i < points.length; i++) { - Vector2D p1 = points[i == 0 ? points.length - 1 : i - 1]; - Vector2D p2 = points[i]; - Vector2D p3 = points[i == points.length - 1 ? 0 : i + 1]; + Coordinates2D p1 = points[i == 0 ? points.length - 1 : i - 1]; + Coordinates2D p2 = points[i]; + Coordinates2D p3 = points[i == points.length - 1 ? 0 : i + 1]; - Vector2D d1 = p2.subtract(p1); - Vector2D d2 = p3.subtract(p2); + Coordinates2D d1 = p2.subtract(p1); + Coordinates2D d2 = p3.subtract(p2); Assert.assertTrue(d1.getNorm() > 1e-10); Assert.assertTrue(d2.getNorm() > 1e-10); @@ -427,14 +427,14 @@ public abstract class ConvexHullGenerator2DAbstractTest { } // verify that all points are inside the convex hull region - protected final void checkPointsInsideHullRegion(final Collection<Vector2D> points, + protected final void checkPointsInsideHullRegion(final Collection<Coordinates2D> points, final ConvexHull2D hull, final boolean includesCollinearPoints) { - final Collection<Vector2D> hullVertices = Arrays.asList(hull.getVertices()); + final Collection<Coordinates2D> hullVertices = Arrays.asList(hull.getVertices()); final Region<Euclidean2D> region = hull.createRegion(); - for (final Vector2D p : points) { + for (final Coordinates2D p : points) { Location location = region.checkPoint(p); Assert.assertTrue(location != Location.OUTSIDE); http://git-wip-us.apache.org/repos/asf/commons-math/blob/b815d2af/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/MonotoneChainTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/MonotoneChainTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/MonotoneChainTest.java index 7860b9d..4813fdd 100644 --- a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/MonotoneChainTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/MonotoneChainTest.java @@ -20,7 +20,7 @@ import java.util.ArrayList; import java.util.Collection; import org.apache.commons.math4.exception.ConvergenceException; -import org.apache.commons.math4.geometry.euclidean.twod.Vector2D; +import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D; import org.apache.commons.math4.geometry.euclidean.twod.hull.ConvexHull2D; import org.apache.commons.math4.geometry.euclidean.twod.hull.ConvexHullGenerator2D; import org.apache.commons.math4.geometry.euclidean.twod.hull.MonotoneChain; @@ -40,16 +40,16 @@ public class MonotoneChainTest extends ConvexHullGenerator2DAbstractTest { @Test(expected=ConvergenceException.class) public void testConvergenceException() { - final Collection<Vector2D> points = new ArrayList<>(); - - points.add(new Vector2D(1, 1)); - points.add(new Vector2D(1, 5)); - points.add(new Vector2D(0, 7)); - points.add(new Vector2D(1, 10)); - points.add(new Vector2D(1, 20)); - points.add(new Vector2D(20, 20)); - points.add(new Vector2D(20, 40)); - points.add(new Vector2D(40, 1)); + final Collection<Coordinates2D> points = new ArrayList<>(); + + points.add(new Coordinates2D(1, 1)); + points.add(new Coordinates2D(1, 5)); + points.add(new Coordinates2D(0, 7)); + points.add(new Coordinates2D(1, 10)); + points.add(new Coordinates2D(1, 20)); + points.add(new Coordinates2D(20, 20)); + points.add(new Coordinates2D(20, 40)); + points.add(new Coordinates2D(40, 1)); @SuppressWarnings("unused") final ConvexHull2D hull = new MonotoneChain(true, 2).generate(points); http://git-wip-us.apache.org/repos/asf/commons-math/blob/b815d2af/src/test/java/org/apache/commons/math4/geometry/partitioning/RegionDumper.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/geometry/partitioning/RegionDumper.java b/src/test/java/org/apache/commons/math4/geometry/partitioning/RegionDumper.java index 274ff9e..5c356a2 100644 --- a/src/test/java/org/apache/commons/math4/geometry/partitioning/RegionDumper.java +++ b/src/test/java/org/apache/commons/math4/geometry/partitioning/RegionDumper.java @@ -23,15 +23,15 @@ import org.apache.commons.math4.geometry.Space; import org.apache.commons.math4.geometry.euclidean.oned.Euclidean1D; import org.apache.commons.math4.geometry.euclidean.oned.IntervalsSet; import org.apache.commons.math4.geometry.euclidean.oned.OrientedPoint; -import org.apache.commons.math4.geometry.euclidean.oned.Vector1D; +import org.apache.commons.math4.geometry.euclidean.oned.Coordinates1D; import org.apache.commons.math4.geometry.euclidean.threed.Euclidean3D; import org.apache.commons.math4.geometry.euclidean.threed.Plane; import org.apache.commons.math4.geometry.euclidean.threed.PolyhedronsSet; -import org.apache.commons.math4.geometry.euclidean.threed.Vector3D; +import org.apache.commons.math4.geometry.euclidean.threed.Coordinates3D; import org.apache.commons.math4.geometry.euclidean.twod.Euclidean2D; import org.apache.commons.math4.geometry.euclidean.twod.Line; import org.apache.commons.math4.geometry.euclidean.twod.PolygonsSet; -import org.apache.commons.math4.geometry.euclidean.twod.Vector2D; +import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D; import org.apache.commons.math4.geometry.spherical.oned.ArcsSet; import org.apache.commons.math4.geometry.spherical.oned.LimitAngle; import org.apache.commons.math4.geometry.spherical.oned.Sphere1D; @@ -125,7 +125,7 @@ public class RegionDumper { @Override protected void formatHyperplane(final Hyperplane<Euclidean2D> hyperplane) { final Line h = (Line) hyperplane; - final Vector2D p = h.toSpace(Vector1D.ZERO); + final Coordinates2D p = h.toSpace(Coordinates1D.ZERO); getFormatter().format("%22.15e %22.15e %22.15e %22.15e", p.getX(), p.getY(), h.getAngle(), h.getTolerance()); } @@ -146,7 +146,7 @@ public class RegionDumper { @Override protected void formatHyperplane(final Hyperplane<Euclidean3D> hyperplane) { final Plane h = (Plane) hyperplane; - final Vector3D p = h.toSpace(Vector2D.ZERO); + final Coordinates3D p = h.toSpace(Coordinates2D.ZERO); getFormatter().format("%22.15e %22.15e %22.15e %22.15e %22.15e %22.15e %22.15e", p.getX(), p.getY(), p.getZ(), h.getNormal().getX(), h.getNormal().getY(), h.getNormal().getZ(), http://git-wip-us.apache.org/repos/asf/commons-math/blob/b815d2af/src/test/java/org/apache/commons/math4/geometry/partitioning/RegionParser.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/geometry/partitioning/RegionParser.java b/src/test/java/org/apache/commons/math4/geometry/partitioning/RegionParser.java index ced1989..23a4c01 100644 --- a/src/test/java/org/apache/commons/math4/geometry/partitioning/RegionParser.java +++ b/src/test/java/org/apache/commons/math4/geometry/partitioning/RegionParser.java @@ -24,15 +24,15 @@ import org.apache.commons.math4.geometry.Space; import org.apache.commons.math4.geometry.euclidean.oned.Euclidean1D; import org.apache.commons.math4.geometry.euclidean.oned.IntervalsSet; import org.apache.commons.math4.geometry.euclidean.oned.OrientedPoint; -import org.apache.commons.math4.geometry.euclidean.oned.Vector1D; +import org.apache.commons.math4.geometry.euclidean.oned.Coordinates1D; import org.apache.commons.math4.geometry.euclidean.threed.Euclidean3D; import org.apache.commons.math4.geometry.euclidean.threed.Plane; import org.apache.commons.math4.geometry.euclidean.threed.PolyhedronsSet; -import org.apache.commons.math4.geometry.euclidean.threed.Vector3D; +import org.apache.commons.math4.geometry.euclidean.threed.Coordinates3D; import org.apache.commons.math4.geometry.euclidean.twod.Euclidean2D; import org.apache.commons.math4.geometry.euclidean.twod.Line; import org.apache.commons.math4.geometry.euclidean.twod.PolygonsSet; -import org.apache.commons.math4.geometry.euclidean.twod.Vector2D; +import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D; import org.apache.commons.math4.geometry.spherical.oned.ArcsSet; import org.apache.commons.math4.geometry.spherical.oned.LimitAngle; import org.apache.commons.math4.geometry.spherical.oned.S1Point; @@ -90,7 +90,7 @@ public class RegionParser { @Override public Circle parseHyperplane() throws IOException, ParseException { - return new Circle(new Vector3D(getNumber(), getNumber(), getNumber()), getNumber()); + return new Circle(new Coordinates3D(getNumber(), getNumber(), getNumber()), getNumber()); } }; @@ -111,7 +111,7 @@ public class RegionParser { @Override public OrientedPoint parseHyperplane() throws IOException, ParseException { - return new OrientedPoint(new Vector1D(getNumber()), getBoolean(), getNumber()); + return new OrientedPoint(new Coordinates1D(getNumber()), getBoolean(), getNumber()); } }; @@ -132,7 +132,7 @@ public class RegionParser { @Override public Line parseHyperplane() throws IOException, ParseException { - return new Line(new Vector2D(getNumber(), getNumber()), getNumber(), getNumber()); + return new Line(new Coordinates2D(getNumber(), getNumber()), getNumber(), getNumber()); } }; @@ -153,8 +153,8 @@ public class RegionParser { @Override public Plane parseHyperplane() throws IOException, ParseException { - return new Plane(new Vector3D(getNumber(), getNumber(), getNumber()), - new Vector3D(getNumber(), getNumber(), getNumber()), + return new Plane(new Coordinates3D(getNumber(), getNumber(), getNumber()), + new Coordinates3D(getNumber(), getNumber(), getNumber()), getNumber()); } http://git-wip-us.apache.org/repos/asf/commons-math/blob/b815d2af/src/test/java/org/apache/commons/math4/geometry/spherical/twod/CircleTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math4/geometry/spherical/twod/CircleTest.java b/src/test/java/org/apache/commons/math4/geometry/spherical/twod/CircleTest.java index cba801d..3b6cd9d 100644 --- a/src/test/java/org/apache/commons/math4/geometry/spherical/twod/CircleTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/spherical/twod/CircleTest.java @@ -18,7 +18,7 @@ package org.apache.commons.math4.geometry.spherical.twod; import org.apache.commons.math4.geometry.euclidean.threed.Rotation; import org.apache.commons.math4.geometry.euclidean.threed.RotationConvention; -import org.apache.commons.math4.geometry.euclidean.threed.Vector3D; +import org.apache.commons.math4.geometry.euclidean.threed.Coordinates3D; import org.apache.commons.math4.geometry.partitioning.Transform; import org.apache.commons.math4.geometry.spherical.oned.Arc; import org.apache.commons.math4.geometry.spherical.oned.LimitAngle; @@ -40,13 +40,13 @@ public class CircleTest { @Test public void testEquator() { - Circle circle = new Circle(new Vector3D(0, 0, 1000), 1.0e-10).copySelf(); - Assert.assertEquals(Vector3D.PLUS_K, circle.getPole()); + Circle circle = new Circle(new Coordinates3D(0, 0, 1000), 1.0e-10).copySelf(); + Assert.assertEquals(Coordinates3D.PLUS_K, circle.getPole()); Assert.assertEquals(1.0e-10, circle.getTolerance(), 1.0e-20); circle.revertSelf(); - Assert.assertEquals(Vector3D.MINUS_K, circle.getPole()); - Assert.assertEquals(Vector3D.PLUS_K, circle.getReverse().getPole()); - Assert.assertEquals(Vector3D.MINUS_K, circle.getPole()); + Assert.assertEquals(Coordinates3D.MINUS_K, circle.getPole()); + Assert.assertEquals(Coordinates3D.PLUS_K, circle.getReverse().getPole()); + Assert.assertEquals(Coordinates3D.MINUS_K, circle.getPole()); } @Test @@ -54,11 +54,11 @@ 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.getPointAt(0).distance(circle.getXAxis()), 1.0e-10); Assert.assertEquals(0.0, circle.getPointAt(0.5 * FastMath.PI).distance(circle.getYAxis()), 1.0e-10); - Assert.assertEquals(0.5 * FastMath.PI, Vector3D.angle(circle.getXAxis(), circle.getYAxis()), 1.0e-10); - Assert.assertEquals(0.5 * FastMath.PI, Vector3D.angle(circle.getXAxis(), circle.getPole()), 1.0e-10); - Assert.assertEquals(0.5 * FastMath.PI, Vector3D.angle(circle.getPole(), circle.getYAxis()), 1.0e-10); + Assert.assertEquals(0.5 * FastMath.PI, Coordinates3D.angle(circle.getXAxis(), circle.getYAxis()), 1.0e-10); + Assert.assertEquals(0.5 * FastMath.PI, Coordinates3D.angle(circle.getXAxis(), circle.getPole()), 1.0e-10); + Assert.assertEquals(0.5 * FastMath.PI, Coordinates3D.angle(circle.getPole(), circle.getYAxis()), 1.0e-10); Assert.assertEquals(0.0, - circle.getPole().distance(Vector3D.crossProduct(circle.getXAxis(), circle.getYAxis())), + circle.getPole().distance(Coordinates3D.crossProduct(circle.getXAxis(), circle.getYAxis())), 1.0e-10); } @@ -68,16 +68,16 @@ public class CircleTest { Circle reversed = circle.getReverse(); Assert.assertEquals(0.0, reversed.getPointAt(0).distance(reversed.getXAxis()), 1.0e-10); Assert.assertEquals(0.0, reversed.getPointAt(0.5 * FastMath.PI).distance(reversed.getYAxis()), 1.0e-10); - Assert.assertEquals(0.5 * FastMath.PI, Vector3D.angle(reversed.getXAxis(), reversed.getYAxis()), 1.0e-10); - Assert.assertEquals(0.5 * FastMath.PI, Vector3D.angle(reversed.getXAxis(), reversed.getPole()), 1.0e-10); - Assert.assertEquals(0.5 * FastMath.PI, Vector3D.angle(reversed.getPole(), reversed.getYAxis()), 1.0e-10); + Assert.assertEquals(0.5 * FastMath.PI, Coordinates3D.angle(reversed.getXAxis(), reversed.getYAxis()), 1.0e-10); + Assert.assertEquals(0.5 * FastMath.PI, Coordinates3D.angle(reversed.getXAxis(), reversed.getPole()), 1.0e-10); + Assert.assertEquals(0.5 * FastMath.PI, Coordinates3D.angle(reversed.getPole(), reversed.getYAxis()), 1.0e-10); Assert.assertEquals(0.0, - reversed.getPole().distance(Vector3D.crossProduct(reversed.getXAxis(), reversed.getYAxis())), + reversed.getPole().distance(Coordinates3D.crossProduct(reversed.getXAxis(), reversed.getYAxis())), 1.0e-10); - Assert.assertEquals(0, Vector3D.angle(circle.getXAxis(), reversed.getXAxis()), 1.0e-10); - Assert.assertEquals(FastMath.PI, Vector3D.angle(circle.getYAxis(), reversed.getYAxis()), 1.0e-10); - Assert.assertEquals(FastMath.PI, Vector3D.angle(circle.getPole(), reversed.getPole()), 1.0e-10); + Assert.assertEquals(0, Coordinates3D.angle(circle.getXAxis(), reversed.getXAxis()), 1.0e-10); + Assert.assertEquals(FastMath.PI, Coordinates3D.angle(circle.getYAxis(), reversed.getYAxis()), 1.0e-10); + Assert.assertEquals(FastMath.PI, Coordinates3D.angle(circle.getPole(), reversed.getPole()), 1.0e-10); Assert.assertTrue(circle.sameOrientationAs(circle)); Assert.assertFalse(circle.sameOrientationAs(reversed)); @@ -87,13 +87,13 @@ 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 samePhase = circle.getPointAt(circle.getPhase(p)); + Coordinates3D p = new Coordinates3D(1, 2, -4); + Coordinates3D samePhase = circle.getPointAt(circle.getPhase(p)); Assert.assertEquals(0.0, - Vector3D.angle(Vector3D.crossProduct(circle.getPole(), p), - Vector3D.crossProduct(circle.getPole(), samePhase)), + Coordinates3D.angle(Coordinates3D.crossProduct(circle.getPole(), p), + Coordinates3D.crossProduct(circle.getPole(), samePhase)), 1.0e-10); - Assert.assertEquals(0.5 * FastMath.PI, Vector3D.angle(circle.getPole(), samePhase), 1.0e-10); + Assert.assertEquals(0.5 * FastMath.PI, Coordinates3D.angle(circle.getPole(), samePhase), 1.0e-10); Assert.assertEquals(circle.getPhase(p), circle.getPhase(samePhase), 1.0e-10); Assert.assertEquals(0.0, circle.getPhase(circle.getXAxis()), 1.0e-10); Assert.assertEquals(0.5 * FastMath.PI, circle.getPhase(circle.getYAxis()), 1.0e-10); @@ -105,7 +105,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 * FastMath.PI, circle.toSubSpace(new S2Point(circle.getYAxis())).getAlpha(), 1.0e-10); - Vector3D p = new Vector3D(1, 2, -4); + Coordinates3D p = new Coordinates3D(1, 2, -4); Assert.assertEquals(circle.getPhase(p), circle.toSubSpace(new S2Point(p)).getAlpha(), 1.0e-10); } @@ -113,23 +113,23 @@ public class CircleTest { public void testSpace() { Circle circle = new Circle(new S2Point(1.2, 2.5), new S2Point(-4.3, 0), 1.0e-10); for (double alpha = 0; alpha < MathUtils.TWO_PI; alpha += 0.1) { - Vector3D p = new Vector3D(FastMath.cos(alpha), circle.getXAxis(), + Coordinates3D p = new Coordinates3D(FastMath.cos(alpha), circle.getXAxis(), FastMath.sin(alpha), circle.getYAxis()); - Vector3D q = circle.toSpace(new S1Point(alpha)).getVector(); + Coordinates3D q = circle.toSpace(new S1Point(alpha)).getVector(); Assert.assertEquals(0.0, p.distance(q), 1.0e-10); - Assert.assertEquals(0.5 * FastMath.PI, Vector3D.angle(circle.getPole(), q), 1.0e-10); + Assert.assertEquals(0.5 * FastMath.PI, Coordinates3D.angle(circle.getPole(), q), 1.0e-10); } } @Test public void testOffset() { - Circle circle = new Circle(Vector3D.PLUS_K, 1.0e-10); - Assert.assertEquals(0.0, circle.getOffset(new S2Point(Vector3D.PLUS_I)), 1.0e-10); - Assert.assertEquals(0.0, circle.getOffset(new S2Point(Vector3D.MINUS_I)), 1.0e-10); - Assert.assertEquals(0.0, circle.getOffset(new S2Point(Vector3D.PLUS_J)), 1.0e-10); - Assert.assertEquals(0.0, circle.getOffset(new S2Point(Vector3D.MINUS_J)), 1.0e-10); - Assert.assertEquals(-0.5 * FastMath.PI, circle.getOffset(new S2Point(Vector3D.PLUS_K)), 1.0e-10); - Assert.assertEquals( 0.5 * FastMath.PI, circle.getOffset(new S2Point(Vector3D.MINUS_K)), 1.0e-10); + Circle circle = new Circle(Coordinates3D.PLUS_K, 1.0e-10); + Assert.assertEquals(0.0, circle.getOffset(new S2Point(Coordinates3D.PLUS_I)), 1.0e-10); + Assert.assertEquals(0.0, circle.getOffset(new S2Point(Coordinates3D.MINUS_I)), 1.0e-10); + Assert.assertEquals(0.0, circle.getOffset(new S2Point(Coordinates3D.PLUS_J)), 1.0e-10); + Assert.assertEquals(0.0, circle.getOffset(new S2Point(Coordinates3D.MINUS_J)), 1.0e-10); + Assert.assertEquals(-0.5 * FastMath.PI, circle.getOffset(new S2Point(Coordinates3D.PLUS_K)), 1.0e-10); + Assert.assertEquals(0.5 * FastMath.PI, circle.getOffset(new S2Point(Coordinates3D.MINUS_K)), 1.0e-10); } @@ -138,8 +138,8 @@ public class CircleTest { UnitSphereRandomVectorGenerator sphRandom = new UnitSphereRandomVectorGenerator(3, RandomSource.create(RandomSource.WELL_1024_A, 0xbfd34e92231bbcfel)); for (int i = 0; i < 100; ++i) { - Circle c1 = new Circle(new Vector3D(sphRandom.nextVector()), 1.0e-10); - Circle c2 = new Circle(new Vector3D(sphRandom.nextVector()), 1.0e-10); + Circle c1 = new Circle(new Coordinates3D(sphRandom.nextVector()), 1.0e-10); + Circle c2 = new Circle(new Coordinates3D(sphRandom.nextVector()), 1.0e-10); checkArcIsInside(c1, c2); checkArcIsInside(c2, c1); } @@ -163,16 +163,16 @@ public class CircleTest { UnitSphereRandomVectorGenerator sphRandom = new UnitSphereRandomVectorGenerator(3, random); for (int i = 0; i < 100; ++i) { - Rotation r = new Rotation(new Vector3D(sphRandom.nextVector()), + Rotation r = new Rotation(new Coordinates3D(sphRandom.nextVector()), FastMath.PI * random.nextDouble(), RotationConvention.VECTOR_OPERATOR); Transform<Sphere2D, Sphere1D> t = Circle.getTransform(r); - S2Point p = new S2Point(new Vector3D(sphRandom.nextVector())); + S2Point p = new S2Point(new Coordinates3D(sphRandom.nextVector())); S2Point tp = (S2Point) t.apply(p); Assert.assertEquals(0.0, r.applyTo(p.getVector()).distance(tp.getVector()), 1.0e-10); - Circle c = new Circle(new Vector3D(sphRandom.nextVector()), 1.0e-10); + Circle c = new Circle(new Coordinates3D(sphRandom.nextVector()), 1.0e-10); Circle tc = (Circle) t.apply(c); Assert.assertEquals(0.0, r.applyTo(c.getPole()).distance(tc.getPole()), 1.0e-10); Assert.assertEquals(0.0, r.applyTo(c.getXAxis()).distance(tc.getXAxis()), 1.0e-10); @@ -181,9 +181,9 @@ public class CircleTest { SubLimitAngle sub = new LimitAngle(new S1Point(MathUtils.TWO_PI * random.nextDouble()), random.nextBoolean(), 1.0e-10).wholeHyperplane(); - Vector3D psub = c.getPointAt(((LimitAngle) sub.getHyperplane()).getLocation().getAlpha()); + Coordinates3D psub = c.getPointAt(((LimitAngle) sub.getHyperplane()).getLocation().getAlpha()); SubLimitAngle tsub = (SubLimitAngle) t.apply(sub, c, tc); - Vector3D ptsub = tc.getPointAt(((LimitAngle) tsub.getHyperplane()).getLocation().getAlpha()); + Coordinates3D ptsub = tc.getPointAt(((LimitAngle) tsub.getHyperplane()).getLocation().getAlpha()); Assert.assertEquals(0.0, r.applyTo(psub).distance(ptsub), 1.0e-10); }