# How to apply numerical integration on a graph layout

I've done some basic 1 D integration, but i can't wrap my head around things and apply it to my graph layout. So, consider the picture below:

• if i drag the red node to the right, i'm forcing his position to my mouse position
• the other nodes will "follow" him, but how ?

For Verlet, to compute the newPosition, i need the acceleration for every node and the currentPosition. That is what i don't understand.

How to i compute the acceleration and the currentPosition ?

The currentPosition will be the position of the RedNode ? If yes, doesn't that means that they will all overlap ?

http://i.stack.imgur.com/NCKmO.jpg

• As it stands the question doesn't make sense. Are the nodes connected by joints or springs? Do you use a physics engine? When you say "force its position to the new mouse position" then you set its position directly bypassing the physics system? Then you need some sorts of springs that apply forces to the other nodes to make them follow. – Maik Semder Apr 23 '11 at 12:06
• Yes, the nodes will be connected with springs. – Cumatru Apr 23 '11 at 12:16
• And what is your question exactly? How to write the source for those springs? Do you have them already? What do you have so far? Any Physics-Engine? It helps us help you if you answer those questions. – Maik Semder Apr 23 '11 at 12:29
• I've coded ( in Java ) the static part of the graph-layout. Nodes and lines between nodes. I can't code the physics because i don't understand what i have to code. – Cumatru Apr 23 '11 at 13:28
• Ok then you should use a Physics Engine, here is a popular one for 2D: Box2D Home, Manual and another popular one for 3D: Bullet Physics Home, Manual – Maik Semder Apr 23 '11 at 13:46

If I understand your question right and you want to connect the nodes by springs, that apply forces when the spring is not at its rest-length (in other words when you drag it), then look at Hook's Law, it explains the mechanics and forces of springs.

But you will need any kind of physics-engine.

How to i compute the acceleration and the currentPosition ?

Using Hook's Law:

F = -kx
A = F/m


Here you can find a nice tutorial about springs using Hook's Law.

The question is indeed not very clear. But you did mention Verlet so I guess what you want is to enforce some constraints on those links - read Jakobsen's paper, you've got all you need in there, no need for springs.

• actually, those are stiff springs and they work well for most cases, but will not exhibit any elasticity. I think this class of simulators is based on a technique called position based dynamics and may have been introduced by a guy named Provot in his cloth simulator. More here matthiasmueller.info/publications/posBasedDyn.pdf – teodron Oct 5 '12 at 14:02