Java Code Examples for org.apache.commons.math3.geometry.euclidean.threed.Vector3D#PLUS_J
The following examples show how to use
org.apache.commons.math3.geometry.euclidean.threed.Vector3D#PLUS_J .
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: SubCircleTest.java From astor with GNU General Public License v2.0 | 4 votes |
@Test public void testSide() { Circle xzPlane = new Circle(Vector3D.PLUS_J, 1.0e-10); SubCircle sc1 = create(Vector3D.PLUS_K, Vector3D.PLUS_I, Vector3D.PLUS_J, 1.0e-10, 1.0, 3.0, 5.0, 6.0); Assert.assertEquals(Side.BOTH, sc1.side(xzPlane)); SubCircle sc2 = create(Vector3D.PLUS_K, Vector3D.PLUS_I, Vector3D.PLUS_J, 1.0e-10, 1.0, 3.0); Assert.assertEquals(Side.MINUS, sc2.side(xzPlane)); SubCircle sc3 = create(Vector3D.PLUS_K, Vector3D.PLUS_I, Vector3D.PLUS_J, 1.0e-10, 5.0, 6.0); Assert.assertEquals(Side.PLUS, sc3.side(xzPlane)); SubCircle sc4 = create(Vector3D.PLUS_J, Vector3D.PLUS_K, Vector3D.PLUS_I, 1.0e-10, 5.0, 6.0); Assert.assertEquals(Side.HYPER, sc4.side(xzPlane)); SubCircle sc5 = create(Vector3D.MINUS_J, Vector3D.PLUS_I, Vector3D.PLUS_K, 1.0e-10, 5.0, 6.0); Assert.assertEquals(Side.HYPER, sc5.side(xzPlane)); }
Example 2
Source File: SubCircleTest.java From astor with GNU General Public License v2.0 | 4 votes |
@Test public void testSPlit() { Circle xzPlane = new Circle(Vector3D.PLUS_J, 1.0e-10); SubCircle sc1 = create(Vector3D.PLUS_K, Vector3D.PLUS_I, Vector3D.PLUS_J, 1.0e-10, 1.0, 3.0, 5.0, 6.0); SplitSubHyperplane<Sphere2D> split1 = sc1.split(xzPlane); ArcsSet plus1 = (ArcsSet) ((SubCircle) split1.getPlus()).getRemainingRegion(); ArcsSet minus1 = (ArcsSet) ((SubCircle) split1.getMinus()).getRemainingRegion(); Assert.assertEquals(1, plus1.asList().size()); Assert.assertEquals(5.0, plus1.asList().get(0).getInf(), 1.0e-10); Assert.assertEquals(6.0, plus1.asList().get(0).getSup(), 1.0e-10); Assert.assertEquals(1, minus1.asList().size()); Assert.assertEquals(1.0, minus1.asList().get(0).getInf(), 1.0e-10); Assert.assertEquals(3.0, minus1.asList().get(0).getSup(), 1.0e-10); SubCircle sc2 = create(Vector3D.PLUS_K, Vector3D.PLUS_I, Vector3D.PLUS_J, 1.0e-10, 1.0, 3.0); SplitSubHyperplane<Sphere2D> split2 = sc2.split(xzPlane); Assert.assertNull(split2.getPlus()); ArcsSet minus2 = (ArcsSet) ((SubCircle) split2.getMinus()).getRemainingRegion(); Assert.assertEquals(1, minus2.asList().size()); Assert.assertEquals(1.0, minus2.asList().get(0).getInf(), 1.0e-10); Assert.assertEquals(3.0, minus2.asList().get(0).getSup(), 1.0e-10); SubCircle sc3 = create(Vector3D.PLUS_K, Vector3D.PLUS_I, Vector3D.PLUS_J, 1.0e-10, 5.0, 6.0); SplitSubHyperplane<Sphere2D> split3 = sc3.split(xzPlane); ArcsSet plus3 = (ArcsSet) ((SubCircle) split3.getPlus()).getRemainingRegion(); Assert.assertEquals(1, plus3.asList().size()); Assert.assertEquals(5.0, plus3.asList().get(0).getInf(), 1.0e-10); Assert.assertEquals(6.0, plus3.asList().get(0).getSup(), 1.0e-10); Assert.assertNull(split3.getMinus()); SubCircle sc4 = create(Vector3D.PLUS_J, Vector3D.PLUS_K, Vector3D.PLUS_I, 1.0e-10, 5.0, 6.0); SplitSubHyperplane<Sphere2D> split4 = sc4.split(xzPlane); Assert.assertEquals(Side.HYPER, sc4.side(xzPlane)); Assert.assertNull(split4.getPlus()); Assert.assertTrue(split4.getMinus() == sc4); SubCircle sc5 = create(Vector3D.MINUS_J, Vector3D.PLUS_I, Vector3D.PLUS_K, 1.0e-10, 5.0, 6.0); SplitSubHyperplane<Sphere2D> split5 = sc5.split(xzPlane); Assert.assertTrue(split5.getPlus() == sc5); Assert.assertNull(split5.getMinus()); }
Example 3
Source File: SphericalPolygonsSetTest.java From astor with GNU General Public License v2.0 | 4 votes |
@Test public void testPositiveOctantByIntersection() { double tol = 0.01; double sinTol = FastMath.sin(tol); RegionFactory<Sphere2D> factory = new RegionFactory<Sphere2D>(); SphericalPolygonsSet plusX = new SphericalPolygonsSet(Vector3D.PLUS_I, tol); SphericalPolygonsSet plusY = new SphericalPolygonsSet(Vector3D.PLUS_J, tol); SphericalPolygonsSet plusZ = new SphericalPolygonsSet(Vector3D.PLUS_K, tol); SphericalPolygonsSet octant = (SphericalPolygonsSet) factory.intersection(factory.intersection(plusX, plusY), plusZ); UnitSphereRandomVectorGenerator random = new UnitSphereRandomVectorGenerator(3, new Well1024a(0x9c9802fde3cbcf25l)); for (int i = 0; i < 1000; ++i) { Vector3D v = new Vector3D(random.nextVector()); if ((v.getX() > sinTol) && (v.getY() > sinTol) && (v.getZ() > sinTol)) { Assert.assertEquals(Location.INSIDE, octant.checkPoint(new S2Point(v))); } else if ((v.getX() < -sinTol) || (v.getY() < -sinTol) || (v.getZ() < -sinTol)) { Assert.assertEquals(Location.OUTSIDE, octant.checkPoint(new S2Point(v))); } else { Assert.assertEquals(Location.BOUNDARY, octant.checkPoint(new S2Point(v))); } } List<Vertex> loops = octant.getBoundaryLoops(); Assert.assertEquals(1, loops.size()); boolean xPFound = false; boolean yPFound = false; boolean zPFound = false; boolean xVFound = false; boolean yVFound = false; boolean zVFound = false; Vertex first = loops.get(0); int count = 0; for (Vertex v = first; count == 0 || v != first; v = v.getOutgoing().getEnd()) { ++count; Edge e = v.getIncoming(); Assert.assertTrue(v == e.getStart().getOutgoing().getEnd()); xPFound = xPFound || e.getCircle().getPole().distance(Vector3D.PLUS_I) < 1.0e-10; yPFound = yPFound || e.getCircle().getPole().distance(Vector3D.PLUS_J) < 1.0e-10; zPFound = zPFound || e.getCircle().getPole().distance(Vector3D.PLUS_K) < 1.0e-10; Assert.assertEquals(0.5 * FastMath.PI, e.getLength(), 1.0e-10); xVFound = xVFound || v.getLocation().getVector().distance(Vector3D.PLUS_I) < 1.0e-10; yVFound = yVFound || v.getLocation().getVector().distance(Vector3D.PLUS_J) < 1.0e-10; zVFound = zVFound || v.getLocation().getVector().distance(Vector3D.PLUS_K) < 1.0e-10; } Assert.assertTrue(xPFound); Assert.assertTrue(yPFound); Assert.assertTrue(zPFound); Assert.assertTrue(xVFound); Assert.assertTrue(yVFound); Assert.assertTrue(zVFound); Assert.assertEquals(3, count); Assert.assertEquals(0.0, ((S2Point) octant.getBarycenter()).distance(new S2Point(new Vector3D(1, 1, 1))), 1.0e-10); Assert.assertEquals(0.5 * FastMath.PI, octant.getSize(), 1.0e-10); EnclosingBall<Sphere2D, S2Point> cap = octant.getEnclosingCap(); Assert.assertEquals(0.0, octant.getBarycenter().distance(cap.getCenter()), 1.0e-10); Assert.assertEquals(FastMath.acos(1.0 / FastMath.sqrt(3)), cap.getRadius(), 1.0e-10); EnclosingBall<Sphere2D, 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(FastMath.PI - FastMath.asin(1.0 / FastMath.sqrt(3)), reversedCap.getRadius(), 1.0e-10); }
Example 4
Source File: SphericalPolygonsSetTest.java From astor with GNU General Public License v2.0 | 4 votes |
@Test public void testNonConvex() { double tol = 0.01; double sinTol = FastMath.sin(tol); RegionFactory<Sphere2D> factory = new RegionFactory<Sphere2D>(); SphericalPolygonsSet plusX = new SphericalPolygonsSet(Vector3D.PLUS_I, tol); SphericalPolygonsSet plusY = new SphericalPolygonsSet(Vector3D.PLUS_J, tol); SphericalPolygonsSet plusZ = new SphericalPolygonsSet(Vector3D.PLUS_K, tol); SphericalPolygonsSet threeOctants = (SphericalPolygonsSet) factory.difference(plusZ, factory.intersection(plusX, plusY)); UnitSphereRandomVectorGenerator random = new UnitSphereRandomVectorGenerator(3, new Well1024a(0x9c9802fde3cbcf25l)); for (int i = 0; i < 1000; ++i) { Vector3D v = new Vector3D(random.nextVector()); if (((v.getX() < -sinTol) || (v.getY() < -sinTol)) && (v.getZ() > sinTol)) { Assert.assertEquals(Location.INSIDE, threeOctants.checkPoint(new S2Point(v))); } else if (((v.getX() > sinTol) && (v.getY() > sinTol)) || (v.getZ() < -sinTol)) { Assert.assertEquals(Location.OUTSIDE, threeOctants.checkPoint(new S2Point(v))); } else { Assert.assertEquals(Location.BOUNDARY, threeOctants.checkPoint(new S2Point(v))); } } List<Vertex> loops = threeOctants.getBoundaryLoops(); Assert.assertEquals(1, loops.size()); boolean xPFound = false; boolean yPFound = false; boolean zPFound = false; boolean xVFound = false; boolean yVFound = false; boolean zVFound = false; Vertex first = loops.get(0); int count = 0; for (Vertex v = first; count == 0 || v != first; v = v.getOutgoing().getEnd()) { ++count; Edge e = v.getIncoming(); Assert.assertTrue(v == e.getStart().getOutgoing().getEnd()); xPFound = xPFound || e.getCircle().getPole().distance(Vector3D.MINUS_I) < 1.0e-10; yPFound = yPFound || e.getCircle().getPole().distance(Vector3D.MINUS_J) < 1.0e-10; zPFound = zPFound || e.getCircle().getPole().distance(Vector3D.PLUS_K) < 1.0e-10; if (Vector3D.PLUS_K.distance(e.getCircle().getPole()) < 1.0e-10) { Assert.assertEquals(1.5 * FastMath.PI, e.getLength(), 1.0e-10); } else { Assert.assertEquals(0.5 * FastMath.PI, e.getLength(), 1.0e-10); } xVFound = xVFound || v.getLocation().getVector().distance(Vector3D.PLUS_I) < 1.0e-10; yVFound = yVFound || v.getLocation().getVector().distance(Vector3D.PLUS_J) < 1.0e-10; zVFound = zVFound || v.getLocation().getVector().distance(Vector3D.PLUS_K) < 1.0e-10; } Assert.assertTrue(xPFound); Assert.assertTrue(yPFound); Assert.assertTrue(zPFound); Assert.assertTrue(xVFound); Assert.assertTrue(yVFound); Assert.assertTrue(zVFound); Assert.assertEquals(3, count); Assert.assertEquals(1.5 * FastMath.PI, threeOctants.getSize(), 1.0e-10); }
Example 5
Source File: SubCircleTest.java From astor with GNU General Public License v2.0 | 4 votes |
@Test public void testSide() { Circle xzPlane = new Circle(Vector3D.PLUS_J, 1.0e-10); SubCircle sc1 = create(Vector3D.PLUS_K, Vector3D.PLUS_I, Vector3D.PLUS_J, 1.0e-10, 1.0, 3.0, 5.0, 6.0); Assert.assertEquals(Side.BOTH, sc1.side(xzPlane)); SubCircle sc2 = create(Vector3D.PLUS_K, Vector3D.PLUS_I, Vector3D.PLUS_J, 1.0e-10, 1.0, 3.0); Assert.assertEquals(Side.MINUS, sc2.side(xzPlane)); SubCircle sc3 = create(Vector3D.PLUS_K, Vector3D.PLUS_I, Vector3D.PLUS_J, 1.0e-10, 5.0, 6.0); Assert.assertEquals(Side.PLUS, sc3.side(xzPlane)); SubCircle sc4 = create(Vector3D.PLUS_J, Vector3D.PLUS_K, Vector3D.PLUS_I, 1.0e-10, 5.0, 6.0); Assert.assertEquals(Side.HYPER, sc4.side(xzPlane)); SubCircle sc5 = create(Vector3D.MINUS_J, Vector3D.PLUS_I, Vector3D.PLUS_K, 1.0e-10, 5.0, 6.0); Assert.assertEquals(Side.HYPER, sc5.side(xzPlane)); }
Example 6
Source File: SubCircleTest.java From astor with GNU General Public License v2.0 | 4 votes |
@Test public void testSPlit() { Circle xzPlane = new Circle(Vector3D.PLUS_J, 1.0e-10); SubCircle sc1 = create(Vector3D.PLUS_K, Vector3D.PLUS_I, Vector3D.PLUS_J, 1.0e-10, 1.0, 3.0, 5.0, 6.0); SplitSubHyperplane<Sphere2D> split1 = sc1.split(xzPlane); ArcsSet plus1 = (ArcsSet) ((SubCircle) split1.getPlus()).getRemainingRegion(); ArcsSet minus1 = (ArcsSet) ((SubCircle) split1.getMinus()).getRemainingRegion(); Assert.assertEquals(1, plus1.asList().size()); Assert.assertEquals(5.0, plus1.asList().get(0).getInf(), 1.0e-10); Assert.assertEquals(6.0, plus1.asList().get(0).getSup(), 1.0e-10); Assert.assertEquals(1, minus1.asList().size()); Assert.assertEquals(1.0, minus1.asList().get(0).getInf(), 1.0e-10); Assert.assertEquals(3.0, minus1.asList().get(0).getSup(), 1.0e-10); SubCircle sc2 = create(Vector3D.PLUS_K, Vector3D.PLUS_I, Vector3D.PLUS_J, 1.0e-10, 1.0, 3.0); SplitSubHyperplane<Sphere2D> split2 = sc2.split(xzPlane); Assert.assertNull(split2.getPlus()); ArcsSet minus2 = (ArcsSet) ((SubCircle) split2.getMinus()).getRemainingRegion(); Assert.assertEquals(1, minus2.asList().size()); Assert.assertEquals(1.0, minus2.asList().get(0).getInf(), 1.0e-10); Assert.assertEquals(3.0, minus2.asList().get(0).getSup(), 1.0e-10); SubCircle sc3 = create(Vector3D.PLUS_K, Vector3D.PLUS_I, Vector3D.PLUS_J, 1.0e-10, 5.0, 6.0); SplitSubHyperplane<Sphere2D> split3 = sc3.split(xzPlane); ArcsSet plus3 = (ArcsSet) ((SubCircle) split3.getPlus()).getRemainingRegion(); Assert.assertEquals(1, plus3.asList().size()); Assert.assertEquals(5.0, plus3.asList().get(0).getInf(), 1.0e-10); Assert.assertEquals(6.0, plus3.asList().get(0).getSup(), 1.0e-10); Assert.assertNull(split3.getMinus()); SubCircle sc4 = create(Vector3D.PLUS_J, Vector3D.PLUS_K, Vector3D.PLUS_I, 1.0e-10, 5.0, 6.0); SplitSubHyperplane<Sphere2D> split4 = sc4.split(xzPlane); Assert.assertEquals(Side.HYPER, sc4.side(xzPlane)); Assert.assertNull(split4.getPlus()); Assert.assertTrue(split4.getMinus() == sc4); SubCircle sc5 = create(Vector3D.MINUS_J, Vector3D.PLUS_I, Vector3D.PLUS_K, 1.0e-10, 5.0, 6.0); SplitSubHyperplane<Sphere2D> split5 = sc5.split(xzPlane); Assert.assertTrue(split5.getPlus() == sc5); Assert.assertNull(split5.getMinus()); }
Example 7
Source File: SphericalPolygonsSetTest.java From astor with GNU General Public License v2.0 | 4 votes |
@Test public void testPositiveOctantByIntersection() { double tol = 0.01; double sinTol = FastMath.sin(tol); RegionFactory<Sphere2D> factory = new RegionFactory<Sphere2D>(); SphericalPolygonsSet plusX = new SphericalPolygonsSet(Vector3D.PLUS_I, tol); SphericalPolygonsSet plusY = new SphericalPolygonsSet(Vector3D.PLUS_J, tol); SphericalPolygonsSet plusZ = new SphericalPolygonsSet(Vector3D.PLUS_K, tol); SphericalPolygonsSet octant = (SphericalPolygonsSet) factory.intersection(factory.intersection(plusX, plusY), plusZ); UnitSphereRandomVectorGenerator random = new UnitSphereRandomVectorGenerator(3, new Well1024a(0x9c9802fde3cbcf25l)); for (int i = 0; i < 1000; ++i) { Vector3D v = new Vector3D(random.nextVector()); if ((v.getX() > sinTol) && (v.getY() > sinTol) && (v.getZ() > sinTol)) { Assert.assertEquals(Location.INSIDE, octant.checkPoint(new S2Point(v))); } else if ((v.getX() < -sinTol) || (v.getY() < -sinTol) || (v.getZ() < -sinTol)) { Assert.assertEquals(Location.OUTSIDE, octant.checkPoint(new S2Point(v))); } else { Assert.assertEquals(Location.BOUNDARY, octant.checkPoint(new S2Point(v))); } } List<Vertex> loops = octant.getBoundaryLoops(); Assert.assertEquals(1, loops.size()); boolean xPFound = false; boolean yPFound = false; boolean zPFound = false; boolean xVFound = false; boolean yVFound = false; boolean zVFound = false; Vertex first = loops.get(0); int count = 0; for (Vertex v = first; count == 0 || v != first; v = v.getOutgoing().getEnd()) { ++count; Edge e = v.getIncoming(); Assert.assertTrue(v == e.getStart().getOutgoing().getEnd()); xPFound = xPFound || e.getCircle().getPole().distance(Vector3D.PLUS_I) < 1.0e-10; yPFound = yPFound || e.getCircle().getPole().distance(Vector3D.PLUS_J) < 1.0e-10; zPFound = zPFound || e.getCircle().getPole().distance(Vector3D.PLUS_K) < 1.0e-10; Assert.assertEquals(0.5 * FastMath.PI, e.getLength(), 1.0e-10); xVFound = xVFound || v.getLocation().getVector().distance(Vector3D.PLUS_I) < 1.0e-10; yVFound = yVFound || v.getLocation().getVector().distance(Vector3D.PLUS_J) < 1.0e-10; zVFound = zVFound || v.getLocation().getVector().distance(Vector3D.PLUS_K) < 1.0e-10; } Assert.assertTrue(xPFound); Assert.assertTrue(yPFound); Assert.assertTrue(zPFound); Assert.assertTrue(xVFound); Assert.assertTrue(yVFound); Assert.assertTrue(zVFound); Assert.assertEquals(3, count); Assert.assertEquals(0.0, ((S2Point) octant.getBarycenter()).distance(new S2Point(new Vector3D(1, 1, 1))), 1.0e-10); Assert.assertEquals(0.5 * FastMath.PI, octant.getSize(), 1.0e-10); EnclosingBall<Sphere2D, S2Point> cap = octant.getEnclosingCap(); Assert.assertEquals(0.0, octant.getBarycenter().distance(cap.getCenter()), 1.0e-10); Assert.assertEquals(FastMath.acos(1.0 / FastMath.sqrt(3)), cap.getRadius(), 1.0e-10); EnclosingBall<Sphere2D, 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(FastMath.PI - FastMath.asin(1.0 / FastMath.sqrt(3)), reversedCap.getRadius(), 1.0e-10); }
Example 8
Source File: SphericalPolygonsSetTest.java From astor with GNU General Public License v2.0 | 4 votes |
@Test public void testNonConvex() { double tol = 0.01; double sinTol = FastMath.sin(tol); RegionFactory<Sphere2D> factory = new RegionFactory<Sphere2D>(); SphericalPolygonsSet plusX = new SphericalPolygonsSet(Vector3D.PLUS_I, tol); SphericalPolygonsSet plusY = new SphericalPolygonsSet(Vector3D.PLUS_J, tol); SphericalPolygonsSet plusZ = new SphericalPolygonsSet(Vector3D.PLUS_K, tol); SphericalPolygonsSet threeOctants = (SphericalPolygonsSet) factory.difference(plusZ, factory.intersection(plusX, plusY)); UnitSphereRandomVectorGenerator random = new UnitSphereRandomVectorGenerator(3, new Well1024a(0x9c9802fde3cbcf25l)); for (int i = 0; i < 1000; ++i) { Vector3D v = new Vector3D(random.nextVector()); if (((v.getX() < -sinTol) || (v.getY() < -sinTol)) && (v.getZ() > sinTol)) { Assert.assertEquals(Location.INSIDE, threeOctants.checkPoint(new S2Point(v))); } else if (((v.getX() > sinTol) && (v.getY() > sinTol)) || (v.getZ() < -sinTol)) { Assert.assertEquals(Location.OUTSIDE, threeOctants.checkPoint(new S2Point(v))); } else { Assert.assertEquals(Location.BOUNDARY, threeOctants.checkPoint(new S2Point(v))); } } List<Vertex> loops = threeOctants.getBoundaryLoops(); Assert.assertEquals(1, loops.size()); boolean xPFound = false; boolean yPFound = false; boolean zPFound = false; boolean xVFound = false; boolean yVFound = false; boolean zVFound = false; Vertex first = loops.get(0); int count = 0; for (Vertex v = first; count == 0 || v != first; v = v.getOutgoing().getEnd()) { ++count; Edge e = v.getIncoming(); Assert.assertTrue(v == e.getStart().getOutgoing().getEnd()); xPFound = xPFound || e.getCircle().getPole().distance(Vector3D.MINUS_I) < 1.0e-10; yPFound = yPFound || e.getCircle().getPole().distance(Vector3D.MINUS_J) < 1.0e-10; zPFound = zPFound || e.getCircle().getPole().distance(Vector3D.PLUS_K) < 1.0e-10; if (Vector3D.PLUS_K.distance(e.getCircle().getPole()) < 1.0e-10) { Assert.assertEquals(1.5 * FastMath.PI, e.getLength(), 1.0e-10); } else { Assert.assertEquals(0.5 * FastMath.PI, e.getLength(), 1.0e-10); } xVFound = xVFound || v.getLocation().getVector().distance(Vector3D.PLUS_I) < 1.0e-10; yVFound = yVFound || v.getLocation().getVector().distance(Vector3D.PLUS_J) < 1.0e-10; zVFound = zVFound || v.getLocation().getVector().distance(Vector3D.PLUS_K) < 1.0e-10; } Assert.assertTrue(xPFound); Assert.assertTrue(yPFound); Assert.assertTrue(zPFound); Assert.assertTrue(xVFound); Assert.assertTrue(yVFound); Assert.assertTrue(zVFound); Assert.assertEquals(3, count); Assert.assertEquals(1.5 * FastMath.PI, threeOctants.getSize(), 1.0e-10); }