Jump to content
  • Advertisement
Sign in to follow this  
adriansnetlis

How To Correctly Caluclate Compression Speed For Damping?

This topic is 708 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 :)

Share this post


Link to post
Share on other sites
Advertisement

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. 

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites

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?

Edited by adriansnetlis

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!