123456789101112131415161718192021222324(* Claude Code
*
* Copyright (C) 2026 Yoann Padioleau
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License
* (LGPL) as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*)(* See Follow.mli *)typet={value:float;velocity:float}letat(x:float):t={value=x;velocity=0.}(* the velocity first, then the value with the new velocity *)letchase?(frequency=2.)?(damping=1.)~(dt:float)(target:float)(t:t):t=letw=2.*.Float.pi*.frequencyinletacceleration=(w*.w*.(target-.t.value))-.(2.*.damping*.w*.t.velocity)inletvelocity=t.velocity+.(acceleration*.dt)in{value=t.value+.(velocity*.dt);velocity}letsmooth~(rate:float)~(dt:float)(target:float)(x:float):float=x+.((target-.x)*.(1.-.exp(-.rate*.dt)))