When looking at bezier curves, it's easy to understand them intuitively as a few lerps between points. And they are fairly trivial to implement this way.
Vector3 SampleCurve(Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3, float t) {
Vector3 q0 = Lerp(p0, p1, t);
Vector3 q1 = Lerp(p1, p2, t);
Vector3 q2 = Lerp(p3, p3, t);
Vector3 r0 = Lerp(q0, q1, t);
Vevtor3 r1 = Lerp(q1, q2, t);
return Lerp(r0, r1, t);
}
From what i gather, the above is called de Casteljau's method.
However, you could also evaluate them using the bezier basis functions:
p = (1-t)^3 *P0 + 3*t*(1-t)^2*P1 + 3*t^2*(1-t)*P2 + t^3*P3
Which is a lot less intuitive, but at least i can find some nice graphics to explain how the functions work:
When looking at cubic hermite splines, the only info i seem to find online is the less than intuitive basis funtions:
Implemented with some less than intuitive code:
float Hermite(float t, float p0, float m0, float p1, float m1) {
float tt = t * t;
float ttt = t * t * t;
return
(2.0f * ttt - 3.0f * tt + 1.0f) * p0 +
(ttt - 2.0f * tt + t) * m0 +
(-2.0f * ttt + 3.0f * tt) * p1 +
(ttt - tt) * m1;
}
Is there an intuitive, easy to explain way of interpolating cubic hermite splines similar to that of bezier curves? Maybe it's not just a few lerps, but it would really help to know if there is a way to explain this that doesn't involve having to look at the graph of basis functions....