0
\$\begingroup\$

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 ?

https://i.sstatic.net/NCKmO.jpg

\$\endgroup\$
7
  • \$\begingroup\$ 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. \$\endgroup\$ Commented Apr 23, 2011 at 12:06
  • \$\begingroup\$ Yes, the nodes will be connected with springs. \$\endgroup\$ Commented Apr 23, 2011 at 12:16
  • \$\begingroup\$ 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. \$\endgroup\$ Commented Apr 23, 2011 at 12:29
  • \$\begingroup\$ 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. \$\endgroup\$ Commented Apr 23, 2011 at 13:28
  • \$\begingroup\$ 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 \$\endgroup\$ Commented Apr 23, 2011 at 13:46

2 Answers 2

2
\$\begingroup\$

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.

\$\endgroup\$
2
\$\begingroup\$

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.

\$\endgroup\$
1
  • \$\begingroup\$ 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 \$\endgroup\$ Commented Oct 5, 2012 at 14:02

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.