Detailing

Logo

Adding complexity to polygons.

View the Project on GitHub MichaelMBradley/Detailing

7 May 2021

Graphing 2

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.

A series of short red lines connect from the perimeter of the polygon to the closest circle.

(Lines between circles closest to the polyline in red)

I also wrote code to traverse the circles surrounding the polygon.

A series of red lines connect many 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.

Many circles slowly come together to form one graph.

In the end, it would look something like this (blue for touching circles, red for a possible traversal):

A circle packing around a polygon.

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:

A random circle-packing.

This is roughly what I currently have implemented.

A circle packing only on the inside of the polygon.

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:

Packed circles, some with dashed lines.

This would create a curve that would look something like this:

A curve wraps around some circles.

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: