You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by GitBox <gi...@apache.org> on 2020/01/07 15:21:42 UTC

[GitHub] [commons-geometry] singhbaljit opened a new pull request #51: [GEOMETRY-71] Add test for RegionBSPTree2S barycenter

singhbaljit opened a new pull request #51: [GEOMETRY-71] Add test for RegionBSPTree2S barycenter
URL: https://github.com/apache/commons-geometry/pull/51
 
 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [commons-geometry] singhbaljit commented on issue #51: [GEOMETRY-71] Add test for RegionBSPTree2S barycenter

Posted by GitBox <gi...@apache.org>.
singhbaljit commented on issue #51: [GEOMETRY-71] Add test for RegionBSPTree2S barycenter
URL: https://github.com/apache/commons-geometry/pull/51#issuecomment-572056894
 
 
   Rebased it from the latest master, including the fix in https://github.com/apache/commons-geometry/pull/53.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [commons-geometry] singhbaljit commented on a change in pull request #51: [GEOMETRY-71] Add test for RegionBSPTree2S barycenter

Posted by GitBox <gi...@apache.org>.
singhbaljit commented on a change in pull request #51: [GEOMETRY-71] Add test for RegionBSPTree2S barycenter
URL: https://github.com/apache/commons-geometry/pull/51#discussion_r363913448
 
 

 ##########
 File path: commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/RegionBSPTree2STest.java
 ##########
 @@ -626,6 +626,54 @@ public void testGeographicMap() {
         checkBarycenterConsistency(france);
     }
 
+    @Test
+    public void testCircleToPolygonBarycenter() {
+        double radius = 0.0001;
+        Point2S center = Point2S.of(1.0, 1.0);
+        int numPts = 200;
+
+        // counterclockwise
+        RegionBSPTree2S ccw = circleToPolygon(center, radius, numPts, false);
+        SphericalTestUtils.assertPointsEq(center, ccw.getBarycenter(), BARYCENTER_EPS);
+
+        // clockwise; barycenter should just be antipodal for the circle center
+        RegionBSPTree2S cw = circleToPolygon(center, radius, numPts, true);
+        SphericalTestUtils.assertPointsEq(center.antipodal(), cw.getBarycenter(), BARYCENTER_EPS);
+    }
+
+    @Test
+    public void testCircleToPolygonSize() {
+        double radius = 0.0001;
+        Point2S center = Point2S.of(1.0, 1.0);
+        int numPts = 200;
+
+        // https://en.wikipedia.org/wiki/Spherical_cap
+        double ccw_area = 4.0 * PlaneAngleRadians.PI * Math.pow(Math.sin(radius / 2.0), 2.0);
+        double cw_area = 4.0 * PlaneAngleRadians.PI - ccw_area;
+
+        RegionBSPTree2S ccw = circleToPolygon(center, radius, numPts, false);
+        Assert.assertEquals("Counterclockwise size", ccw_area, ccw.getSize(), TEST_EPS);
+
+        RegionBSPTree2S cw = circleToPolygon(center, radius, numPts, true);
+        Assert.assertEquals("Clockwise size", cw_area, cw.getSize(), TEST_EPS);
+    }
+
+    @Test
+    public void testCircleToPolygonBoundarySize() {
+        double radius = 0.0001;
+        Point2S center = Point2S.of(1.0, 1.0);
+        int numPts = 200;
+
+        // boundary size is independent from winding
+        double boundary = PlaneAngleRadians.TWO_PI * Math.sin(radius);
+
+        RegionBSPTree2S ccw = circleToPolygon(center, radius, numPts, false);
+        Assert.assertEquals("Counterclockwise boundary size", boundary, ccw.getBoundarySize(), TEST_EPS);
+
+        RegionBSPTree2S cw = circleToPolygon(center, radius, numPts, true);
+        Assert.assertEquals("Clockwise boundary size", boundary, cw.getBoundarySize(), TEST_EPS);
 
 Review comment:
   This test is failing.
   
   ```
   Expected :6.283185296707611E-4
   Actual   :6.282926914026013E-4
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [commons-geometry] singhbaljit commented on a change in pull request #51: [GEOMETRY-71] Add test for RegionBSPTree2S barycenter

Posted by GitBox <gi...@apache.org>.
singhbaljit commented on a change in pull request #51: [GEOMETRY-71] Add test for RegionBSPTree2S barycenter
URL: https://github.com/apache/commons-geometry/pull/51#discussion_r363913448
 
 

 ##########
 File path: commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/RegionBSPTree2STest.java
 ##########
 @@ -626,6 +626,54 @@ public void testGeographicMap() {
         checkBarycenterConsistency(france);
     }
 
+    @Test
+    public void testCircleToPolygonBarycenter() {
+        double radius = 0.0001;
+        Point2S center = Point2S.of(1.0, 1.0);
+        int numPts = 200;
+
+        // counterclockwise
+        RegionBSPTree2S ccw = circleToPolygon(center, radius, numPts, false);
+        SphericalTestUtils.assertPointsEq(center, ccw.getBarycenter(), BARYCENTER_EPS);
+
+        // clockwise; barycenter should just be antipodal for the circle center
+        RegionBSPTree2S cw = circleToPolygon(center, radius, numPts, true);
+        SphericalTestUtils.assertPointsEq(center.antipodal(), cw.getBarycenter(), BARYCENTER_EPS);
+    }
+
+    @Test
+    public void testCircleToPolygonSize() {
+        double radius = 0.0001;
+        Point2S center = Point2S.of(1.0, 1.0);
+        int numPts = 200;
+
+        // https://en.wikipedia.org/wiki/Spherical_cap
+        double ccw_area = 4.0 * PlaneAngleRadians.PI * Math.pow(Math.sin(radius / 2.0), 2.0);
+        double cw_area = 4.0 * PlaneAngleRadians.PI - ccw_area;
+
+        RegionBSPTree2S ccw = circleToPolygon(center, radius, numPts, false);
+        Assert.assertEquals("Counterclockwise size", ccw_area, ccw.getSize(), TEST_EPS);
+
+        RegionBSPTree2S cw = circleToPolygon(center, radius, numPts, true);
+        Assert.assertEquals("Clockwise size", cw_area, cw.getSize(), TEST_EPS);
+    }
+
+    @Test
+    public void testCircleToPolygonBoundarySize() {
+        double radius = 0.0001;
+        Point2S center = Point2S.of(1.0, 1.0);
+        int numPts = 200;
+
+        // boundary size is independent from winding
+        double boundary = PlaneAngleRadians.TWO_PI * Math.sin(radius);
+
+        RegionBSPTree2S ccw = circleToPolygon(center, radius, numPts, false);
+        Assert.assertEquals("Counterclockwise boundary size", boundary, ccw.getBoundarySize(), TEST_EPS);
+
+        RegionBSPTree2S cw = circleToPolygon(center, radius, numPts, true);
+        Assert.assertEquals("Clockwise boundary size", boundary, cw.getBoundarySize(), TEST_EPS);
 
 Review comment:
   This test is failing.
   ```
   Expected :6.283185296707611E-4
   Actual   :6.282926914026013E-4
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [commons-geometry] asfgit closed pull request #51: GEOMETRY-71 Fix spherical barycenter algorithm

Posted by GitBox <gi...@apache.org>.
asfgit closed pull request #51: GEOMETRY-71 Fix spherical barycenter algorithm
URL: https://github.com/apache/commons-geometry/pull/51
 
 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [commons-geometry] singhbaljit commented on a change in pull request #51: [GEOMETRY-71] Add test for RegionBSPTree2S barycenter

Posted by GitBox <gi...@apache.org>.
singhbaljit commented on a change in pull request #51: [GEOMETRY-71] Add test for RegionBSPTree2S barycenter
URL: https://github.com/apache/commons-geometry/pull/51#discussion_r363800994
 
 

 ##########
 File path: commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/RegionBSPTree2STest.java
 ##########
 @@ -626,6 +626,17 @@ public void testGeographicMap() {
         checkBarycenterConsistency(france);
     }
 
+    @Test
+    public void testCircleToPolygonBarycenter() {
+        Point2S center = Point2S.of(1.0, 1.0);
+        RegionBSPTree2S ccw = circleToPolygon(center, 0.0001, 200, false);
+        SphericalTestUtils.assertPointsEq(center, ccw.getBarycenter(), BARYCENTER_EPS);
+
+        // clockwise should just be antipodal for the center
+        RegionBSPTree2S cw = circleToPolygon(center, 0.0001, 200, true);
+        SphericalTestUtils.assertPointsEq(center.antipodal(), cw.getBarycenter(), BARYCENTER_EPS);
 
 Review comment:
   This test is currently failing!
   
   `Expected point to be equivalent to (5.283185307179586, 2.141592653589793) but was (5.8884091858825425, 1.8372466013631619)`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [commons-geometry] singhbaljit commented on a change in pull request #51: [GEOMETRY-71] Add test for RegionBSPTree2S barycenter

Posted by GitBox <gi...@apache.org>.
singhbaljit commented on a change in pull request #51: [GEOMETRY-71] Add test for RegionBSPTree2S barycenter
URL: https://github.com/apache/commons-geometry/pull/51#discussion_r363913692
 
 

 ##########
 File path: commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/RegionBSPTree2STest.java
 ##########
 @@ -626,6 +626,54 @@ public void testGeographicMap() {
         checkBarycenterConsistency(france);
     }
 
+    @Test
+    public void testCircleToPolygonBarycenter() {
+        double radius = 0.0001;
+        Point2S center = Point2S.of(1.0, 1.0);
+        int numPts = 200;
+
+        // counterclockwise
+        RegionBSPTree2S ccw = circleToPolygon(center, radius, numPts, false);
+        SphericalTestUtils.assertPointsEq(center, ccw.getBarycenter(), BARYCENTER_EPS);
+
+        // clockwise; barycenter should just be antipodal for the circle center
+        RegionBSPTree2S cw = circleToPolygon(center, radius, numPts, true);
+        SphericalTestUtils.assertPointsEq(center.antipodal(), cw.getBarycenter(), BARYCENTER_EPS);
+    }
+
+    @Test
+    public void testCircleToPolygonSize() {
+        double radius = 0.0001;
+        Point2S center = Point2S.of(1.0, 1.0);
+        int numPts = 200;
+
+        // https://en.wikipedia.org/wiki/Spherical_cap
+        double ccw_area = 4.0 * PlaneAngleRadians.PI * Math.pow(Math.sin(radius / 2.0), 2.0);
+        double cw_area = 4.0 * PlaneAngleRadians.PI - ccw_area;
+
+        RegionBSPTree2S ccw = circleToPolygon(center, radius, numPts, false);
+        Assert.assertEquals("Counterclockwise size", ccw_area, ccw.getSize(), TEST_EPS);
+
+        RegionBSPTree2S cw = circleToPolygon(center, radius, numPts, true);
+        Assert.assertEquals("Clockwise size", cw_area, cw.getSize(), TEST_EPS);
+    }
+
+    @Test
+    public void testCircleToPolygonBoundarySize() {
+        double radius = 0.0001;
+        Point2S center = Point2S.of(1.0, 1.0);
+        int numPts = 200;
+
+        // boundary size is independent from winding
+        double boundary = PlaneAngleRadians.TWO_PI * Math.sin(radius);
+
+        RegionBSPTree2S ccw = circleToPolygon(center, radius, numPts, false);
+        Assert.assertEquals("Counterclockwise boundary size", boundary, ccw.getBoundarySize(), TEST_EPS);
 
 Review comment:
   This test is failing!
   
   ```
   Expected :6.283185296707611E-4
   Actual   :6.282926914327948E-4
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [commons-geometry] singhbaljit commented on a change in pull request #51: [GEOMETRY-71] Add test for RegionBSPTree2S barycenter

Posted by GitBox <gi...@apache.org>.
singhbaljit commented on a change in pull request #51: [GEOMETRY-71] Add test for RegionBSPTree2S barycenter
URL: https://github.com/apache/commons-geometry/pull/51#discussion_r363800994
 
 

 ##########
 File path: commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/RegionBSPTree2STest.java
 ##########
 @@ -626,6 +626,17 @@ public void testGeographicMap() {
         checkBarycenterConsistency(france);
     }
 
+    @Test
+    public void testCircleToPolygonBarycenter() {
+        Point2S center = Point2S.of(1.0, 1.0);
+        RegionBSPTree2S ccw = circleToPolygon(center, 0.0001, 200, false);
+        SphericalTestUtils.assertPointsEq(center, ccw.getBarycenter(), BARYCENTER_EPS);
+
+        // clockwise should just be antipodal for the center
+        RegionBSPTree2S cw = circleToPolygon(center, 0.0001, 200, true);
+        SphericalTestUtils.assertPointsEq(center.antipodal(), cw.getBarycenter(), BARYCENTER_EPS);
 
 Review comment:
   This test is currently failing!

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [commons-geometry] singhbaljit commented on a change in pull request #51: [GEOMETRY-71] Add test for RegionBSPTree2S barycenter

Posted by GitBox <gi...@apache.org>.
singhbaljit commented on a change in pull request #51: [GEOMETRY-71] Add test for RegionBSPTree2S barycenter
URL: https://github.com/apache/commons-geometry/pull/51#discussion_r363913448
 
 

 ##########
 File path: commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/RegionBSPTree2STest.java
 ##########
 @@ -626,6 +626,54 @@ public void testGeographicMap() {
         checkBarycenterConsistency(france);
     }
 
+    @Test
+    public void testCircleToPolygonBarycenter() {
+        double radius = 0.0001;
+        Point2S center = Point2S.of(1.0, 1.0);
+        int numPts = 200;
+
+        // counterclockwise
+        RegionBSPTree2S ccw = circleToPolygon(center, radius, numPts, false);
+        SphericalTestUtils.assertPointsEq(center, ccw.getBarycenter(), BARYCENTER_EPS);
+
+        // clockwise; barycenter should just be antipodal for the circle center
+        RegionBSPTree2S cw = circleToPolygon(center, radius, numPts, true);
+        SphericalTestUtils.assertPointsEq(center.antipodal(), cw.getBarycenter(), BARYCENTER_EPS);
+    }
+
+    @Test
+    public void testCircleToPolygonSize() {
+        double radius = 0.0001;
+        Point2S center = Point2S.of(1.0, 1.0);
+        int numPts = 200;
+
+        // https://en.wikipedia.org/wiki/Spherical_cap
+        double ccw_area = 4.0 * PlaneAngleRadians.PI * Math.pow(Math.sin(radius / 2.0), 2.0);
+        double cw_area = 4.0 * PlaneAngleRadians.PI - ccw_area;
+
+        RegionBSPTree2S ccw = circleToPolygon(center, radius, numPts, false);
+        Assert.assertEquals("Counterclockwise size", ccw_area, ccw.getSize(), TEST_EPS);
+
+        RegionBSPTree2S cw = circleToPolygon(center, radius, numPts, true);
+        Assert.assertEquals("Clockwise size", cw_area, cw.getSize(), TEST_EPS);
+    }
+
+    @Test
+    public void testCircleToPolygonBoundarySize() {
+        double radius = 0.0001;
+        Point2S center = Point2S.of(1.0, 1.0);
+        int numPts = 200;
+
+        // boundary size is independent from winding
+        double boundary = PlaneAngleRadians.TWO_PI * Math.sin(radius);
+
+        RegionBSPTree2S ccw = circleToPolygon(center, radius, numPts, false);
+        Assert.assertEquals("Counterclockwise boundary size", boundary, ccw.getBoundarySize(), TEST_EPS);
+
+        RegionBSPTree2S cw = circleToPolygon(center, radius, numPts, true);
+        Assert.assertEquals("Clockwise boundary size", boundary, cw.getBoundarySize(), TEST_EPS);
 
 Review comment:
   This test is failing.
   ```
   Expected :6.283185296707611E-4
   Actual   :6.282926914327948E-4
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [commons-geometry] singhbaljit commented on a change in pull request #51: [GEOMETRY-71] Add test for RegionBSPTree2S barycenter

Posted by GitBox <gi...@apache.org>.
singhbaljit commented on a change in pull request #51: [GEOMETRY-71] Add test for RegionBSPTree2S barycenter
URL: https://github.com/apache/commons-geometry/pull/51#discussion_r364236321
 
 

 ##########
 File path: commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/RegionBSPTree2STest.java
 ##########
 @@ -626,6 +626,17 @@ public void testGeographicMap() {
         checkBarycenterConsistency(france);
     }
 
+    @Test
+    public void testCircleToPolygonBarycenter() {
+        Point2S center = Point2S.of(1.0, 1.0);
+        RegionBSPTree2S ccw = circleToPolygon(center, 0.0001, 200, false);
+        SphericalTestUtils.assertPointsEq(center, ccw.getBarycenter(), BARYCENTER_EPS);
+
+        // clockwise should just be antipodal for the center
+        RegionBSPTree2S cw = circleToPolygon(center, 0.0001, 200, true);
+        SphericalTestUtils.assertPointsEq(center.antipodal(), cw.getBarycenter(), BARYCENTER_EPS);
 
 Review comment:
   After the fix in https://github.com/apache/commons-geometry/pull/53,
   
   `Expected point to be equivalent to (4.141592653589792, 2.141592653589793) but was (5.8884091858825425, 1.8372466013631619)`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services