update method

(double, double) update(
  1. double pos,
  2. double vel,
  3. double equilibriumPos
)

Update position/velocity toward equilibriumPos.

Implementation

(double, double) update(double pos, double vel, double equilibriumPos) {
  final oldPos = pos - equilibriumPos;
  final oldVel = vel;

  final newPos = oldPos * _posPosCoef + oldVel * _posVelCoef + equilibriumPos;
  final newVel = oldPos * _velPosCoef + oldVel * _velVelCoef;
  return (newPos, newVel);
}