Skip to content

Spline example #6

Description

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;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions