[ 
https://issues.apache.org/jira/browse/GEOMETRY-71?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17011943#comment-17011943
 ] 

Baljit Singh edited comment on GEOMETRY-71 at 1/9/20 3:24 PM:
--------------------------------------------------------------

I think I fixed it! Based on what's inside ConvexArea2S, and the code in the 
comments above, barycenter is the vector sum of the pole vector scaled with 
arclength of each edge. However, in RegionBSPTree2S, the code has two issues:

* Conversion to Point2S from barycenter vector causes a loss of information, 
which is the weight barycenter of the ConvexArea2S.
* It sums the ConvexArea2D barycenters with areas. In spherical geometry, it 
seems the boundary/arc length that should be used.

So, I introduced a weighted barycenter. The result seems to work for both CCW 
and CW, and all other tests are passing too. I did increase the tolerance on 
the boundary size test to make it pass, which I think is fine.

I haven't verified other cases (in case they're don't already have unit tests). 
Like, does this algorithm work with polygon holes?

TravisCI seems to be taking a while to run. Things are working locally on my 
end.


was (Author: balsingh):
I think I fixed it! Based on what's inside ConvexArea2S, and the code in the 
comments above, barycenter is the vector sum of the pole vector scaled with 
arclength of each edge. However, in RegionBSPTree2S, the code has two issues:

* Conversion to Point2S from barycenter vector causes a loss of information, 
which is the weight of the ConvexArea2S barycenter.
* It sums the ConvexArea2D barycenters with areas. In spherical geometry, it is 
the boundary/arc length that should be used.

So, I introduced a weighted barycenter. The result seems to work for both CCW 
and CW, and all other tests are passing too. I did increase the tolerance on 
the boundary size test to make it pass, which I think is fine.

I haven't verified other cases (in case they're don't already have unit tests). 
Like, does this algorithm work with polygon holes?

TravisCI seems to be taking a while to run. Things are working locally on my 
end.

> Investigate Spherical Barycenter Accuracy
> -----------------------------------------
>
>                 Key: GEOMETRY-71
>                 URL: https://issues.apache.org/jira/browse/GEOMETRY-71
>             Project: Apache Commons Geometry
>          Issue Type: Bug
>            Reporter: Matt Juntunen
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> The current code for computing spherical barycenters in 
> {{ConvexArea2S.getBarycenter()}} seems to suffer from floating point accuracy 
> issues. The {{ConvexArea2STest.checkBarycenterConsistency()}} method checks 
> the consistency of the barycenter computation of a region by splitting the 
> region into two sections, computing the area and barycenter of each section, 
> and then computing the combined barycenter of the sections by adding the 
> barycenter of each scaled by its corresponding area. It is expected that the 
> combined barycenter computed in this way should equal the barycenter computed 
> for the region as a whole. However, in practice, a large epsilon value is 
> needed in the comparison in order for the tests to pass. We need to 
> investigate why this is the case.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to