Gistrec

Spline example

Mar 25th, 2020
275
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3.  
  4. #include "Spline.hpp"
  5.  
  6. int main() {
  7.     std::vector<double> X = { -1, -0.5, 0, 0.5, 1 };
  8.     std::vector<double> Y = {  0,    0, 1,   0, 0 };
  9.    
  10.     tk::spline s;
  11.    
  12.     s.set_points(X, Y);    // X needs to be sorted, strictly increasing
  13.     //double value = s(1.5);  // interpolated value at 1.5
  14.    
  15.     for (double i = -1; i < 1; i += 0.01) {
  16.         std::cout << i << "\t" << s(i) << std::endl;
  17.     }
  18.  
  19.     return 0;
  20. }
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment