Skip to main content
gamedev.net
🔒 Locked

D3DXVec3Lerp Function

Started by Keba 2 replies 1.8k views
Original Post
Keba
Keba
the docs sais: D3DXVECTOR3 *D3DXVec3Lerp( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, FLOAT s ); Parameters pOut [in, out] Pointer to the D3DXVECTOR3 structure that is the result of the operation. pV1 [in] Pointer to a source D3DXVECTOR3 structure. pV2 [in] Pointer to a source D3DXVECTOR3 structure. s [in] Parameter that linearly interpolates between the vectors. Return Value: Pointer to a D3DXVECTOR3 structure that is the result of the linear interpolation so my question is: What is s? / thanks
fiskbil
fiskbil
s denotes which point you wish the interpolation to calculate. Say you have vector (3; 0; 0) and (0; 0; 1). If s = 0.5 then the result would be (1.5; 0; 0.5) since that is halfway between the two vectors. So s is a value between 0 and 1 telling the function where along the line between the two points you want to "be".
Mezz
Mezz
Just to add slightly (and hopefully aid in understanding) s is the parameter which basically says how much of each vector to contribute to the final answer.

The actual linear interpolation equation is probably something like this:

pOut = pV1*(1-s) + pV2*s

Thus, you can see that s weights each vector into the answer, if s is zero, you get:

pOut = pV1*(1-0) + pV2*0
meaning
pOut = pV1

and if s is 1, you get
pOut = pV1*(1-1) + pV2*1
meaning
pOut = pV2

Hope that clears things up some more.

-Mezz
fiskbil
fiskbil
That's a much better explanation, thanks! :)

Topic Locked

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

Sign in to reply to this topic.