You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think there is an issue with the finishing step, namely the finish_edges function.
The following code shows a missing edge (P3/P1) which is removed in finish_edges. Diving in, it seems like an issue with _get_intersection_point.
from foronoi import Voronoi, Polygon
good = [(262, 90), (188, 204), (521, 360), (541, 329), (501, 154)]
bad = [(262, 90), (188, 204), (521, 360), (541, 329), (500, 154)] # last site differs by (1, 0) from the above
polygon = Polygon([(0, 720), (1280, 720), (1280, 0), (0, 0)])
v_good = Voronoi(polygon)
v_good.create_diagram(points=good)
v_bad = Voronoi(polygon)
v_bad.create_diagram(points=bad)
Here are the diagrams (bad to the left, good to the right)
I've tried and changed the _get_intersection_point into:
def _get_intersection_point(self, orig, end):
p = self.points + [self.points[0]]
points = []
point = None
for i in range(0, len(p) - 1):
intersection_point = Algebra.get_intersection(orig, end, p[i], p[i + 1])
if intersection_point:
points.append(intersection_point)
if len(points) == 0:
point = None
elif len(points) == 1: # this is the actual change
point = points[0]
else:
max_distance = Algebra.distance(orig, end)
# Find the intersection point that is furthest away from the start
if points:
distances = [Algebra.distance(orig, p) for p in points]
distances = [i for i in distances if i <= max_distance]
if distances:
point = points[np.argmax(distances)]
return point
This change solves the above case, without breaking any tests. @Yatoom Could you please take a look? Thanks for the lib btw!
The text was updated successfully, but these errors were encountered:
I think there is an issue with the finishing step, namely the finish_edges function.
The following code shows a missing edge (P3/P1) which is removed in finish_edges. Diving in, it seems like an issue with _get_intersection_point.
Here are the diagrams (bad to the left, good to the right)
I've tried and changed the _get_intersection_point into:
This change solves the above case, without breaking any tests.
@Yatoom Could you please take a look? Thanks for the lib btw!
The text was updated successfully, but these errors were encountered: