Skip to main content
gamedev.net
🔒 Locked

Vector interpolation

Started by Sir Valeq 0 replies 500+ views
Original Post
Sir Valeq
Sir Valeq
Hi! I''d like to ask if there is any nicer way to interpolate between two vectors than D3DXVec3Lerp? I found the Hermite and CatmullRom funcs in the SDK, but I just don''t get them. I don''t know what are those tangent vectors... I would just like a nice interpolation, like slerp between quaternions. Did anyone work out such function? Any help will be appreciated. Thx in advance
--------------"We cannot all be masters." - William Shakespeare
quasar3d
quasar3d
CatmullRom interpolates between two vectors, but it also needs the previous and next vector to make the line curved. There is a function for it in D3DX I think, but you can use also mine (which is of course much nicer


  
template <class T> T CatmullRom(const T &x1,const T &x2,const T &x3,const T &x4,float t)
{
T ret;

ret = (-x1 + x2 * 3 - x3 * 3 + x4) * (t * t * t);
ret += (x1 * 2 - x2 * 5 + x3 * 4 - x4) * (t * t);
ret += (-x1 + x3) * t;
ret += x2 * 2;
ret *= .5f;

return ret;
}


My Site

[edited by - Quasar3D on May 15, 2003 3:13:58 PM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.