0

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

2
  • Probably not, but you should be able to do this in a single line anyway. Dec 12, 2011 at 12:55
  • @MaticOblak would you be able to show me how? Dec 12, 2011 at 13:05

1 Answer 1

1

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..

2
  • How does the last line work? you cannot multiply pointers (it won't multiply the contents, just the pointers and crash soon)
    – Daniel
    Dec 12, 2011 at 13:39
  • sorry, as I said, I didn't even know what language to write in and couldn't try to debug. In c++ you can lose all the pointers and put "&" symbols before vectors in functions that require pointers. Dec 12, 2011 at 13:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.