Py2D icon indicating copy to clipboard operation
Py2D copied to clipboard

Polygon.offset UnboundLocalError exception

Open benoitjacquier opened this issue 5 years ago • 1 comments

Hi, The lib can raise UnboundLocalError Exception: local variable 'b' referenced before assignment in the Polygon.offset.find_point_in_poly(pts) function

You can reproduce the issue by adding these points in the Math.Offset example

self.poly.add_point(Vector(373.668226, 168.574425))
self.poly.add_point(Vector(296.092461, 105.675716))
self.poly.add_point(Vector(276.191587, 101.057173))
self.poly.add_point(Vector(273.277250, 116.783745))
self.poly.add_point(Vector(284.042971, 149.605305))
self.poly.add_point(Vector(298.894386, 194.885749))
self.poly.add_point(Vector(314.806373, 203.784994))
self.poly.add_point(Vector(374.497873, 181.460794))

Polygon.simplify_sequence produce an empty polygon in that case. By reducing the EPSILON value used in the distance_point_lineseg_squared comparison ( simplify_sequence func ) to a smaller value ( 0.00000001), everything seems to be fine. 0.001 epsilon seems a bit large for squared distance comparison. Is it a fix or am I missing something ?

Thanks for your help ( and for the lib! )

benoitjacquier avatar Feb 08 '20 16:02 benoitjacquier

Hi @benoitjacquier, we're facing the same issue. How did you resolve it, was changing EPSILON a final solution?

karl-schulz avatar Nov 02 '23 06:11 karl-schulz