computer-graphics-mass-spring-systems icon indicating copy to clipboard operation
computer-graphics-mass-spring-systems copied to clipboard

single-spring-horizontal.json doesn't swing like a pendulum

Open CalinArdelean opened this issue 6 years ago • 2 comments

In single-spring-horizontal.json, my unpinned vertex slowly comes to rest at the bottom of the pendulum without swinging from side to side. What can be the problem? I see that f_ext is a constant -9.8. Shouldn't it be -9.8 * sin(alpha), where alpha is the angle between the current position and rest position of the vertex? My other examples are working fine. I notice there's only a single pinned vertex in this one, so I wonder if the problem might lie in the C matrix or penalty term?

CalinArdelean avatar Nov 30 '19 18:11 CalinArdelean

You can think of the external force in this case as gravity, which is constant everywhere - it doesn't depend on vertex positions. If the penalty term was not working correctly, the pinned vertex would move, so from what you described, that's probably not it. My guess is that it's something to do with the stiffness constant k. If you don't take it into account somewhere, the elastic force will be much smaller than it should be, which will prevent the swinging effect from happening.

abhimadan avatar Nov 30 '19 18:11 abhimadan

A couple other people had this problem, too. Maybe your bug is similar. Here's what we did in their cases.

The inner loop (e.g., 50 iterations) is bouncing between using U_next to improve d and then using d to improve U_next.

alecjacobson avatar Nov 30 '19 19:11 alecjacobson