Closed trive closed 8 years ago
You could calculate it out! Wikipedia has a good reference for the formulas.
Critical damping is where ζ = 1
, and (in Pop terminology) ζ = friction / (2 * sqrt(mass * tension))
. If you set mass = 1
then you should be able to pick your tension and friction to make it critically damped.
Cool! So something like this then?
+ (CGFloat)frictionWhenCriticallyDampedWithMass:(CGFloat)mass tension:(CGFloat)tension
{
// https://github.com/facebook/pop/issues/304
// https://www.wolframalpha.com/input/?i=solve+1+%3D+f+%2F+(2+*+sqrt(t+*+m))+for+f
return 2.0 * sqrt(mass * tension);
}
+ (CGFloat)tensionWhenCriticallyDampedWithMass:(CGFloat)mass friction:(CGFloat)friction
{
// https://github.com/facebook/pop/issues/304
// https://www.wolframalpha.com/input/?i=solve+1+%3D+f+%2F+(2+*+sqrt(t+*+m))+for+t
return (friction * friction) / (4.0 * mass);
}
What about velocity? Does it come into play as well?
I think it should work. Would need to test, for sure — if it's good, might be a useful utility to include in Pop itself.
Hi,
Is there a set of parameters for bounciness and speed that create the behavior of a critically damped spring?