https://github.com/chen0040/cpp-spline
Package provides C++ implementation of spline interpolation
https://github.com/chen0040/cpp-spline
b-spline bezier catmull-rom cpp interpolation splines
Last synced: 5 days ago
JSON representation
Package provides C++ implementation of spline interpolation
- Host: GitHub
- URL: https://github.com/chen0040/cpp-spline
- Owner: chen0040
- License: mit
- Created: 2017-05-30T03:41:08.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2021-07-16T18:10:43.000Z (almost 4 years ago)
- Last Synced: 2025-04-03T23:51:12.483Z (3 months ago)
- Topics: b-spline, bezier, catmull-rom, cpp, interpolation, splines
- Language: C++
- Size: 15.6 KB
- Stars: 136
- Watchers: 4
- Forks: 43
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cpp-spline
Package provides C++ implementation of spline interpolation
# Features
* Bezier Curve
* B-Spline
* CatmullRom# Usage
# Bezier
To create a Bezier Curve in 2D or 3D environment:
```cpp
#include
#include "../../main/cpp/Bezier.h"
int main(char** argv, int argc) {
Curve* curve = new Bezier();
curve->set_steps(100); // generate 100 interpolate points between the last 4 way pointscurve->add_way_point(Vector(1, 1, 0));
curve->add_way_point(Vector(2, 3, 0));
curve->add_way_point(Vector(3, 2, 0));
curve->add_way_point(Vector(4, 6, 0));
...std::cout << "nodes: " << curve->node_count() << std::endl;
std::cout << "total length: " << curve->total_length() << std::endl;
for (int i = 0; i < curve->node_count(); ++i) {
std::cout << "node #" << i << ": " << curve->node(i).toString() << " (length so far: " << curve->length_from_starting_point(i) << ")" << std::endl;
}
delete curve;
}
```# BSpline
To create a BSpline Curve in 2D or 3D environment:
```cpp
#include
#include "../../main/cpp/BSpline.h"
int main(char** argv, int argc) {
Curve* curve = new BSpline();
curve->set_steps(100); // generate 100 interpolate points between the last 4 way pointscurve->add_way_point(Vector(1, 1, 0));
curve->add_way_point(Vector(2, 3, 0));
curve->add_way_point(Vector(3, 2, 0));
curve->add_way_point(Vector(4, 6, 0));
...std::cout << "nodes: " << curve->node_count() << std::endl;
std::cout << "total length: " << curve->total_length() << std::endl;
for (int i = 0; i < curve->node_count(); ++i) {
std::cout << "node #" << i << ": " << curve->node(i).toString() << " (length so far: " << curve->length_from_starting_point(i) << ")" << std::endl;
}
delete curve;
}
```# CatmullRom
To create a CatmullRom Curve in 2D or 3D environment:
```cpp
#include
#include "../../main/cpp/CatmullRom.h"
int main(char** argv, int argc) {
Curve* curve = new CatmullRom();
curve->set_steps(100); // generate 100 interpolate points between the last 4 way pointscurve->add_way_point(Vector(1, 1, 0));
curve->add_way_point(Vector(2, 3, 0));
curve->add_way_point(Vector(3, 2, 0));
curve->add_way_point(Vector(4, 6, 0));
...std::cout << "nodes: " << curve->node_count() << std::endl;
std::cout << "total length: " << curve->total_length() << std::endl;
for (int i = 0; i < curve->node_count(); ++i) {
std::cout << "node #" << i << ": " << curve->node(i).toString() << " (length so far: " << curve->length_from_starting_point(i) << ")" << std::endl;
}
delete curve;
}
```