A: 

If both matrices are diagonal, square and have same size, then the multiplication is commutative.

krico
+2  A: 

The convention in mathematics (and thus in programming) is that you multiply the vector by a linear transformation from the right: matrix * vector == transformed vector. So I don't understand you complain. The matrix is already set to the right one. If you want to multiply the vector from the left then you need to transpose the matrix: result = mul(vector, transpose(wvp))

EDIT: OK, Direct3D actually does the opposite. It multiplies vectors from the left (treats them as rows rather than columns). OpenGL, for example, multiplies from the right as normal people do. So you need to load the transposed matrix to the cg program.

ybungalobill
Could you explain then why does the code (DX-specific) generates the matrix, which is `transposed` comparing to multiplication convention? *You could test it yourself, for this code to work shader has to have a `mul(vector, matrix)` instruction, but not the `mul(matrix, vector)`.*
HardCoder1986
Yes, I looked at the documentation. See edit.
ybungalobill
Note: The cue was that you wrote `world * view * projection`. The order here may be right iff you project as `vector * world * view * projection`.
ybungalobill