Search code examples
c++mathdirectxdirect3ddirect3d10

D3DX Vector Math function for projection?


Is there a D3DX10 vector3 math function to calculate the projection of one D3DXVECTOR3 onto another?


Solution

  • Mathematically projecting vector a to vector b: p = (a*(b/|b|))*(b/|b|) As for the code I do not know even what language are you writing in. Anyway, the only difference may bi in using pointers or objects..

     D3DXVECTOR3 *a; //input
     D3DXVECTOR3 *b; //input
     D3DXVECTOR3 *tmpVec; //create new temporary vector I guess
     D3DXVec3Normalize(tmpVec, b); //tmpVec becomes normalized b vector
     D3DXVECTOR3 *p = tmpVec*D3DXVec3Dot(a, tmpVec); //result
    

    I hope this helps..