@@ -10,22 +10,80 @@ Package provides C++ implementation of spline interpolation
10
10
11
11
# Usage
12
12
13
+ # Bezier
14
+
13
15
To create a Bezier Curve in 2D or 3D environment:
14
16
15
17
``` cpp
16
- Bezier* curve = new Bezier();
17
- curve->set_steps (100); // generate 100 interpolate points between the last 4 way points
18
-
19
- curve->add_way_point(Vector(1, 1, 0));
20
- curve->add_way_point(Vector(2, 3, 0));
21
- curve->add_way_point(Vector(3, 2, 0));
22
- curve->add_way_point(Vector(4, 6, 0));
23
- ...
24
-
25
- std::cout << "nodes: " << curve->node_count() << std::endl;
26
- std::cout << "total length: " << curve->total_length() << std::endl;
27
- for (int i = 0; i < curve->node_count(); ++i) {
28
- std::cout << "node #" << i << ": " << curve->node(i).toString() << " (length so far: " << curve->length_from_starting_point(i) << ")" << std::endl;
18
+ #include < iostream>
19
+ #include " ../../main/cpp/Bezier.h"
20
+ int main (char** argv, int argc) {
21
+ Curve* curve = new Bezier();
22
+ curve->set_steps(100); // generate 100 interpolate points between the last 4 way points
23
+
24
+ curve->add_way_point(Vector(1, 1, 0));
25
+ curve->add_way_point(Vector(2, 3, 0));
26
+ curve->add_way_point(Vector(3, 2, 0));
27
+ curve->add_way_point(Vector(4, 6, 0));
28
+ ...
29
+
30
+ std::cout << "nodes: " << curve->node_count() << std::endl;
31
+ std::cout << "total length: " << curve->total_length() << std::endl;
32
+ for (int i = 0; i < curve->node_count(); ++i) {
33
+ std::cout << "node #" << i << ": " << curve->node(i).toString() << " (length so far: " << curve->length_from_starting_point(i) << ")" << std::endl;
34
+ }
35
+ delete curve;
36
+ }
37
+ ```
38
+
39
+ # BSpline
40
+
41
+ To create a BSpline Curve in 2D or 3D environment:
42
+
43
+ ```cpp
44
+ #include <iostream>
45
+ #include "../../main/cpp/BSpline.h"
46
+ int main(char** argv, int argc) {
47
+ Curve* curve = new BSpline();
48
+ curve->set_steps(100); // generate 100 interpolate points between the last 4 way points
49
+
50
+ curve->add_way_point(Vector(1, 1, 0));
51
+ curve->add_way_point(Vector(2, 3, 0));
52
+ curve->add_way_point(Vector(3, 2, 0));
53
+ curve->add_way_point(Vector(4, 6, 0));
54
+ ...
55
+
56
+ std::cout << "nodes: " << curve->node_count() << std::endl;
57
+ std::cout << "total length: " << curve->total_length() << std::endl;
58
+ for (int i = 0; i < curve->node_count(); ++i) {
59
+ std::cout << "node #" << i << ": " << curve->node(i).toString() << " (length so far: " << curve->length_from_starting_point(i) << ")" << std::endl;
60
+ }
61
+ delete curve;
62
+ }
63
+ ```
64
+
65
+ # CatmullRom
66
+
67
+ To create a CatmullRom Curve in 2D or 3D environment:
68
+
69
+ ``` cpp
70
+ #include < iostream>
71
+ #include " ../../main/cpp/CatmullRom.h"
72
+ int main (char** argv, int argc) {
73
+ Curve* curve = new CatmullRom();
74
+ curve->set_steps(100); // generate 100 interpolate points between the last 4 way points
75
+
76
+ curve->add_way_point(Vector(1, 1, 0));
77
+ curve->add_way_point(Vector(2, 3, 0));
78
+ curve->add_way_point(Vector(3, 2, 0));
79
+ curve->add_way_point(Vector(4, 6, 0));
80
+ ...
81
+
82
+ std::cout << "nodes: " << curve->node_count() << std::endl;
83
+ std::cout << "total length: " << curve->total_length() << std::endl;
84
+ for (int i = 0; i < curve->node_count(); ++i) {
85
+ std::cout << "node #" << i << ": " << curve->node(i).toString() << " (length so far: " << curve->length_from_starting_point(i) << ")" << std::endl;
86
+ }
87
+ delete curve;
29
88
}
30
- delete curve;
31
89
```
0 commit comments