Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modification to physics based layouter #42

Open
KayakSnail opened this issue Jul 25, 2019 · 5 comments
Open

Modification to physics based layouter #42

KayakSnail opened this issue Jul 25, 2019 · 5 comments

Comments

@KayakSnail
Copy link

I notice that your repulsion force is proportional to 1/Distance. this is causing unconnected nodes to get ejected from a local group quite drastically. I would propose increasing the repulsion coefficent slightly and making the force proportional to 1/Distance^2 (similar to how gravity attracts). you cold then increase the friction component so that nodes slow down faster.

@Wouterdek
Copy link
Owner

Do you have a set of parameters that you would recommend? I've played around with it a bit, but can't find a setup that works very well. (Nodes still fly off when unconnected) Might be caused by a bug somewhere, since intuitively the friction should stop them sometime, but increasing friction has barely any impact.

@KayakSnail
Copy link
Author

Unfortunately I've not been able to compile the code to test (let's not solve that here).

Looking over what you have written I can't see anything obviously wrong. I would set up a very simple simulation with 2 unconnected nodes (one fixed position) and see at what distance friction overcomes reupulsion. It may be necessary to have repulsion fall off more rapidly, which will require smaller spring constant once connected.

@KayakSnail
Copy link
Author

I've finally managed to find some time to take a look at this and to get it working.

I have a couple of proposed changes (locally) but I'm not quite sure how to create a pull request for it. Is this a setting on your end or am I doing something wrong my end I wonder.

In brief:

  1. I've changed the Repulsion section to be based on an inverse gravity model (F=Gm1m2/r^2)
  2. There was a small bug in the friction section which was causing nodes to never stop moving (Friction was being set to the minimum of the Kinetic and the Repulsion+Spring values). Presumably this was to stop the Friction component from making the node move in the opposite direction?
  3. Removed the FrictionVector normalisation. Now the friction is proportional to the nodes velocity such that very fast nodes slow down and very slow nodes don't suddenly change direction (see 2. above)

@Wouterdek
Copy link
Owner

I fixed item 2 in commit aa35e0b, thanks for that. The other two suggestions seem to produce unstable results for me, for example when piling nodes on top of eachother. However, in my limited testing it seems like it already works pretty good by just fixing the friction?

@KayakSnail
Copy link
Author

Fix worked to an extent for me. Now nodes don't ping off into the distance. However, nodes do now 'jitter' when the friction force is larger than the repulsion force and the node is nearly at rest. I.e. the friction component is causing a node to accelerate in the opposite direction. I would still reccomend removing the normalisation so that very slow moving nodes don't suddenly change direction due to friction forces alone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants