speed adjustments

pull/2234/head
frederic wagner 2022-09-14 17:09:00 +02:00
parent c0c6e5c2bd
commit d54e44c869
1 changed files with 6 additions and 4 deletions

View File

@ -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 {