Not very complicated but couldn’t find an easy way of getting raw interpolated data otherwise so ended up writing this yesterday. Can do beziers, b-splines and catmull-rom splines. Might come in handy for others

# ofxCurve: addon to interpolate curves from a set of control points

**ayruos**#1

This is really handy. There are other spline add-ons out there but this is the only one I can find that includes bsplines alongside catmull.

One very minor tweak; in my use I need to assess scenarios of varying control point no.s, i.e. not always compliant to 3n+1. So I’ve added the following lines to each of the curve evaluations to allow the above, it seems to work, and allows the check on the no of control points to be commented out.

In Bezier eval. for loop:

```
int j = 3*i;
int k = 3*i+1; if(k > P.size()-1) k = j;
int m = 3*i+2; if(m > P.size()-1) m = k;
int n = 3*i+3; if(n > P.size()-1) n = m;
Curve smallBez = coreBezier(P[j], P[k], P[m], P[n], steps);
```

In Bspline eval. for loop:

```
int j = i;
int k = i+1; if(k > P.size()-1) k = j;
int m = i+2; if(m > P.size()-1) m = k;
int n = i+3; if(n > P.size()-1) n = m;
glm::vec4 cx = glm::vec4(P[j].x, P[j].y, P[j].z, 1); //etc
```

In CR eval for loop:

```
int h = (i-2) % P.size(); if(h < 0) h = 0;
int j = (i-1) % P.size(); if(j < 0) j = 0;
int k = (i) % P.size(); if(k > P.size()-1) k = j;
int m = (i+1) % P.size(); if(m > P.size()-1) m = k;
int n = (i+2) % P.size(); if(n > P.size()-1) n = m;
glm::vec4 cx = glm::vec4(P[j].x, P[j].y, P[h].z, 1); //etc
```

And one other final tweak; adding the first and last control points twice for the CR curves brings the end of the curve much closer to the start and end control points. Again, might not be exact science but works for me.

S