0

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

Dollarslice
  • 9,917
  • 22
  • 59
  • 87

1 Answers1

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

Matic Oblak
  • 16,318
  • 3
  • 24
  • 43
  • 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 '11 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. – Matic Oblak Dec 12 '11 at 13:42