andrewwillmott/splines-lib

Spline example

densar opened this issue · 0 comments

Can you show an example simply computing f.e. a cubic spline from points? Accoring to the test example there come always wrong results with index = -1 during the query:

int cnt = getcount(); // point count
Vec2f* in = new Vec2f[cnt]; // input points
cSpline2* splines = new cSpline2[cnt + 1]; // splines

// Make vector
for (int i = 0; i < cnt; i++) {  in[i].x = pt[i].getx(); in[i].y = p[i].gety(); }

// Splines
int numSplines = SplinesFromPoints(cnt, in, cnt + 1, splines);

// Query points from vector
for(int i = 0; i < cnt; i++)
{
  int index;
  float t = FindClosestPoint(in[i], cnt, splines, &index);
  Vec2f cp = Position(splines[index], t);
}

delete[] in;
delete[] splines;