Jump to content
  • Advertisement
Sign in to follow this  
Keba

D3DXVec3Lerp Function

This topic is 4952 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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".

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!