Like this image showed:
http://www.mvps.org/directx/articles...es/spline1.gif
Desired point is in the middle, between second and third point. So the end points are there to just show where to twist
As you see here, only middle section is what we need:
Code:
function nxCatmull(const a,b,c,d: PVector3f; const delta: single): TVector3f;
function Calc(p0,p1,p2,p3,t: single): single;
begin
result:=0.5 *( (2 * p1) + (-p0 + p2) * t +
(2*p0 - 5*p1 + 4*p2 - p3) * t*t +
(-p0 + 3*p1- 3*p2 + p3) * t*t*t);
end;
begin
result.x:=Calc(a.x, b.x, c.x, d.x, delta);
result.y:=Calc(a.y, b.y, c.y, d.y, delta);
result.z:=Calc(a.z, b.z, c.z, d.z, delta);
end;
PS. I really like seeing these twist in 3 dimensions real time
PPS. Here's what you get when combining the middle sections It's exactly the way the curve is supposed to go! Now is it fast enough for real models?
http://img512.imageshack.us/img512/3514/catmull2kp4.jpg
Bookmarks