-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
69 lines (48 loc) · 1.58 KB
/
main.cpp
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
63
64
65
66
67
68
69
#include"bspline.h"
using namespace std;
BSpline::BSpline bspline; // bspline object
std::vector<Eigen::Vector3d> controlPoints;
int splineOrder = 5;
int main()
{
std::ofstream splineData;
std::cout<<"BSpline fitting on points in space ..."<<std::endl;
std::cout<<"Enter the num of control points ";
std::cin>>bspline.numCtrlPoints;
splineData.open("dataControlPoints.txt");
// take the points as input
for(int i = 0; i<=bspline.numCtrlPoints; i++)
{
std::cout<<"Enter the coordinate "<<i<<" ";
Eigen::Vector3d pt;
std::cin>>pt(0)>>pt(1)>>pt(2);
splineData<<pt(0)<<","<<pt(1)<<","<<pt(2)<<std::endl;
controlPoints.push_back(pt);
}
splineData.close();
// set this as the control points
bspline.setControlPoints(controlPoints);
// set the order
bspline.setOrder(splineOrder);
// now calculate the spline
bspline.setKnotVector(); // this sets the knot vector
// set the no. of segments
bspline.setNumSegments();
// calculate the bspline points
bspline.getBSplineTrajectory();
// print the spline points
splineData.open("data.txt");
for(int i = 0; i<bspline.splineSegments.size(); i++)
{
std::vector<Eigen::Vector3d> spPts = bspline.splineSegments[i];
for(int i = 0; i<spPts.size(); i++)
{
Eigen::Vector3d point;
std::cout<<spPts[i].transpose()<<std::endl;
point = spPts[i];
splineData<<point(0)<<","<<point(1)<<","<<point(2)<<std::endl;
}
}
splineData.close();
return 0;
}