- This project gives an example, which can be modified by users.
- Every block during option start and option end should be modified by users according to the actual situation, where contains printing options.
- Need to pre install dependency
Eigen:
sudo apt-get install libeigen3-dev
sudo ln -s /usr/include/eigen3/Eigen /usr/include/Eigen - Provide simple parameter type checking function.
- Control points should be expressed in a matrix
P_, each column of this matrix represents a control point given by the users and this matrix should contains the start point at the first column and the end point at the last column. - The coefficients of each segment of the whole path are loaded in
CS->a,CS->b,CS->candCS->dafter run the functionCS->CubicSplineRun, if you want to know the specific form of the equation corresponding to each paragraph, please do not commented macro definitionCUBICSPLINE_TEST_PRINT_EQUATION. - Parameters
NATURAL,CLAMPEDandNOT_A_KNOTmeans different end condition, could be use asCS->CubicSplineRun(control_pt, NATURAL)orCS->CubicSplineRun(control_pt, CLAMPED)orCS->CubicSplineRun(control_pt, NOT_A_KNOT)in the example inmain.cpp. - The test result is as the follow figures, the red line corresponds to
NATURAL, the blue line corresponds toCLAMPEDand the green line corresponds toNOT_A_KNOT. Control points are set as(0, 0)&(2, 6)&(3, -1)&(7, 0), all of them are plot as the black dot in the figure.
- Reference:
三次样条插值(Cubic Spline Interpolation)及代码实现(C语言)
