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

Matt Juntunen commented on GEOMETRY-100:
----------------------------------------

bq. Yes: I think v1 should not be released with this known bug. Feel free to 
disagree.

I will agree with you on this, especially considering that you were the one who 
requested the release on the dev ML.

bq. Also, Java8's Optional might provide cleaner API than returning null for 
empty/full BSP trees.

I disagree here. This could be a future addition to the API but I don't think 
this should replace the current functionality. A typical usage pattern would be 
to get the desired value and then check if it exists before using it. Use of 
{{Optional}} in these simple cases seems like extra noise. Also, that is quite 
a large change to make at this point.

A few more notes here:
- It's possible that the algorithms are just not very robust when dealing with 
points so close together. We should take a look at ways to increase the 
robustness of the computations. One possible place is 
{{Point2S.from(Vector3D)}}. Here, we normalize the input vector and use that as 
the underlying unit vector for the point. We may get more accuracy by passing 
null for the vector and letting the constructor compute the vector from the 
angles.
- Slightly different results are returned if the rectangle is constructed using 
a {{RegionBSPTree2S}} vs a {{ConvexArea2S}}.
{code:java}
// centroid = (5.0506469268307175, 0.826296679131567)
final ConvexArea2S area = ConvexArea2S.fromVertexLoop(Arrays.asList(
                    Point2S.of(5.050647792392463, 0.8263048984534946),
                    Point2S.of(5.050644504477406, 0.8263064367456399),
                    Point2S.of(5.050649564478115, 0.8263123289902004),
                    Point2S.of(5.050652852378331, 0.8263107907013917)),
                precision);

// centroid = (5.050588136585909, 0.8263123037002262)
final GreatArcPath path = GreatArcPath.fromVertexLoop(Arrays.asList(
                    Point2S.of(5.050647792392463, 0.8263048984534946),
                    Point2S.of(5.050644504477406, 0.8263064367456399),
                    Point2S.of(5.050649564478115, 0.8263123289902004),
                    Point2S.of(5.050652852378331, 0.8263107907013917)),
                precision);
final RegionBSPTree2S tree = path.toTree();
{code}


> Invalid result for small spherical polygons
> -------------------------------------------
>
>                 Key: GEOMETRY-100
>                 URL: https://issues.apache.org/jira/browse/GEOMETRY-100
>             Project: Apache Commons Geometry
>          Issue Type: Bug
>            Reporter: Baljit Singh
>            Priority: Blocker
>             Fix For: 1.0
>
>
> h2. First test case: small spherical rectangle
> * Precision/Tolerance: {{EpsilonDoublePrecisionContext[epsilon= 
> 1.5696101377226165E-12]}}
> * Spherical polygon/rectangle vertices: {{[(5.050647792392463, 
> 0.8263048984534946), (5.050644504477406, 0.8263064367456399), 
> (5.050649564478115, 0.8263123289902004), (5.050652852378331, 
> 0.8263107907013917)]}}
> h4. Centroid:
> * Expected (approximately the average of vertices): {{(5.050648678475973, 
> 0.8263086112510253)}}
> * Actual: {{(5.0506454742491504, 0.8263177505886343)}}
> The difference looks small, however, the actual result is outside the polygon.
> h4. Area (size):
> * Expected: 2.0005645375711432E-11
> * Actual: 1.9971579945377016E-11
> h4. Perimeter (boundary size):
> * Expected: 1.9679779440894825E-5
> * Actual: 1.96697104639384E-5
> h2. Second test case: small circular (sphere) polygon
> * Precision/Tolerance: {{EpsilonDoublePrecisionContext[epsilon= 
> 1.5696101377226165E-12]}}
> * Circle discretized with 100 vertices: center: {{(0.5410520681182421, 
> 1.3962634015954636)}}, radius: {{4.784171699778536E-8}}
> h4. Centroid:
> * Expected (approximately circle center): {{(0.5410520681182421, 
> 1.3962634015954636)}}
> * Actual: {{null}}
> h4. Area (size):
> * Expected: 7.181590857887451E-15
> * Actual: 0.0
> h4. Perimeter (boundary size):
> * Expected: 3.0054894917112657E-7
> * Actual: 3.005489492811408E-7



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

Reply via email to