• Greg Price's avatar
    Fix buggy formula for critically-damped springs (#120488) · 97938859
    Greg Price authored
    Fixes #109675.
    
    This formula would produce an initial velocity quite different
    from the one specified as an argument.
    
    To update the test, I computed the expected results separately
    by using the physical formula.
    
    Happily, the framework by default never ends up actually exercising
    this code.  Of the four SpringDescription call sites within the
    framework, two are explicitly overdamped; the other two are by
    design critically damped, but due to rounding they end up being
    treated as (very slightly) overdamped too.  Details here:
      https://github.com/flutter/flutter/issues/109675#issuecomment-1423674855
    
    So the only way an app could be affected by this bug is if it called
    a SpringDescription constructor itself, and managed to create a spring
    description where the distinguishing formula in _SpringSolution comes
    out exactly equal to zero.  It's likely nobody has ever shipped such
    an app, because the behavior this produces would be so wildly wrong
    that it'd be hard to miss when exercised.
    Co-authored-by: 's avatarKate Lovett <katelovett@google.com>
    97938859
spring_simulation.dart 8.65 KB