Advertisement

How To Correctly Caluclate Compression Speed For Damping?

Started by August 02, 2016 10:00 AM
6 comments, last by Irlan Robson 8 years, 6 months ago

Hello!

So far I've been doing this:


v = (x - x0) / dt

To determine the compression speed used for damping in spring's equation(


F = x * k + v * c

).

v = compression speed

x = compression

x0 = last frame compression

k = stiffness

c = damping

However, I know that this method is not quite correct and mostly results in critically unstable results. I'm wondering how to calculate it correctly for

  • 2 mass connected by a spring case
  • a mass connected to a spring which is connected to a static point

And hints and help appreciated :)

Not sure of what you're asking. Do you mean determining the point mass velocity at a future time knowing the spring ODE and the initial state?

Springs were covered in this talk with a semi-implicit Euler solution for this ODE as well.

Advertisement

I would think the relative velocity along the spring axis.

As Dirk pointed out, looks like v is the difference between the two masses velocities along the spring axis. Example:
n = (b - a) / |b - a|
v = dot(v_b - v_a, n)
And, more generally,
F_a = - (c * v + k * (|b - a| - r)) * n
F_b = - F_a
Where a and b are the positions of the two masses, v_a and v_b their velocities, and r the spring rest lenght.
Also, you might want to consider store v_i as a state and use the semi-implicit Euler integrator which is stable even for undamped systems (k_c = 0).

Hi! Thank you very much. This seems to be exactly what I need. I'm glad that I asked it here:)

Advertisement

Also, you might want to consider store v_i as a state and use the semi-implicit Euler integrator which is stable even for undamped systems (k_c = 0).

I always use symplecit Euler. I thought that I used explicit one, but than I found out that explicit Euler uses last frame velocity to integrate position and only than integrates velocity which doesn't make sense for me. I always integrate velocity first and than use it. However, it's easy to set the stiffness high enaugh to blow symplecit Euler. I also found it being ultra easy to blow RK4. I haven't yet tried verlet. I also haven't found out how it is possible to implement implicit Euler in game. And lastly - I gotta try out PBD as it seems to be the best stability and performance balance yet made for stiff spring system. ;)

Also it seems that previously I calculated the spring velocity implicitly, but in unsuitable case?

Indeed deriving spring forces from energy gradients and adding damping forces into the equation is horrible if you have a linear integrator.

Erin Catto talks about a bunch of integration stuff in the slide I've posted and also about spring joints (or soft constraints if you will) which are a possible replacement for springs and fit very nicely inside a particle/rigid body solver.

Yes, you've approximated velocity to first-order.

I personally haven't take the time to implement implicit Euler but it shouldn't be to hard to do so using the Newton-Raphson method for solving a system of non-linear equations because the next position is defined implicitly in terms of the next velocity.

Currently most game physics engines use PBD for cloth/particles and VBD for rigid bodies. Therefore implementing this would be usefull for comparison between solvers.

This topic is closed to new replies.

Advertisement