diff options
author | ccolin | 2021-01-04 14:49:26 +0100 |
---|---|---|
committer | ccolin | 2021-01-04 14:49:26 +0100 |
commit | 0c28d9dc80e634ebfbabed5ad446b6a4f82056e3 (patch) | |
tree | 498a6b8ce12305a2d7531396767852a07f564b7d /src/drone.cc | |
parent | 472e291ca823910418919eac101f26e2b3d852a8 (diff) |
add speeding violation reporting
Diffstat (limited to 'src/drone.cc')
-rw-r--r-- | src/drone.cc | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/drone.cc b/src/drone.cc index 2c0fad8..50bc5e7 100644 --- a/src/drone.cc +++ b/src/drone.cc @@ -31,6 +31,10 @@ Drone::Drone(const QJsonObject &json) for (const QJsonValue &o : ja) { waypoints.append(Waypoint(o.toObject())); } + for (int i = 0; i < waypoints.size() - 1; i++) { + waypoints[i].computed_speed = (waypoints[i + 1].pos - waypoints[i].pos).length() + / (waypoints[i + 1].frame - waypoints[i].frame); + } setTo(0); } @@ -55,10 +59,13 @@ void Drone::setTo(int frame) { } if (next > -1 && prev == -1) { pos = next_wp->pos; + speed = next_wp->computed_speed; } else if (prev > -1 && next == -1) { pos = prev_wp->pos; + speed = prev_wp->computed_speed; } else { pos = lerp(prev_wp->pos, next_wp->pos, (double) (frame-prev) / (next-prev)); + speed = prev_wp->computed_speed; } } @@ -73,6 +80,11 @@ int Drone::getId() const { } +double Drone::getSpeed() const { + return speed; +} + + const OpenGLMesh *Drone::getMesh() const { return mesh; } |