-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCurve.h
executable file
·62 lines (49 loc) · 1.57 KB
/
Curve.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#pragma once
#include <vector>
#include "Eigen/Dense"
#include "Eigen/StdVector"
#include <json/json.h>
class cCurve
{
public:
enum eCurveType
{
eCurveTypeCatmullRom,
eCurveTypeBSpline,
eCurveTypeMax
};
struct tAnchor
{
tAnchor();
~tAnchor();
// anchors are specified by a position and a tangent
Eigen::VectorXd mPos;
Eigen::VectorXd mTangent;
};
cCurve();
virtual ~cCurve();
virtual bool Load(const std::string& file);
virtual void Clear();
virtual int GetNumAnchors() const;
virtual const Eigen::VectorXd& GetAnchorPos(int i) const;
virtual const Eigen::VectorXd& GetAnchorTangent(int i) const;
virtual int GetNumSegments() const;
virtual int GetDim() const;
virtual void Eval(double time, Eigen::VectorXd& out_result) const;
virtual void EvalTangent(double time, Eigen::VectorXd& out_result) const;
virtual void EvalNormal(double time, Eigen::VectorXd& out_result) const;
virtual double GetMaxTime() const;
virtual void Add(const tAnchor& anchor);
protected:
static eCurveType ParseCurveType(const std::string& str);
eCurveType mCurveType;
double mSegmentDuration; // assume constant duration for each segment
std::vector<tAnchor, Eigen::aligned_allocator<tAnchor>> mAnchors;
virtual bool ParseAnchors(const Json::Value& root);
virtual bool ParseAnchor(const Json::Value& root, tAnchor& out_anchor) const;
virtual void PrintAnchors() const;
virtual void GetAnchors(int seg, int& anchor_beg, int& anchor_end) const;
virtual double GetAnchorTime(int i) const;
virtual void ComputeAnchorTangents();
virtual double GetSegDuration(int seg) const;
};