tdewolff / canvas

Cairo in Go: vector to raster, SVG, PDF, EPS, WASM, OpenGL, Gio, etc.
MIT License
1.46k stars 98 forks source link

Intersection panics #297

Open supertxtnet opened 2 months ago

supertxtnet commented 2 months ago

Experimenting with different map views in the Amsterdam example has led to different panics. Here are some of the panic details.

Path: len=36 data=M-26839.223090777265 106465.85481182295L-26839.22226944103 106465.84274485425L-26839.222602774364 106465.88749485425L-26839.222602196183 106465.8874127033L-26839.223535529516 106466.02824603664L-26839.224995889737 106466.01054301945L-26839.21732922307 106466.05487635279L-26839.22154657948 106466.03869436432L-26839.14781324615 106466.24802769766L-26839.149112711242 106466.24454626566L-26838.97451271124 106466.68704626565A0.1 0.1 0 0 1 -26838.97324978259 106466.69042414996L-26838.860583115922 106467.00917414996L-26838.861519902275 106467.00663383461L-26838.75678656894 106467.27921716795A0.1 0.1 0 0 1 -26838.750133333586 106467.3150833293A0.1 0.1 0 0 1 -26838.943480098227 106467.35094949066L-26839.04821343156 106467.07836615732A0.1 0.1 0 0 1 -26839.049150217914 106467.07582584197L-26839.16181688458 106466.75707584196L-26839.16055395593 106466.76045372627L-26839.335153955933 106466.31795372628A0.1 0.1 0 0 1 -26839.336453421027 106466.31447229428L-26839.410186754358 106466.10513896095A0.1 0.1 0 0 1 -26839.41440411077 106466.08895697248L-26839.422070777437 106466.04462363914A0.1 0.1 0 0 1 -26839.423533333586 106466.0275833293A0.1 0.1 0 0 1 -26839.423531137658 106466.02692062195L-26839.422597804325 106465.88608728861A0.1 0.1 0 0 1 -26839.422597226145 106465.88600513767L-26839.42226389281 106465.84125513767A0.1 0.1 0 0 1 -26839.421442556577 106465.82918816897L-26839.415909223244 106465.78635483564A0.1 0.1 0 0 1 -26839.21673333359 106465.79916666263A0.1 0.1 0 0 1 -26839.21755744393 106465.81197848963z
Intersection 0: seg=(2,35) t=(0.1353824543,0.8597213103) pos=(-26839.22231,106465.8488) dir=(90.42677631°,97.36086783°)
Intersection 1: seg=(2,4) t=(0.999082068,0.0002916460842) pos=(-26839.2226,106465.8875) dir=(90.42677631°,90.37970612°)
Intersection 2: seg=(4,6) t=(0.9366867404,0.1981894691) pos=(-26839.22348,106466.0193) dir=(90.37970612°,80.18874313°)
Intersection 3: seg=(6,8) t=(0.8135054309,0.03780603139) pos=(-26839.21876,106466.0466) dir=(80.18874313°,70.59624282°)
Intersection 4: seg=(8,10) t=(0.9916267979,0.00390653489) pos=(-26839.14843,106466.2463) dir=(70.59624282°,68.46698428°)
Intersection 5: seg=(12,14) t=(0.9959952967,0.004636439702) pos=(-26838.86103,106467.0079) dir=(70.53332946°,68.98197614°)
Intersection 6: seg=(19,21) t=(0.994665631,0.003791082922) pos=(-26839.16122,106466.7588) dir=(250.5333295°,248.4669843°)
Intersection 7: seg=(26,27) t=(0.9999999994,0) pos=(-26839.42353,106466.0276) dir=(270°,270°) tangent
Intersection 8: seg=(26,27) t=(1,1.4906032e-08) pos=(-26839.42353,106466.0276) dir=(270°,270°) tangent
Intersection 9: seg=(27,28) t=(0.9999996487,0) pos=(-26839.42353,106466.0269) dir=(270.379706°,270.3797061°) tangent
panic: Bug found in path intersection code, please report on GitHub at https://github.com/tdewolff/canvas/issues with the path or paths that caused this panic.
Path: len=37 data=M-26839.415909223244 -106365.78635483564L-26839.421442556577 -106365.82918816897A0.1 0.1 0 0 1 -26839.42226389281 -106365.84125513767L-26839.422597226145 -106365.88600513767A0.1 0.1 0 0 1 -26839.422597804325 -106365.88608728861L-26839.423531137658 -106366.02692062195A0.1 0.1 0 0 1 -26839.423533333586 -106366.0275833293A0.1 0.1 0 0 1 -26839.422070777437 -106366.04462363914L-26839.41440411077 -106366.08895697248A0.1 0.1 0 0 1 -26839.410186754358 -106366.10513896095L-26839.336453421027 -106366.31447229428A0.1 0.1 0 0 1 -26839.335153955933 -106366.31795372628L-26839.16055395593 -106366.76045372627L-26839.16181688458 -106366.75707584196L-26839.049150217914 -106367.07582584197A0.1 0.1 0 0 1 -26839.04821343156 -106367.07836615732L-26838.943480098227 -106367.35094949066A0.1 0.1 0 0 1 -26838.750133333586 -106367.3150833293A0.1 0.1 0 0 1 -26838.75678656894 -106367.27921716795L-26838.861519902275 -106367.00663383461L-26838.860583115922 -106367.00917414996L-26838.97324978259 -106366.69042414996A0.1 0.1 0 0 1 -26838.97451271124 -106366.68704626565L-26839.149112711242 -106366.24454626566L-26839.14781324615 -106366.24802769766L-26839.22154657948 -106366.03869436432L-26839.21732922307 -106366.05487635279L-26839.224995889737 -106366.01054301945L-26839.223535529516 -106366.02824603664L-26839.222602196183 -106365.8874127033L-26839.222602774364 -106365.88749485425L-26839.22226944103 -106365.84274485425L-26839.223090777265 -106365.85481182295L-26839.21755744393 -106365.81197848963A0.1 0.1 0 0 1 -26839.21673333359 -106365.79916666263A0.1 0.1 0 0 1 -26839.415909223244 -106365.78635483564z
Intersection 0: seg=(6,7) t=(0.9999996415,0) pos=(-26839.42353,-106366.0276) dir=(270°,270°) tangent
Intersection 1: seg=(6,7) t=(1,1.387491821e-08) pos=(-26839.42353,-106366.0276) dir=(270.0000001°,270.0000001°) tangent
Intersection 2: seg=(12,14) t=(0.9962089171,0.005334368983) pos=(-26839.16122,-106366.7588) dir=(291.5330157°,289.4666705°)
Intersection 3: seg=(19,21) t=(0.9953635603,0.004004703269) pos=(-26838.86103,-106367.0079) dir=(111.0180239°,109.4666705°)
Intersection 4: seg=(23,25) t=(0.9960934651,0.008373202101) pos=(-26839.14843,-106366.2463) dir=(111.5330157°,109.4037572°)
Intersection 5: seg=(25,27) t=(0.9621939686,0.1864945691) pos=(-26839.21876,-106366.0466) dir=(109.4037572°,99.81125687°)
Intersection 6: seg=(27,29) t=(0.8018105309,0.06331325959) pos=(-26839.22348,-106366.0193) dir=(99.81125687°,89.62029388°)
Intersection 7: seg=(29,31) t=(0.9997083539,0.0009179319661) pos=(-26839.2226,-106365.8875) dir=(89.62029388°,89.57322369°)
Intersection 8: seg=(31,33) t=(0.8646175457,0.1402786897) pos=(-26839.22231,-106365.8488) dir=(89.57322369°,82.63913217°)
Intersection 9: seg=(34,35) t=(0.9999999991,0) pos=(-26839.21673,-106365.7992) dir=(90°,90°) tangent
panic: Bug found in path intersection code, please report on GitHub at https://github.com/tdewolff/canvas/issues with the path or paths that caused this panic.
Path: len=11 data=M-26840.14829671525 67.29429651198964A0.25 0.25 0 0 1 -26840.14827655932 67.29487210683011L-26840.052609892653 70.11987210689995A0.25 0.25 0 0 1 -26840.05246666692 70.12833333335584A0.25 0.25 0 0 1 -26840.552323441185 70.13679455981175L-26840.647990107853 67.31179455974188L-26840.647969951922 67.31237015458234L-26840.77423661859 63.821536821296355A0.2500000000008149 0.2500000000008149 0 0 1 -26840.774400000253 63.8125A0.2500000000008149 0.2500000000008149 0 0 1 -26840.274563381918 63.803463178703645z
Intersection 0: seg=(5,7) t=(0.9998981205,8.244026137e-05) pos=(-26840.64798,67.31208237) dir=(268.0604593°,267.9284618°)
Intersection 1: seg=(8,9) t=(0.9999999975,0) pos=(-26840.7744,63.8125) dir=(270°,270°) tangent
panic: Bug found in path intersection code, please report on GitHub at https://github.com/tdewolff/canvas/issues with the path or paths that caused this panic.
tdewolff commented 2 months ago

Thanks for the report as always, I will try and fix those ASAP