Is there a set of math equations that can help me determine how to make a mesh or graph from a set of randomised points in 2D or 3D space?

105 Views Asked by At

mesh or graph diagram with nodes and connections

Apologies in advance if this is too broad or to vague a question.

I generate a set of randomised points, let say in 2D space so (x, y).

I want to write code to make lines between points such that I get a graph like the image, but without lines crossing each other as the green dashed lines shown do.

I want to be able to limit the number of points coming into any given node to a maximum number, so at point B the purple line would not be created if the max limit is 9 and the existing lines in image have already been constructed by the algorithm.

I will then animate the points and keep testing that no lines overlap, if so I remove lines until no lines crossing. Also need to define regions in the mesh.

Checking a radius around each point will not necessarily be enough to solve this problem as that doesn't prevent lines crossing or too many lines to a single node or point. Ideally I regularly generate points/nodes with only 3 lines coming into it like point C. Or even exclusively.

Also, as I animate points, I want to test that lines do not become to adjacent to each other as the blue lines from point D when I move it (see second image). Should I test for close to parallel vectors that share points or what?

enter image description here