Esempio n. 1
0
ts::BSpline::BSpline(const std::vector<ts::rational> points, const size_t dim)
{
    if (dim == 0)
        throw std::runtime_error(ts_enum_str(TS_DIM_ZERO));
    if (points.size() % dim != 0)
        throw std::runtime_error("#points % dim == 0 failed");
    const tsError err = ts_bspline_interpolate(
            points.data(), points.size()/dim, dim, &bspline);
    if (err < 0)
        throw std::runtime_error(ts_enum_str(err));
}
Esempio n. 2
0
/********************************************************
*                                                       *
* Modify these lines for experimenting.                 *
*                                                       *
********************************************************/
void setup()
{
    float points[15];
    points[0] = 1;
    points[1] = -1;
    points[2] = 0;
    points[3] = -1;
    points[4] = 2;
    points[5] = 0;
    points[6] = 1;
    points[7] = 4;
    points[8] = 0;
    points[9] = 4;
    points[10] = 3;
    points[11] = 0;
    points[12] = 7;
    points[13] = 5;
    points[14] = 0;

    ts_bspline_interpolate(points, 5, 3, &spline);
    ts_bspline_print(&spline);
}