# Where have the cross and dot products gone in DirectX10?

In D3D9 there were functions to deal with D3DXVECTOR3's in order to calculate dot and cross products. However these have disappeared from the math library in D3D10.

I assume they must have gone somewhere? My question is where and why?

The D3DX10math.h header still contains declarations for the dot and cross product of vectors. I think the documentation of the D3DXMath library on MSDN is incomplete.

The following example worked fine for me (Please excuse the absolute path for including the header):

#include "C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include\D3DX10math.h"

int main(int argc, char* argv[])
{
D3DXVECTOR3 firstVector = D3DXVECTOR3(1.0f, 0.0f, 0.0f);
D3DXVECTOR3 secondVector = D3DXVECTOR3(2.0f, 1.0f, 0.0f);

float dot = D3DXVec3Dot(&firstVector, &secondVector);
D3DXVECTOR3 cross;

D3DXVec3Cross(&cross, &firstVector, &secondVector);

return 0;
}


Please note that it is probably a good idea to use DirectX Math, because there is no D3DXMath library in DirectX 11 anymore (although you could still use the D3DX10math.h)

These are just simple functions that don't depend on a Direct3D device being available, so as long as the classes/structs being used are the same, you could in theory even go back to D3D8 versions of them (you could even use them in an OpenGL program if you were so inclined).