boostorg / polygon

Boost.org polygon module
http://boost.org/libs/polygon
57 stars 70 forks source link

[voronoi] issue with pss() #67

Open eadf opened 3 years ago

eadf commented 3 years ago

1.76.0 produces this voronoi output:

1

0
3
673 903 -985 -362
-238 248 -179 453
-136 323 -90 419

1

herepss([-985,-362],[-179,453,-238,248],[673,903,-985,-362]) finds a CE @[-2674.2,1851.9];

1

2

0
3
519 -635 342 -158
-440 707 661 -976
269 -113 507 -171

2

here pss([519,-635],[519,-635,342,-158],[269,-113,507,-171]) finds a CE @ [788.2,-535.1]

2

3

0
3
597 -23 533 65
716 302 455 245
-716 412 999 356

3

here pss([-716,412],[-716,412,999,356],[533,65,597,-23]) finds a CE @ [-784.19,-1676.38]

3

4

in example ”primary_29.txt" pss([-1,1], [0,1,0,0], [0,0,-1,1]) finds a CE @ [-0.59,1.41]

4

In these examples pss() solves for CE solutions where the (infinite line) segments tangents the CE, but the segment falls short of reaching that tangent point.

ghost commented 3 years ago

@eadf have you had a chance to work on a fix for pss()? In any case, I'd be interested to read your thoughts on it (edges cases you've identified etc.)

eadf commented 3 years ago

@vm-am I made an effort to try to figure out the edge cases, but they just kept popping up. For example: if trying to delegate a pss() call to pps() it gladly finds circle events that are too close to the reduced-to-point-segment.

But I will take a look at it again next week or so

ghost commented 3 years ago

@eadf in your example, are both segments missing the circle? Would you please share the input to pss()? I have also been trying to reduce pss() to pps() (as well as sss() to pss() in some cases) by replacing by a point the segment that is the closest to the circle.

It seems to work okay (so far) but I believe we'd better fix this issue during the construction of the circle rather than after the fact and risk to hit more edge cases. @asydorchuk any thoughts?

eadf commented 3 years ago

@vm-am

in your example, are both segments missing the circle?

In my pss() test code I sort the two dot products and run pps() on the segment point with the largest error. But I think I've seen examples of both segments not reaching the CE.

Would you please share the input to pss()?

I've got a pss() example where both segments misses the CE here:

0
3
-5138 -5149 -5038 -5142
-5042 -5069 -5165 -5162
-5011 -5195 -5404 -5134

The code "finds" a circle event at (-4953.51, -5113.77) with site1=(-5038,-5142) site2=(-5011,-5195)(-5404,-5134) site3=(-5165,-5162)(-5042,-5069) double_pss

I believe we'd better fix this issue during the construction of the circle rather than after the fact and risk to hit more edge cases.

☝️ I think replacing pps() with ppp() (or any combination thereof) was a bad idea. The information needed to ensure that the CE circle does not intersect the segment is required (the CE circle should only touch the endpoints or tangent the segment) I've changed my pps() -> ppp() PR accordingly.

Implementing a CE function that takes the length of the segment into consideration the correct way using sqrt_expr_evaluator_XXX() (or something similar) is probably beyond my math skills.