cds-astro / cds-healpix-java

The CDS HEALPix library in Java
BSD 3-Clause "New" or "Revised" License
9 stars 9 forks source link

PolygonComputer.overlappingCells can assert false #11

Closed mbtaylor closed 4 years ago

mbtaylor commented 4 years ago

It is (rarely) possible to provoke an AssertionError (if assertions are enabled) while evaluating cells in a polygon:

        double[][] vertices = { 
            {4.695790732486566, 0.8889150097255261},
            {4.4682913488764395, 0.24417985540748033},
            {4.2460276551603116, -0.1307183283958091},
            {3.915276622719796, -0.42958085596528983},
            {3.159957098738856, -0.5694515052059677},
            {3.4232653287700523, -0.8411539982726408},
            {3.5624631270616547, -1.0765021986213243},
            {3.5643253154494583, -1.3247502355595913},
            {7.889934078990009, -1.4138979988201017},
            {5.093052102418385, -1.0463233540993349},
            {5.212197941830804, -0.6180885659230597},
            {5.375096075892637, -0.2088528564758103},
            {5.776366851387001, 0.33400642074068165},
            {5.4196187097295985, 0.35367158642311125},
            {5.171289457253199, 0.45115053076437905},
            {4.947552986866946, 0.6074987013677716},
            {4.695790732486566, 0.8889150097255261},
         };
         Healpix.getNested( 6 ).newPolygonComputer().overlappingCells( vertices );

fails the assert statement at cds.healpix.NewtonMethod.arcSpecialPointInPc(NewtonMethod.java:394). I haven't noticed problems with the call apart from that.

fxpineau commented 4 years ago

I finally manage to re-understand the code and to fix the issue (at least with this specific polygon). So I close the issue, waiting for possibly new pathological polygons...

Completely unrelated, but for my curiosity: I noticed that the first and the last vertices are the same in your polygon, why so?

mbtaylor commented 4 years ago

Thanks for the fix - playing around with the latest version hasn't shown up any similar issues so far.

Regarding the polygon: I did explicitly write code to add this duplicated closing point at some time in the past, so I probably had my reasons, but I can't see what they are now. I've removed it.