0

How to do component-wise multiplication of two 3d vector? it seems MS didn't provide such functions in DirectXMath.h, what's Microsoft doing there? in the old SDKs(DX 10/9), I can make a product of two vectors directly as:

v3 = v1 * v2;

or multiply a vector by a scalar like:

v2 = v1 * 1.0f;

but now, there is no operator * for XMVECTOR type, so I can't do that. so I need to make the product manually as

v3 = (v1.x * v2.x + v1.y * v2.y + v1.z * v2.z);

although it is not so difficult, I think DirectXMath should provide such a basic function.

zdd
  • 8,258
  • 8
  • 46
  • 75

1 Answers1

2

The dot product can be achieved with XMVector*Dot method. MSDN link for dot3product.

And the good page exists on msdn with methods list: MSDN

Also, I think that Microsoft didn't make operator* override because it is not clear which product this operator should use - dot or cross product.

acrilige
  • 2,436
  • 20
  • 30
  • thank you very much, I am sure I see XMVector3Dot, but in my mind the result of a dot product is scalar(like what D3DXVec3Dot does), but now MS make the result as a vector. I didn't realize this change, so I missed this function. – zdd Mar 25 '13 at 02:04