Java Code Examples for org.apache.commons.math3.geometry.partitioning.Region#Location

The following examples show how to use org.apache.commons.math3.geometry.partitioning.Region#Location . 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: PolyhedronsSetTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testBox() {
    PolyhedronsSet tree = new PolyhedronsSet(0, 1, 0, 1, 0, 1);
    Assert.assertEquals(1.0, tree.getSize(), 1.0e-10);
    Assert.assertEquals(6.0, tree.getBoundarySize(), 1.0e-10);
    Vector3D barycenter = (Vector3D) tree.getBarycenter();
    Assert.assertEquals(0.5, barycenter.getX(), 1.0e-10);
    Assert.assertEquals(0.5, barycenter.getY(), 1.0e-10);
    Assert.assertEquals(0.5, barycenter.getZ(), 1.0e-10);
    for (double x = -0.25; x < 1.25; x += 0.1) {
        boolean xOK = (x >= 0.0) && (x <= 1.0);
        for (double y = -0.25; y < 1.25; y += 0.1) {
            boolean yOK = (y >= 0.0) && (y <= 1.0);
            for (double z = -0.25; z < 1.25; z += 0.1) {
                boolean zOK = (z >= 0.0) && (z <= 1.0);
                Region.Location expected =
                    (xOK && yOK && zOK) ? Region.Location.INSIDE : Region.Location.OUTSIDE;
                Assert.assertEquals(expected, tree.checkPoint(new Vector3D(x, y, z)));
            }
        }
    }
    checkPoints(Region.Location.BOUNDARY, tree, new Vector3D[] {
        new Vector3D(0.0, 0.5, 0.5),
        new Vector3D(1.0, 0.5, 0.5),
        new Vector3D(0.5, 0.0, 0.5),
        new Vector3D(0.5, 1.0, 0.5),
        new Vector3D(0.5, 0.5, 0.0),
        new Vector3D(0.5, 0.5, 1.0)
    });
    checkPoints(Region.Location.OUTSIDE, tree, new Vector3D[] {
        new Vector3D(0.0, 1.2, 1.2),
        new Vector3D(1.0, 1.2, 1.2),
        new Vector3D(1.2, 0.0, 1.2),
        new Vector3D(1.2, 1.0, 1.2),
        new Vector3D(1.2, 1.2, 0.0),
        new Vector3D(1.2, 1.2, 1.0)
    });
}
 
Example 2
Source File: PolyhedronsSetTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testBox() {
    PolyhedronsSet tree = new PolyhedronsSet(0, 1, 0, 1, 0, 1);
    Assert.assertEquals(1.0, tree.getSize(), 1.0e-10);
    Assert.assertEquals(6.0, tree.getBoundarySize(), 1.0e-10);
    Vector3D barycenter = (Vector3D) tree.getBarycenter();
    Assert.assertEquals(0.5, barycenter.getX(), 1.0e-10);
    Assert.assertEquals(0.5, barycenter.getY(), 1.0e-10);
    Assert.assertEquals(0.5, barycenter.getZ(), 1.0e-10);
    for (double x = -0.25; x < 1.25; x += 0.1) {
        boolean xOK = (x >= 0.0) && (x <= 1.0);
        for (double y = -0.25; y < 1.25; y += 0.1) {
            boolean yOK = (y >= 0.0) && (y <= 1.0);
            for (double z = -0.25; z < 1.25; z += 0.1) {
                boolean zOK = (z >= 0.0) && (z <= 1.0);
                Region.Location expected =
                    (xOK && yOK && zOK) ? Region.Location.INSIDE : Region.Location.OUTSIDE;
                Assert.assertEquals(expected, tree.checkPoint(new Vector3D(x, y, z)));
            }
        }
    }
    checkPoints(Region.Location.BOUNDARY, tree, new Vector3D[] {
        new Vector3D(0.0, 0.5, 0.5),
        new Vector3D(1.0, 0.5, 0.5),
        new Vector3D(0.5, 0.0, 0.5),
        new Vector3D(0.5, 1.0, 0.5),
        new Vector3D(0.5, 0.5, 0.0),
        new Vector3D(0.5, 0.5, 1.0)
    });
    checkPoints(Region.Location.OUTSIDE, tree, new Vector3D[] {
        new Vector3D(0.0, 1.2, 1.2),
        new Vector3D(1.0, 1.2, 1.2),
        new Vector3D(1.2, 0.0, 1.2),
        new Vector3D(1.2, 1.0, 1.2),
        new Vector3D(1.2, 1.2, 0.0),
        new Vector3D(1.2, 1.2, 1.0)
    });
}
 
Example 3
Source File: PolyhedronsSetTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testBox() {
    PolyhedronsSet tree = new PolyhedronsSet(0, 1, 0, 1, 0, 1);
    Assert.assertEquals(1.0, tree.getSize(), 1.0e-10);
    Assert.assertEquals(6.0, tree.getBoundarySize(), 1.0e-10);
    Vector3D barycenter = (Vector3D) tree.getBarycenter();
    Assert.assertEquals(0.5, barycenter.getX(), 1.0e-10);
    Assert.assertEquals(0.5, barycenter.getY(), 1.0e-10);
    Assert.assertEquals(0.5, barycenter.getZ(), 1.0e-10);
    for (double x = -0.25; x < 1.25; x += 0.1) {
        boolean xOK = (x >= 0.0) && (x <= 1.0);
        for (double y = -0.25; y < 1.25; y += 0.1) {
            boolean yOK = (y >= 0.0) && (y <= 1.0);
            for (double z = -0.25; z < 1.25; z += 0.1) {
                boolean zOK = (z >= 0.0) && (z <= 1.0);
                Region.Location expected =
                    (xOK && yOK && zOK) ? Region.Location.INSIDE : Region.Location.OUTSIDE;
                Assert.assertEquals(expected, tree.checkPoint(new Vector3D(x, y, z)));
            }
        }
    }
    checkPoints(Region.Location.BOUNDARY, tree, new Vector3D[] {
        new Vector3D(0.0, 0.5, 0.5),
        new Vector3D(1.0, 0.5, 0.5),
        new Vector3D(0.5, 0.0, 0.5),
        new Vector3D(0.5, 1.0, 0.5),
        new Vector3D(0.5, 0.5, 0.0),
        new Vector3D(0.5, 0.5, 1.0)
    });
    checkPoints(Region.Location.OUTSIDE, tree, new Vector3D[] {
        new Vector3D(0.0, 1.2, 1.2),
        new Vector3D(1.0, 1.2, 1.2),
        new Vector3D(1.2, 0.0, 1.2),
        new Vector3D(1.2, 1.0, 1.2),
        new Vector3D(1.2, 1.2, 0.0),
        new Vector3D(1.2, 1.2, 1.0)
    });
}
 
Example 4
Source File: PolyhedronsSetTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testBox() {
    PolyhedronsSet tree = new PolyhedronsSet(0, 1, 0, 1, 0, 1);
    Assert.assertEquals(1.0, tree.getSize(), 1.0e-10);
    Assert.assertEquals(6.0, tree.getBoundarySize(), 1.0e-10);
    Vector3D barycenter = (Vector3D) tree.getBarycenter();
    Assert.assertEquals(0.5, barycenter.getX(), 1.0e-10);
    Assert.assertEquals(0.5, barycenter.getY(), 1.0e-10);
    Assert.assertEquals(0.5, barycenter.getZ(), 1.0e-10);
    for (double x = -0.25; x < 1.25; x += 0.1) {
        boolean xOK = (x >= 0.0) && (x <= 1.0);
        for (double y = -0.25; y < 1.25; y += 0.1) {
            boolean yOK = (y >= 0.0) && (y <= 1.0);
            for (double z = -0.25; z < 1.25; z += 0.1) {
                boolean zOK = (z >= 0.0) && (z <= 1.0);
                Region.Location expected =
                    (xOK && yOK && zOK) ? Region.Location.INSIDE : Region.Location.OUTSIDE;
                Assert.assertEquals(expected, tree.checkPoint(new Vector3D(x, y, z)));
            }
        }
    }
    checkPoints(Region.Location.BOUNDARY, tree, new Vector3D[] {
        new Vector3D(0.0, 0.5, 0.5),
        new Vector3D(1.0, 0.5, 0.5),
        new Vector3D(0.5, 0.0, 0.5),
        new Vector3D(0.5, 1.0, 0.5),
        new Vector3D(0.5, 0.5, 0.0),
        new Vector3D(0.5, 0.5, 1.0)
    });
    checkPoints(Region.Location.OUTSIDE, tree, new Vector3D[] {
        new Vector3D(0.0, 1.2, 1.2),
        new Vector3D(1.0, 1.2, 1.2),
        new Vector3D(1.2, 0.0, 1.2),
        new Vector3D(1.2, 1.0, 1.2),
        new Vector3D(1.2, 1.2, 0.0),
        new Vector3D(1.2, 1.2, 1.0)
    });
}
 
Example 5
Source File: PolyhedronsSetTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testBox() {
    PolyhedronsSet tree = new PolyhedronsSet(0, 1, 0, 1, 0, 1, 1.0e-10);
    Assert.assertEquals(1.0, tree.getSize(), 1.0e-10);
    Assert.assertEquals(6.0, tree.getBoundarySize(), 1.0e-10);
    Vector3D barycenter = (Vector3D) tree.getBarycenter();
    Assert.assertEquals(0.5, barycenter.getX(), 1.0e-10);
    Assert.assertEquals(0.5, barycenter.getY(), 1.0e-10);
    Assert.assertEquals(0.5, barycenter.getZ(), 1.0e-10);
    for (double x = -0.25; x < 1.25; x += 0.1) {
        boolean xOK = (x >= 0.0) && (x <= 1.0);
        for (double y = -0.25; y < 1.25; y += 0.1) {
            boolean yOK = (y >= 0.0) && (y <= 1.0);
            for (double z = -0.25; z < 1.25; z += 0.1) {
                boolean zOK = (z >= 0.0) && (z <= 1.0);
                Region.Location expected =
                    (xOK && yOK && zOK) ? Region.Location.INSIDE : Region.Location.OUTSIDE;
                Assert.assertEquals(expected, tree.checkPoint(new Vector3D(x, y, z)));
            }
        }
    }
    checkPoints(Region.Location.BOUNDARY, tree, new Vector3D[] {
        new Vector3D(0.0, 0.5, 0.5),
        new Vector3D(1.0, 0.5, 0.5),
        new Vector3D(0.5, 0.0, 0.5),
        new Vector3D(0.5, 1.0, 0.5),
        new Vector3D(0.5, 0.5, 0.0),
        new Vector3D(0.5, 0.5, 1.0)
    });
    checkPoints(Region.Location.OUTSIDE, tree, new Vector3D[] {
        new Vector3D(0.0, 1.2, 1.2),
        new Vector3D(1.0, 1.2, 1.2),
        new Vector3D(1.2, 0.0, 1.2),
        new Vector3D(1.2, 1.0, 1.2),
        new Vector3D(1.2, 1.2, 0.0),
        new Vector3D(1.2, 1.2, 1.0)
    });
}
 
Example 6
Source File: PolyhedronsSetTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testBox() {
    PolyhedronsSet tree = new PolyhedronsSet(0, 1, 0, 1, 0, 1);
    Assert.assertEquals(1.0, tree.getSize(), 1.0e-10);
    Assert.assertEquals(6.0, tree.getBoundarySize(), 1.0e-10);
    Vector3D barycenter = (Vector3D) tree.getBarycenter();
    Assert.assertEquals(0.5, barycenter.getX(), 1.0e-10);
    Assert.assertEquals(0.5, barycenter.getY(), 1.0e-10);
    Assert.assertEquals(0.5, barycenter.getZ(), 1.0e-10);
    for (double x = -0.25; x < 1.25; x += 0.1) {
        boolean xOK = (x >= 0.0) && (x <= 1.0);
        for (double y = -0.25; y < 1.25; y += 0.1) {
            boolean yOK = (y >= 0.0) && (y <= 1.0);
            for (double z = -0.25; z < 1.25; z += 0.1) {
                boolean zOK = (z >= 0.0) && (z <= 1.0);
                Region.Location expected =
                    (xOK && yOK && zOK) ? Region.Location.INSIDE : Region.Location.OUTSIDE;
                Assert.assertEquals(expected, tree.checkPoint(new Vector3D(x, y, z)));
            }
        }
    }
    checkPoints(Region.Location.BOUNDARY, tree, new Vector3D[] {
        new Vector3D(0.0, 0.5, 0.5),
        new Vector3D(1.0, 0.5, 0.5),
        new Vector3D(0.5, 0.0, 0.5),
        new Vector3D(0.5, 1.0, 0.5),
        new Vector3D(0.5, 0.5, 0.0),
        new Vector3D(0.5, 0.5, 1.0)
    });
    checkPoints(Region.Location.OUTSIDE, tree, new Vector3D[] {
        new Vector3D(0.0, 1.2, 1.2),
        new Vector3D(1.0, 1.2, 1.2),
        new Vector3D(1.2, 0.0, 1.2),
        new Vector3D(1.2, 1.0, 1.2),
        new Vector3D(1.2, 1.2, 0.0),
        new Vector3D(1.2, 1.2, 1.0)
    });
}
 
Example 7
Source File: PolyhedronsSetTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testBox() {
    PolyhedronsSet tree = new PolyhedronsSet(0, 1, 0, 1, 0, 1, 1.0e-10);
    Assert.assertEquals(1.0, tree.getSize(), 1.0e-10);
    Assert.assertEquals(6.0, tree.getBoundarySize(), 1.0e-10);
    Vector3D barycenter = (Vector3D) tree.getBarycenter();
    Assert.assertEquals(0.5, barycenter.getX(), 1.0e-10);
    Assert.assertEquals(0.5, barycenter.getY(), 1.0e-10);
    Assert.assertEquals(0.5, barycenter.getZ(), 1.0e-10);
    for (double x = -0.25; x < 1.25; x += 0.1) {
        boolean xOK = (x >= 0.0) && (x <= 1.0);
        for (double y = -0.25; y < 1.25; y += 0.1) {
            boolean yOK = (y >= 0.0) && (y <= 1.0);
            for (double z = -0.25; z < 1.25; z += 0.1) {
                boolean zOK = (z >= 0.0) && (z <= 1.0);
                Region.Location expected =
                    (xOK && yOK && zOK) ? Region.Location.INSIDE : Region.Location.OUTSIDE;
                Assert.assertEquals(expected, tree.checkPoint(new Vector3D(x, y, z)));
            }
        }
    }
    checkPoints(Region.Location.BOUNDARY, tree, new Vector3D[] {
        new Vector3D(0.0, 0.5, 0.5),
        new Vector3D(1.0, 0.5, 0.5),
        new Vector3D(0.5, 0.0, 0.5),
        new Vector3D(0.5, 1.0, 0.5),
        new Vector3D(0.5, 0.5, 0.0),
        new Vector3D(0.5, 0.5, 1.0)
    });
    checkPoints(Region.Location.OUTSIDE, tree, new Vector3D[] {
        new Vector3D(0.0, 1.2, 1.2),
        new Vector3D(1.0, 1.2, 1.2),
        new Vector3D(1.2, 0.0, 1.2),
        new Vector3D(1.2, 1.0, 1.2),
        new Vector3D(1.2, 1.2, 0.0),
        new Vector3D(1.2, 1.2, 1.0)
    });
}
 
Example 8
Source File: PolyhedronsSetTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testBox() {
    PolyhedronsSet tree = new PolyhedronsSet(0, 1, 0, 1, 0, 1);
    Assert.assertEquals(1.0, tree.getSize(), 1.0e-10);
    Assert.assertEquals(6.0, tree.getBoundarySize(), 1.0e-10);
    Vector3D barycenter = (Vector3D) tree.getBarycenter();
    Assert.assertEquals(0.5, barycenter.getX(), 1.0e-10);
    Assert.assertEquals(0.5, barycenter.getY(), 1.0e-10);
    Assert.assertEquals(0.5, barycenter.getZ(), 1.0e-10);
    for (double x = -0.25; x < 1.25; x += 0.1) {
        boolean xOK = (x >= 0.0) && (x <= 1.0);
        for (double y = -0.25; y < 1.25; y += 0.1) {
            boolean yOK = (y >= 0.0) && (y <= 1.0);
            for (double z = -0.25; z < 1.25; z += 0.1) {
                boolean zOK = (z >= 0.0) && (z <= 1.0);
                Region.Location expected =
                    (xOK && yOK && zOK) ? Region.Location.INSIDE : Region.Location.OUTSIDE;
                Assert.assertEquals(expected, tree.checkPoint(new Vector3D(x, y, z)));
            }
        }
    }
    checkPoints(Region.Location.BOUNDARY, tree, new Vector3D[] {
        new Vector3D(0.0, 0.5, 0.5),
        new Vector3D(1.0, 0.5, 0.5),
        new Vector3D(0.5, 0.0, 0.5),
        new Vector3D(0.5, 1.0, 0.5),
        new Vector3D(0.5, 0.5, 0.0),
        new Vector3D(0.5, 0.5, 1.0)
    });
    checkPoints(Region.Location.OUTSIDE, tree, new Vector3D[] {
        new Vector3D(0.0, 1.2, 1.2),
        new Vector3D(1.0, 1.2, 1.2),
        new Vector3D(1.2, 0.0, 1.2),
        new Vector3D(1.2, 1.0, 1.2),
        new Vector3D(1.2, 1.2, 0.0),
        new Vector3D(1.2, 1.2, 1.0)
    });
}
 
Example 9
Source File: PolyhedronsSetTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
private void checkPoints(Region.Location expected, PolyhedronsSet tree, Vector3D[] points) {
    for (int i = 0; i < points.length; ++i) {
        Assert.assertEquals(expected, tree.checkPoint(points[i]));
    }
}
 
Example 10
Source File: PolyhedronsSetTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
private void checkPoints(Region.Location expected, PolyhedronsSet tree, Vector3D[] points) {
    for (int i = 0; i < points.length; ++i) {
        Assert.assertEquals(expected, tree.checkPoint(points[i]));
    }
}
 
Example 11
Source File: PolygonsSetTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
private void checkPoints(Region.Location expected, PolygonsSet set,
                         Vector2D[] points) {
    for (int i = 0; i < points.length; ++i) {
        Assert.assertEquals(expected, set.checkPoint(points[i]));
    }
}
 
Example 12
Source File: PolyhedronsSetTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
private void checkPoints(Region.Location expected, PolyhedronsSet tree, Vector3D[] points) {
    for (int i = 0; i < points.length; ++i) {
        Assert.assertEquals(expected, tree.checkPoint(points[i]));
    }
}
 
Example 13
Source File: PolyhedronsSetTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
private void checkPoints(Region.Location expected, PolyhedronsSet tree, Vector3D[] points) {
    for (int i = 0; i < points.length; ++i) {
        Assert.assertEquals(expected, tree.checkPoint(points[i]));
    }
}
 
Example 14
Source File: PolygonsSetTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
private void checkPoints(Region.Location expected, PolygonsSet set,
                         Vector2D[] points) {
    for (int i = 0; i < points.length; ++i) {
        Assert.assertEquals(expected, set.checkPoint(points[i]));
    }
}
 
Example 15
Source File: PolygonsSetTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
private void checkPoints(Region.Location expected, PolygonsSet set,
                         Vector2D[] points) {
    for (int i = 0; i < points.length; ++i) {
        Assert.assertEquals(expected, set.checkPoint(points[i]));
    }
}
 
Example 16
Source File: PolyhedronsSetTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
private void checkPoints(Region.Location expected, PolyhedronsSet tree, Vector3D[] points) {
    for (int i = 0; i < points.length; ++i) {
        Assert.assertEquals(expected, tree.checkPoint(points[i]));
    }
}
 
Example 17
Source File: PolygonsSetTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
private void checkPoints(Region.Location expected, PolygonsSet set,
                         Vector2D[] points) {
    for (int i = 0; i < points.length; ++i) {
        Assert.assertEquals(expected, set.checkPoint(points[i]));
    }
}
 
Example 18
Source File: PolyhedronsSetTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
private void checkPoints(Region.Location expected, PolyhedronsSet tree, Vector3D[] points) {
    for (int i = 0; i < points.length; ++i) {
        Assert.assertEquals(expected, tree.checkPoint(points[i]));
    }
}
 
Example 19
Source File: PolygonsSetTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
private void checkPoints(Region.Location expected, PolygonsSet set,
                         Vector2D[] points) {
    for (int i = 0; i < points.length; ++i) {
        Assert.assertEquals(expected, set.checkPoint(points[i]));
    }
}
 
Example 20
Source File: PolyhedronsSetTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
private void checkPoints(Region.Location expected, PolyhedronsSet tree, Vector3D[] points) {
    for (int i = 0; i < points.length; ++i) {
        Assert.assertEquals(expected, tree.checkPoint(points[i]));
    }
}