   Catmull-Rom splines with 3 control points
  Hi guys, I'm trying to do sth unusual here.Basicaly, for my camera-following-path-looking-at-another-path code I need a function that will calculate for me the value of Catmull Rome spline. Well, for 4 control points it's simple and I have it already:Vector3 CalculateCatmullRomeSpline( const Vector3& p1, const Vector3& p2, const Vector3& p3, const Vector3& p4, float t)  {  const Vector3 first_term = (-p1 + 3*p2 -3*p3 + p4) * t*t*t;  const Vector3 second_term = (2*p1 -5*p2 + 4*p3 - p4)*t*t;  const Vector3 third_term = (-p1+p3)*t + 2*p2;  return 0.5f * ( first_term + second_term + third_term );  }That's easy. Now, if you'd want to calculate 3 point CR spline, you can't just omit p4 and hope it'll work (I tried it ;-) ). Instead one would (I presume) take the general N control point CR version, and specialize it for 3 point version. Does anyone have such an implementation, or could point me to a clean C++ implementation of this general algorithm (in one function ideally), since everything I found on google is some hard to port weird matlab stuff that spans over 50 files. That's all, thanks in advance!For the curious ones: not necessarily it must be CR spline. I need anything that interpolates between 3 control points, passing through all of them, and having C0 and C1 continuity, so that tangents at control points are 'symetrical'.    
  Ah so what you want is a good cubic bezier curve for breakfast :-)http://en.wikipedia.org/wiki/B%C3%A9zier_curveor just try this for dinner:http://www.gamedev.net/reference/articles/article1808.asp;  I would say that, lacking the appetite for a full cubic dinner, he merely wants a quadratic amusee-bouche. Alternatively, however, three points will give you a very nice circular arc, which may more effectively fit what you want.   ;  @ddloxI got working 3 point Bezier curve but it didn't work as expected; the main problem is that it doesn't go through all points and that by joining 2 Bezier curves created each for half of points, you won't get the same result as when creating one Bezier curve out of all of them. I need it because I'm calculating spline between camera nodes on the path, but only locally, around the node where the camera is closest to. In Bezier when the camera would move to other node, slightly different curve would be calculated and that would be visible as nasty snapping.I figured out that by having spline which "interpolates between 3 control points, passing through all of them, and having C0 and C1 continuity" would give me what I want, and then I could finally eat main dishes...@SneftelThat was naughty... not being native english speaker and having natural english vocabulary understaning, I thought that Amusee Bouche is some kind of an algorithm, you know, like Runge Kutta or (nomen omen) Catmull Rom. Then i googled for it...Ok, so the tasty saucy quadratic spline isn't necesserily what I'm looking for, since the oscilations I see there are too big for camera paths. So arcs are also automatically disqualified. Any other ideas?   ;  well that's surprising..How r u creating your control points? I assume this is how you should do it if you want to achieve C1->C0 continuity, curve 1: P0 P1 P3 P4 (C==1 at P0 and C==0 at P4)    curve 2: P4 P5 P6 P7 (C==1 at P4 and C==0 at P7)curve 3: P7 P8 P9 P10 (C==1 at P7 and C==0 at P10)curve etc...And yes curve won't go through each point, because remember they're only CONTROL points, so your camera will not spline through all of them, but approximately. If it did, then it's not a curve anymore it would be a polyline.;  ddlox, are you talking about CR or Bezier? I don't know what C==... are you talking about, and also I think that your method wouldn't work. But thanks for writing anything :-)Here you can see that Bezier curves not necesserily are C1 continous:http://www.siggraph.org/education/materials/HyperGraph/modeling/splines/demoprog/curve.htmlAnyway, I came to conclusion that what I was trying to do was trying to fit a rectangle in a triangular type hole, and so it was stupid. I solved the problem by calculating 2 CRs and some other magic math.   ;  Ok fair enough if you've solved it.. I was talking about a Bezier not a CR. C==1 or C==0, by this I meant C for continuity (You can repeat the last control point as the first in the next curve to achieve this).But it will not be as smoother as a B-Spline.If you look back into:http://www.gamedev.net/reference/articles/article1808.aspand search for this comment line:/*... If the points are close enough, itwill appear as a curved line. 20 points are plenty, and since the variable goesfrom 1.0 to 0.0 we must change it by 1/20 = 0.05 each time ... */Then you will see that your continuity is defined by 1 and 0 as well, but then by repeating the last control point as your first into the next curve and resetting your loop to 1 and 0, you can achieve C1 and C0 continuity.But as I said, this is still not as smooth as with a B-spline (because in this curve the last CP doesn't need to be repeated to get smooth passages).   