D3DXVec3Lerp Function

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

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 on other sites
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 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 on other sites
That's a much better explanation, thanks! :)

1. 1
2. 2
3. 3
Rutin
23
4. 4
5. 5
khawk
14

• 9
• 11
• 11
• 23
• 12
• Forum Statistics

• Total Topics
633653
• Total Posts
3013166
×