# test_cubicSpline **Repository Path**: misc_projects/test_cubic-spline ## Basic Information - **Project Name**: test_cubicSpline - **Description**: 测试使用三次样条曲线拟合离散点,并使用matplot-cpp绘制曲线。 - **Primary Language**: C++ - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-11-07 - **Last Updated**: 2024-11-07 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # README # 测试使用三次样条曲线拟合离散点,并使用`matplot-cpp`绘制曲线。 由于`matplot-cpp`只有头文件,其实现依赖调用`Python` DLL -> `Python` 脚本。故直接将`matplot-cpp`头文件拷贝到项目目录下,并使用该头文件。 ## 1. matplot-cpp 修改 ## 注释掉如下代码: ```c++ // Sanity checks; comment them out or change the numpy type below if you're // compiling on a platform where they don't apply static_assert(sizeof(long long) == 8); template <> struct select_npy_type { const static NPY_TYPES type = NPY_INT64; }; static_assert(sizeof(unsigned long long) == 8); template <> struct select_npy_type { const static NPY_TYPES type = NPY_UINT64; }; // TODO: add int, long, etc. ``` ## 2. Python 环境安装及配置 ## 安装依赖的`python`三方库: ```bash pip install numpy scipy matplotlib ``` 添加项目编译需要的`python`及依赖库的头文件及库文件: ```cmake # include dirs target_include_directories(${target_name} PRIVATE "D:/dev_libs/Python/Python312/Lib/site-packages/numpy/core/include") target_include_directories(${target_name} PRIVATE "D:/dev_libs/Python/Python312/include") # libs target_link_directories(${target_name} PRIVATE "D:/dev_libs/Python/Python312/libs") target_link_libraries(${target_name} _tkinter.lib python3.lib python312.lib) ``` 添加`python` DLL到环境变量`PATH`: `D:\dev_libs\Python\Python312`,编译成功即可运行。 ## 3. 样条曲线拟合 ## * [三次样条(Cubic Spline)的C++实现以及可视化](https://blog.csdn.net/aliexken/article/details/121923957) * [样条插值(Spline Interpolation)](https://bbs.huaweicloud.com/blogs/264151) * [三次样条插值原理及代码实现](https://www.cnblogs.com/flysun027/p/10371726.html)