Reputation: 10284
Is there a D3DX10 vector3 math function to calculate the projection of one D3DXVECTOR3 onto another?
Upvotes: 0
Views: 1116
Reputation: 16774
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..
Upvotes: 1