Adding complexity to polygons.
by Michael Bradley
Yesterday I wrote code to find the closest circle at a series of points along the perimeter of the polygon. While this could be used to determine which circle a curve approximating the polyline should be based on locally, I don’t think that I will actually use this. Instead, I will likely choose which circle to focus on based on a graph or tree. In any case, the code could be useful at a later date.
(Lines between circles closest to the polyline in red)
I also wrote code to traverse the circles surrounding the polygon.
The code chooses ach new circle based on it minimizing both the distance from the current circle, and the angle between it and the target vertex. Once the code chooses a circle close enough to the target vertex, it targets the next vertex.
Unfortunately, I also likely will not end up using this code as it doesn’t respect the graph I’ve created from the generated circles. Again, parts of the code may still be reused in a later traversal algorithm.
More importantly, I managed to combine the various discrete groups of touching circles into one graph by just moving them to touch their closest neighbour.
In the end, it would look something like this (blue for touching circles, red for a possible traversal):
As for strategies, I’ve both been focusing on circle-packing and on how to draw the new curve. Below are a couple more possible strategies:
This is roughly what I currently have implemented.
This strategy would certainly be simpler, as you could simply calculate the arc closer to the edge and follow that until the next circle.
Speaking of swapping circles, my current thought is to switch to another (newly generated) circle packed against the two circles that I’m trying to switch between, like so:
This would create a curve that would look something like this:
My next steps are to create a traversal strategy between touching circles, as well as looking into other ideas such as inducing a graph with a Delaunay Triangulation.
I am also switching to Java, primarily to get access to more libraries, but I’m also finding that rewriting my code can significantly improve efficiency and prune unnecessary time-wasters
tags: