|
|
57bda0 |
|
|
|
57bda0 |
#ifndef TRACK_H
|
|
|
57bda0 |
#define TRACK_H
|
|
|
57bda0 |
|
|
|
57bda0 |
|
|
|
57bda0 |
#include <cmath></cmath>
|
|
|
1bcd85 |
#include <cassert></cassert>
|
|
|
57bda0 |
#include <vector></vector>
|
|
|
57bda0 |
#include <string></string>
|
|
|
57bda0 |
|
|
|
d2b2b5 |
#include "geometry.h"
|
|
|
57bda0 |
|
|
|
57bda0 |
|
|
|
d2b2b5 |
class TrackPoint {
|
|
|
57bda0 |
public:
|
|
|
57bda0 |
Vector3 position;
|
|
|
57bda0 |
Real angle;
|
|
|
57bda0 |
Real speed;
|
|
|
57bda0 |
|
|
|
57bda0 |
Real l;
|
|
|
57bda0 |
Real time;
|
|
|
57bda0 |
Real length;
|
|
|
57bda0 |
Real duration;
|
|
|
57bda0 |
Vector3 real_pos;
|
|
|
57bda0 |
|
|
|
d2b2b5 |
TrackPoint(): angle(), speed(), l(), time(), length() { }
|
|
|
57bda0 |
|
|
|
d2b2b5 |
static Vector3 calc_real_pos(const TrackPoint &point) {
|
|
|
57bda0 |
Real a = point.angle*(M_PI/180);
|
|
|
57bda0 |
Real s = sin(a);
|
|
|
57bda0 |
Real c = cos(a);
|
|
|
57bda0 |
return Vector3(
|
|
|
57bda0 |
point.position.x,
|
|
|
57bda0 |
point.position.y*c - point.position.z*s,
|
|
|
57bda0 |
point.position.y*s + point.position.z*c );
|
|
|
57bda0 |
}
|
|
|
57bda0 |
|
|
|
d2b2b5 |
static TrackPoint median(Real l, const TrackPoint &p0, const TrackPoint &p1) {
|
|
|
1bcd85 |
//assert(l >= - precision && l <= 1 + precision);
|
|
|
57bda0 |
Real k = 1 - l;
|
|
|
d2b2b5 |
TrackPoint p;
|
|
|
57bda0 |
p.position.x = p0.position.x*k + p1.position.x*l;
|
|
|
57bda0 |
p.position.y = p0.position.y*k + p1.position.y*l;
|
|
|
57bda0 |
p.position.z = p0.position.z*k + p1.position.z*l;
|
|
|
57bda0 |
p.angle = p0.angle *k + p1.angle *l;
|
|
|
57bda0 |
p.speed = p1.speed ;
|
|
|
57bda0 |
p.l = p0.l *k + p1.l *l;
|
|
|
57bda0 |
p.time = p0.time *k + p1.time *l;
|
|
|
57bda0 |
p.length = p1.length *l;
|
|
|
57bda0 |
p.duration = p1.duration *l;
|
|
|
57bda0 |
p.real_pos.x = p0.real_pos.x*k + p1.real_pos.x*l;
|
|
|
57bda0 |
p.real_pos.y = p0.real_pos.y*k + p1.real_pos.y*l;
|
|
|
57bda0 |
p.real_pos.z = p0.real_pos.z*k + p1.real_pos.z*l;
|
|
|
57bda0 |
return p;
|
|
|
57bda0 |
}
|
|
|
57bda0 |
};
|
|
|
57bda0 |
|
|
|
d2b2b5 |
typedef std::vector<trackpoint> TrackPointList;</trackpoint>
|
|
|
57bda0 |
|
|
|
57bda0 |
class Track {
|
|
|
57bda0 |
public:
|
|
|
d2b2b5 |
TrackPointList points;
|
|
|
57bda0 |
|
|
|
57bda0 |
void split(Real da, Real dl, Real dt);
|
|
|
57bda0 |
void calc_length();
|
|
|
57bda0 |
|
|
|
57bda0 |
int index_by_l(Real l) const;
|
|
|
57bda0 |
int index_by_time(Real t) const;
|
|
|
57bda0 |
};
|
|
|
57bda0 |
|
|
|
57bda0 |
|
|
|
57bda0 |
#endif
|