RE: https://mastodon.gamedev.place/@runevision/115736639369756581

What are good approaches to enforce minimum distances in a simulated web of “springs”?

I have forces that both push and pull to approach an ideal distance between nodes, but avoiding too short distances should take priority over avoiding too long ones. If I just make the pull forces weaker, things converge slower, which is not great.

@runevision one approach I've seen is to make each edge a spring (attracting proportional to length, but then say each vertex is a charge which repels other vertices proportional to 1/distance^2
SpringElectricalEmbedding—Wolfram Documentation

SpringElectricalEmbedding (Graph Layout Method) Vertex layout for GraphLayout. Use spring electrical embedding to lay out vertices of a graph. The spring electrical embedding is a graph-drawing technique to position vertices of a graph so that they minimize mechanical and electrical energy when each vertex has a charge and each edge corresponds to a spring. The spring electrical embedding is typically used to lay out complex large graphs. The layout x_i of the vertices v_i of the graph is calculated by minimizing the energy function UnderscriptBox[\[Sum], i]||f__i|| ^2 with f_i== -C UnderscriptBox[\[Sum], RowBox[{StyleBox[j, TI], !=, StyleBox[i, TI]}]] ( K^2 ) / ( ||x_i-x_j||^2 ) (x_j-x_i) +UnderscriptBox[\[Sum], RowBox[{StyleBox[ , TI], RowBox[{StyleBox[i, TI], StyleBox[ , TI], \[UndirectedEdge], j}]}]] ( ||x_i-x_j|| ) / ( K ) (x_j-x_i). C is a constant that regulates the relative strength of the repulsive force and K is the relative spring length. Vertices can be embedded in \[DoubleStruckCapitalR]^n. The following model parameters can be given: The following graph parameters can be given: Possible settings to control the energy minimization process include: Possible settings to control the layout include: