Java Code Examples for org.apache.commons.math3.geometry.euclidean.twod.Line#toSpace()
The following examples show how to use
org.apache.commons.math3.geometry.euclidean.twod.Line#toSpace() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LineTest.java From astor with GNU General Public License v2.0 | 5 votes |
@Test public void testPointAt() { Line l = new Line(new Vector2D(2, 1), new Vector2D(-2, -2), 1.0e-10); for (double a = -2.0; a < 2.0; a += 0.2) { Point<Euclidean1D> pA = new Vector1D(a); Point<Euclidean2D> point = l.toSpace(pA); Assert.assertEquals(a, (l.toSubSpace(point)).getX(), 1.0e-10); Assert.assertEquals(0.0, l.getOffset(point), 1.0e-10); for (double o = -2.0; o < 2.0; o += 0.2) { point = l.getPointAt((Vector1D) pA, o); Assert.assertEquals(a, (l.toSubSpace(point)).getX(), 1.0e-10); Assert.assertEquals(o, l.getOffset(point), 1.0e-10); } } }
Example 2
Source File: LineTest.java From astor with GNU General Public License v2.0 | 5 votes |
@Test public void testPointAt() { Line l = new Line(new Vector2D(2, 1), new Vector2D(-2, -2)); for (double a = -2.0; a < 2.0; a += 0.2) { Vector1D pA = new Vector1D(a); Vector2D point = l.toSpace(pA); Assert.assertEquals(a, (l.toSubSpace(point)).getX(), 1.0e-10); Assert.assertEquals(0.0, l.getOffset(point), 1.0e-10); for (double o = -2.0; o < 2.0; o += 0.2) { point = l.getPointAt(pA, o); Assert.assertEquals(a, (l.toSubSpace(point)).getX(), 1.0e-10); Assert.assertEquals(o, l.getOffset(point), 1.0e-10); } } }
Example 3
Source File: LineTest.java From astor with GNU General Public License v2.0 | 5 votes |
@Test public void testPointAt() { Line l = new Line(new Vector2D(2, 1), new Vector2D(-2, -2)); for (double a = -2.0; a < 2.0; a += 0.2) { Vector1D pA = new Vector1D(a); Vector2D point = l.toSpace(pA); Assert.assertEquals(a, (l.toSubSpace(point)).getX(), 1.0e-10); Assert.assertEquals(0.0, l.getOffset(point), 1.0e-10); for (double o = -2.0; o < 2.0; o += 0.2) { point = l.getPointAt(pA, o); Assert.assertEquals(a, (l.toSubSpace(point)).getX(), 1.0e-10); Assert.assertEquals(o, l.getOffset(point), 1.0e-10); } } }
Example 4
Source File: LineTest.java From astor with GNU General Public License v2.0 | 5 votes |
@Test public void testPointAt() { Line l = new Line(new Vector2D(2, 1), new Vector2D(-2, -2)); for (double a = -2.0; a < 2.0; a += 0.2) { Vector1D pA = new Vector1D(a); Vector2D point = l.toSpace(pA); Assert.assertEquals(a, (l.toSubSpace(point)).getX(), 1.0e-10); Assert.assertEquals(0.0, l.getOffset(point), 1.0e-10); for (double o = -2.0; o < 2.0; o += 0.2) { point = l.getPointAt(pA, o); Assert.assertEquals(a, (l.toSubSpace(point)).getX(), 1.0e-10); Assert.assertEquals(o, l.getOffset(point), 1.0e-10); } } }
Example 5
Source File: LineTest.java From astor with GNU General Public License v2.0 | 5 votes |
@Test public void testPointAt() { Line l = new Line(new Vector2D(2, 1), new Vector2D(-2, -2)); for (double a = -2.0; a < 2.0; a += 0.2) { Vector1D pA = new Vector1D(a); Vector2D point = l.toSpace(pA); Assert.assertEquals(a, (l.toSubSpace(point)).getX(), 1.0e-10); Assert.assertEquals(0.0, l.getOffset(point), 1.0e-10); for (double o = -2.0; o < 2.0; o += 0.2) { point = l.getPointAt(pA, o); Assert.assertEquals(a, (l.toSubSpace(point)).getX(), 1.0e-10); Assert.assertEquals(o, l.getOffset(point), 1.0e-10); } } }
Example 6
Source File: LineTest.java From astor with GNU General Public License v2.0 | 5 votes |
@Test public void testPointAt() { Line l = new Line(new Vector2D(2, 1), new Vector2D(-2, -2)); for (double a = -2.0; a < 2.0; a += 0.2) { Vector1D pA = new Vector1D(a); Vector2D point = l.toSpace(pA); Assert.assertEquals(a, (l.toSubSpace(point)).getX(), 1.0e-10); Assert.assertEquals(0.0, l.getOffset(point), 1.0e-10); for (double o = -2.0; o < 2.0; o += 0.2) { point = l.getPointAt(pA, o); Assert.assertEquals(a, (l.toSubSpace(point)).getX(), 1.0e-10); Assert.assertEquals(o, l.getOffset(point), 1.0e-10); } } }
Example 7
Source File: LineTest.java From astor with GNU General Public License v2.0 | 5 votes |
@Test public void testPointAt() { Line l = new Line(new Vector2D(2, 1), new Vector2D(-2, -2)); for (double a = -2.0; a < 2.0; a += 0.2) { Vector1D pA = new Vector1D(a); Vector2D point = l.toSpace(pA); Assert.assertEquals(a, (l.toSubSpace(point)).getX(), 1.0e-10); Assert.assertEquals(0.0, l.getOffset(point), 1.0e-10); for (double o = -2.0; o < 2.0; o += 0.2) { point = l.getPointAt(pA, o); Assert.assertEquals(a, (l.toSubSpace(point)).getX(), 1.0e-10); Assert.assertEquals(o, l.getOffset(point), 1.0e-10); } } }
Example 8
Source File: LineTest.java From astor with GNU General Public License v2.0 | 5 votes |
@Test public void testPointAt() { Line l = new Line(new Vector2D(2, 1), new Vector2D(-2, -2), 1.0e-10); for (double a = -2.0; a < 2.0; a += 0.2) { Point<Euclidean1D> pA = new Vector1D(a); Point<Euclidean2D> point = l.toSpace(pA); Assert.assertEquals(a, (l.toSubSpace(point)).getX(), 1.0e-10); Assert.assertEquals(0.0, l.getOffset(point), 1.0e-10); for (double o = -2.0; o < 2.0; o += 0.2) { point = l.getPointAt((Vector1D) pA, o); Assert.assertEquals(a, (l.toSubSpace(point)).getX(), 1.0e-10); Assert.assertEquals(o, l.getOffset(point), 1.0e-10); } } }
Example 9
Source File: PolygonsSetTest.java From astor with GNU General Public License v2.0 | 4 votes |
@Test public void testLineIntersection() { Vector2D[][] vertices = new Vector2D[][] { new Vector2D[] { new Vector2D( 0.0, 0.0), new Vector2D( 2.0, 0.0), new Vector2D( 2.0, 1.0), new Vector2D( 3.0, 1.0), new Vector2D( 3.0, 3.0), new Vector2D( 1.0, 3.0), new Vector2D( 1.0, 2.0), new Vector2D( 0.0, 2.0) } }; PolygonsSet set = buildSet(vertices); Line l1 = new Line(new Vector2D(-1.5, 0.0), FastMath.PI / 4); SubLine s1 = (SubLine) set.intersection(l1.wholeHyperplane()); List<Interval> i1 = ((IntervalsSet) s1.getRemainingRegion()).asList(); Assert.assertEquals(2, i1.size()); Interval v10 = i1.get(0); Vector2D p10Lower = l1.toSpace(new Vector1D(v10.getLower())); Assert.assertEquals(0.0, p10Lower.getX(), 1.0e-10); Assert.assertEquals(1.5, p10Lower.getY(), 1.0e-10); Vector2D p10Upper = l1.toSpace(new Vector1D(v10.getUpper())); Assert.assertEquals(0.5, p10Upper.getX(), 1.0e-10); Assert.assertEquals(2.0, p10Upper.getY(), 1.0e-10); Interval v11 = i1.get(1); Vector2D p11Lower = l1.toSpace(new Vector1D(v11.getLower())); Assert.assertEquals(1.0, p11Lower.getX(), 1.0e-10); Assert.assertEquals(2.5, p11Lower.getY(), 1.0e-10); Vector2D p11Upper = l1.toSpace(new Vector1D(v11.getUpper())); Assert.assertEquals(1.5, p11Upper.getX(), 1.0e-10); Assert.assertEquals(3.0, p11Upper.getY(), 1.0e-10); Line l2 = new Line(new Vector2D(-1.0, 2.0), 0); SubLine s2 = (SubLine) set.intersection(l2.wholeHyperplane()); List<Interval> i2 = ((IntervalsSet) s2.getRemainingRegion()).asList(); Assert.assertEquals(1, i2.size()); Interval v20 = i2.get(0); Vector2D p20Lower = l2.toSpace(new Vector1D(v20.getLower())); Assert.assertEquals(1.0, p20Lower.getX(), 1.0e-10); Assert.assertEquals(2.0, p20Lower.getY(), 1.0e-10); Vector2D p20Upper = l2.toSpace(new Vector1D(v20.getUpper())); Assert.assertEquals(3.0, p20Upper.getX(), 1.0e-10); Assert.assertEquals(2.0, p20Upper.getY(), 1.0e-10); }
Example 10
Source File: PolygonsSetTest.java From astor with GNU General Public License v2.0 | 4 votes |
@Test public void testLineIntersection() { Vector2D[][] vertices = new Vector2D[][] { new Vector2D[] { new Vector2D( 0.0, 0.0), new Vector2D( 2.0, 0.0), new Vector2D( 2.0, 1.0), new Vector2D( 3.0, 1.0), new Vector2D( 3.0, 3.0), new Vector2D( 1.0, 3.0), new Vector2D( 1.0, 2.0), new Vector2D( 0.0, 2.0) } }; PolygonsSet set = buildSet(vertices); Line l1 = new Line(new Vector2D(-1.5, 0.0), FastMath.PI / 4); SubLine s1 = (SubLine) set.intersection(l1.wholeHyperplane()); List<Interval> i1 = ((IntervalsSet) s1.getRemainingRegion()).asList(); Assert.assertEquals(2, i1.size()); Interval v10 = i1.get(0); Vector2D p10Lower = l1.toSpace(new Vector1D(v10.getLower())); Assert.assertEquals(0.0, p10Lower.getX(), 1.0e-10); Assert.assertEquals(1.5, p10Lower.getY(), 1.0e-10); Vector2D p10Upper = l1.toSpace(new Vector1D(v10.getUpper())); Assert.assertEquals(0.5, p10Upper.getX(), 1.0e-10); Assert.assertEquals(2.0, p10Upper.getY(), 1.0e-10); Interval v11 = i1.get(1); Vector2D p11Lower = l1.toSpace(new Vector1D(v11.getLower())); Assert.assertEquals(1.0, p11Lower.getX(), 1.0e-10); Assert.assertEquals(2.5, p11Lower.getY(), 1.0e-10); Vector2D p11Upper = l1.toSpace(new Vector1D(v11.getUpper())); Assert.assertEquals(1.5, p11Upper.getX(), 1.0e-10); Assert.assertEquals(3.0, p11Upper.getY(), 1.0e-10); Line l2 = new Line(new Vector2D(-1.0, 2.0), 0); SubLine s2 = (SubLine) set.intersection(l2.wholeHyperplane()); List<Interval> i2 = ((IntervalsSet) s2.getRemainingRegion()).asList(); Assert.assertEquals(1, i2.size()); Interval v20 = i2.get(0); Vector2D p20Lower = l2.toSpace(new Vector1D(v20.getLower())); Assert.assertEquals(1.0, p20Lower.getX(), 1.0e-10); Assert.assertEquals(2.0, p20Lower.getY(), 1.0e-10); Vector2D p20Upper = l2.toSpace(new Vector1D(v20.getUpper())); Assert.assertEquals(3.0, p20Upper.getX(), 1.0e-10); Assert.assertEquals(2.0, p20Upper.getY(), 1.0e-10); }
Example 11
Source File: PolygonsSetTest.java From astor with GNU General Public License v2.0 | 4 votes |
@Test public void testLineIntersection() { Vector2D[][] vertices = new Vector2D[][] { new Vector2D[] { new Vector2D( 0.0, 0.0), new Vector2D( 2.0, 0.0), new Vector2D( 2.0, 1.0), new Vector2D( 3.0, 1.0), new Vector2D( 3.0, 3.0), new Vector2D( 1.0, 3.0), new Vector2D( 1.0, 2.0), new Vector2D( 0.0, 2.0) } }; PolygonsSet set = buildSet(vertices); Line l1 = new Line(new Vector2D(-1.5, 0.0), FastMath.PI / 4); SubLine s1 = (SubLine) set.intersection(l1.wholeHyperplane()); List<Interval> i1 = ((IntervalsSet) s1.getRemainingRegion()).asList(); Assert.assertEquals(2, i1.size()); Interval v10 = i1.get(0); Vector2D p10Lower = l1.toSpace(new Vector1D(v10.getLower())); Assert.assertEquals(0.0, p10Lower.getX(), 1.0e-10); Assert.assertEquals(1.5, p10Lower.getY(), 1.0e-10); Vector2D p10Upper = l1.toSpace(new Vector1D(v10.getUpper())); Assert.assertEquals(0.5, p10Upper.getX(), 1.0e-10); Assert.assertEquals(2.0, p10Upper.getY(), 1.0e-10); Interval v11 = i1.get(1); Vector2D p11Lower = l1.toSpace(new Vector1D(v11.getLower())); Assert.assertEquals(1.0, p11Lower.getX(), 1.0e-10); Assert.assertEquals(2.5, p11Lower.getY(), 1.0e-10); Vector2D p11Upper = l1.toSpace(new Vector1D(v11.getUpper())); Assert.assertEquals(1.5, p11Upper.getX(), 1.0e-10); Assert.assertEquals(3.0, p11Upper.getY(), 1.0e-10); Line l2 = new Line(new Vector2D(-1.0, 2.0), 0); SubLine s2 = (SubLine) set.intersection(l2.wholeHyperplane()); List<Interval> i2 = ((IntervalsSet) s2.getRemainingRegion()).asList(); Assert.assertEquals(1, i2.size()); Interval v20 = i2.get(0); Vector2D p20Lower = l2.toSpace(new Vector1D(v20.getLower())); Assert.assertEquals(1.0, p20Lower.getX(), 1.0e-10); Assert.assertEquals(2.0, p20Lower.getY(), 1.0e-10); Vector2D p20Upper = l2.toSpace(new Vector1D(v20.getUpper())); Assert.assertEquals(3.0, p20Upper.getX(), 1.0e-10); Assert.assertEquals(2.0, p20Upper.getY(), 1.0e-10); }