diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2021-01-13 17:26:33 +0100 |
---|---|---|
committer | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2021-01-13 17:26:33 +0100 |
commit | 4524c20b48abe08e69c25a7382a289592d147496 (patch) | |
tree | 3e475fe673d5acd800180282e84df03d396106f3 /src/animation/Controller.js | |
parent | 4f4dc2afa62cb899a5cae72c359150f8adf27edb (diff) | |
download | svg.js-4524c20b48abe08e69c25a7382a289592d147496.tar.gz svg.js-4524c20b48abe08e69c25a7382a289592d147496.zip |
update dependencies, apply new linter fixes
Diffstat (limited to 'src/animation/Controller.js')
-rw-r--r-- | src/animation/Controller.js | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/animation/Controller.js b/src/animation/Controller.js index ae49de9..303fb71 100644 --- a/src/animation/Controller.js +++ b/src/animation/Controller.js @@ -140,15 +140,15 @@ export class Controller extends Stepper { function recalculate () { // Apply the default parameters - var duration = (this._duration || 500) / 1000 - var overshoot = this._overshoot || 0 + const duration = (this._duration || 500) / 1000 + const overshoot = this._overshoot || 0 // Calculate the PID natural response - var eps = 1e-10 - var pi = Math.PI - var os = Math.log(overshoot / 100 + eps) - var zeta = -os / Math.sqrt(pi * pi + os * os) - var wn = 3.9 / (zeta * duration) + const eps = 1e-10 + const pi = Math.PI + const os = Math.log(overshoot / 100 + eps) + const zeta = -os / Math.sqrt(pi * pi + os * os) + const wn = 3.9 / (zeta * duration) // Calculate the Spring values this.d = 2 * zeta * wn @@ -173,11 +173,11 @@ export class Spring extends Controller { dt /= 1000 // Get the previous velocity - var velocity = c.velocity || 0 + const velocity = c.velocity || 0 // Apply the control to get the new position and store it - var acceleration = -this.d * velocity - this.k * (current - target) - var newPosition = current + const acceleration = -this.d * velocity - this.k * (current - target) + const newPosition = current + velocity * dt + acceleration * dt * dt / 2 @@ -208,10 +208,10 @@ export class PID extends Controller { if (dt === Infinity) return target if (dt === 0) return current - var p = target - current - var i = (c.integral || 0) + p * dt - var d = (p - (c.error || 0)) / dt - var windup = this._windup + const p = target - current + let i = (c.integral || 0) + p * dt + const d = (p - (c.error || 0)) / dt + const windup = this._windup // antiwindup if (windup !== false) { |