chen0040 / cpp-spline Goto Github PK
View Code? Open in Web Editor NEWPackage provides C++ implementation of spline interpolation
License: MIT License
Package provides C++ implementation of spline interpolation
License: MIT License
Hello, thanks for the effort put into this library, I want to use it for a project of mine but I need to be able to create splines (Bezier and Catmull) using 3 control points (and 2, but that's just a straight line), not the coded minimum of 4.
I have been looking into on how to do it but I can't really wrap my head around the math for it and also to create an implementation, any help regarding this? Thanks.
Hi,
A compilation issue came to me when I would like to run the test code. It seems to me that this package is header-only and there is no need to compile sth. However, compilation error is reported during the link stage
CMakeFiles/MyApp.dir/src/main.cc.o: In function `demo_bezier()':
/home/motion/cpp-spline/spline/src/test/cpp/src/main.cc:17: undefined reference to `Bezier::Bezier()'
/home/motion/cpp-spline/spline/src/test/cpp/src/main.cc:19: undefined reference to `Vector::Vector(double, double, double)'
/home/motion/cpp-spline/spline/src/test/cpp/src/main.cc:19: undefined reference to `Curve::add_way_point(Vector const&)'
/home/motion/cpp-spline/spline/src/test/cpp/src/main.cc:20: undefined reference to `Vector::Vector(double, double, double)'
/home/motion/cpp-spline/spline/src/test/cpp/src/main.cc:20: undefined reference to `Curve::add_way_point(Vector const&)'
/home/motion/cpp-spline/spline/src/test/cpp/src/main.cc:21: undefined reference to `Vector::Vector(double, double, double)'
/home/motion/cpp-spline/spline/src/test/cpp/src/main.cc:21: undefined reference to `Curve::add_way_point(Vector const&)'
/home/motion/cpp-spline/spline/src/test/cpp/src/main.cc:22: undefined reference to `Vector::Vector(double, double, double)'
/home/motion/cpp-spline/spline/src/test/cpp/src/main.cc:22: undefined reference to `Curve::add_way_point(Vector const&)'
/home/motion/cpp-spline/spline/src/test/cpp/src/main.cc:26: undefined reference to `Vector::toString[abi:cxx11]() const'
CMakeFiles/MyApp.dir/src/main.cc.o: In function `demo_bspline()':
/home/motion/cpp-spline/spline/src/test/cpp/src/main.cc:32: undefined reference to `BSpline::BSpline()'
/home/motion/cpp-spline/spline/src/test/cpp/src/main.cc:34: undefined reference to `Vector::Vector(double, double, double)'
/home/motion/cpp-spline/spline/src/test/cpp/src/main.cc:34: undefined reference to `Curve::add_way_point(Vector const&)'
/home/motion/cpp-spline/spline/src/test/cpp/src/main.cc:35: undefined reference to `Vector::Vector(double, double, double)'
/home/motion/cpp-spline/spline/src/test/cpp/src/main.cc:35: undefined reference to `Curve::add_way_point(Vector const&)'
/home/motion/cpp-spline/spline/src/test/cpp/src/main.cc:36: undefined reference to `Vector::Vector(double, double, double)'
/home/motion/cpp-spline/spline/src/test/cpp/src/main.cc:36: undefined reference to `Curve::add_way_point(Vector const&)'
/home/motion/cpp-spline/spline/src/test/cpp/src/main.cc:37: undefined reference to `Vector::Vector(double, double, double)'
/home/motion/cpp-spline/spline/src/test/cpp/src/main.cc:37: undefined reference to `Curve::add_way_point(Vector const&)'
/home/motion/cpp-spline/spline/src/test/cpp/src/main.cc:41: undefined reference to `Vector::toString[abi:cxx11]() const'
CMakeFiles/MyApp.dir/src/main.cc.o: In function `demo_catmullrom()':
/home/motion/cpp-spline/spline/src/test/cpp/src/main.cc:47: undefined reference to `CatmullRom::CatmullRom()'
/home/motion/cpp-spline/spline/src/test/cpp/src/main.cc:49: undefined reference to `Vector::Vector(double, double, double)'
/home/motion/cpp-spline/spline/src/test/cpp/src/main.cc:49: undefined reference to `Curve::add_way_point(Vector const&)'
/home/motion/cpp-spline/spline/src/test/cpp/src/main.cc:50: undefined reference to `Vector::Vector(double, double, double)'
/home/motion/cpp-spline/spline/src/test/cpp/src/main.cc:50: undefined reference to `Curve::add_way_point(Vector const&)'
/home/motion/cpp-spline/spline/src/test/cpp/src/main.cc:51: undefined reference to `Vector::Vector(double, double, double)'
/home/motion/cpp-spline/spline/src/test/cpp/src/main.cc:51: undefined reference to `Curve::add_way_point(Vector const&)'
/home/motion/cpp-spline/spline/src/test/cpp/src/main.cc:52: undefined reference to `Vector::Vector(double, double, double)'
/home/motion/cpp-spline/spline/src/test/cpp/src/main.cc:52: undefined reference to `Curve::add_way_point(Vector const&)'
/home/motion/cpp-spline/spline/src/test/cpp/src/main.cc:56: undefined reference to `Vector::toString[abi:cxx11]() const'
CMakeFiles/MyApp.dir/src/main.cc.o: In function `Curve::node(int) const':
/home/motion/cpp-spline/spline/src/main/cpp/../../main/cpp/Curve.h:28: undefined reference to `Vector::Vector(Vector const&)'
collect2: error: ld returned 1 exit status
CMakeFiles/MyApp.dir/build.make:109: recipe for target 'MyApp' failed
make[2]: *** [MyApp] Error 1
CMakeFiles/Makefile2:72: recipe for target 'CMakeFiles/MyApp.dir/all' failed
make[1]: *** [CMakeFiles/MyApp.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
Can you provide me with an insight about what could be the cause for this problem?
Bezier graph is fine, but BSpline and CatmullRom are missing the first point.
Hi,
Thanks for sharing the work. I want to fit curved line through given points. I am unable to understand how you chose the coefficient for interpolation function e.g. for CatmullRom you use the following function
interpolate(double u, const Vector& P0, const Vector& P1, const Vector& P2, const Vector& P3)
{
Vector point;
point=u*u*u*((-1) * P0 + 3 * P1 - 3 * P2 + P3) / 2;
point+=u*u*(2*P0 - 5 * P1+ 4 * P2 - P3) / 2;
point+=u*((-1) * P0 + P2) / 2;
point+=P1;
return point;
}
Can I use more than four control points ? I tried with more than four point but algorithm considering only 4 control points. Please help me, I am waiting for you reply.
Thanks in advance !!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.