google / s2geometry

Computational geometry and spatial indexing on the sphere
http://s2geometry.io/
Apache License 2.0
2.29k stars 302 forks source link

problem with S2loop::init #336

Open catmagic opened 8 months ago

catmagic commented 8 months ago

Hi, the program crashes on the correct data, namely, a call on a very narrow quadrilateral causes a crash and the error: ERROR Edge 1 crosses edge 3. this is the quadrilateral -1.0780749761978428 1.4688488034282494 -1.0780759735047707 1.4666611693199976 -0.981471670584179 -3.0839249353037306 -0.9814705651439662 -3.081737300942303

smcallis commented 8 months ago

So edges 1 and 3 would be edges:

(-1.0780759735047707, 1.4666611693199976)-(-0.981471670584179, -3.0839249353037306) and 
(-0.9814705651439662, -3.081737300942303)-(-1.0780749761978428, 1.4688488034282494) 

which don't cross when I test them manually.

Can you print the individual S2Points that form the polygon with fprintf(stderr, "%.18e %.18e %.18e\n", pnt.x(), pnt.y(), pnt.z());? That'll give me full precision on the actual points in the polygon so I can check them.

jmr commented 7 months ago

@catmagic Alternatively, can you add a test case to s2loop_test.cc that demonstrates the problem? Having runnable code will make this easier to debug.