diff --git a/apps/gipy/app.js b/apps/gipy/app.js index 4acb9f284..723f795da 100644 --- a/apps/gipy/app.js +++ b/apps/gipy/app.js @@ -63,10 +63,12 @@ class Status { let last_point = this.old_points[this.old_points.length - 1]; let oldest_point = this.old_points[0]; - if (this.old_points.length == 6) { - let p1 = this.old_points[0].plus(this.old_points[1]).plus(this.old_points[2]).times(1/3); - let p2 = this.old_points[3].plus(this.old_points[4]).plus(this.old_points[5]).times(1/3); - this.instant_speed = p1.distance(p2) / (this.old_times[4] - this.old_times[1]); + if (this.old_points.length == 8) { + let p1 = this.old_points[0].plus(this.old_points[1]).plus(this.old_points[2]).plus(this.old_points[3]).times(1/4); + let p2 = this.old_points[4].plus(this.old_points[5]).plus(this.old_points[6]).plus(this.old_points[7]).times(1/4); + let t1 = (this.old_times[1] + this.old_times[2]) / 2; + let t2 = (this.old_times[5] + this.old_times[6]) / 2; + this.instant_speed = p1.distance(p2) / (t2-t1); this.old_points.shift(); this.old_times.shift(); } else {