If you use the magnificent SlimDX (something that you should definitely do), and have been experiencing strange issues with maths or physics, keep reading.
Quaternion Multiplication Issue
As you probably know, Quaternion multiplication is not commutative. This means that “a*b” is not the same than “b*a”.
It seems that XNA and D3DX implement this algorithm in exactly the opposite way, so for the operation: Multiply(Quaternion left, Quaternion right), one does left*right and the other does right*left.
Since the August 2009 release of SlimDX, they changed the way this operation was being done, as they thought they were previously doing it wrong. That’s why you might be getting strange maths or physical results if you install any version newer than March 2009.
I write this post because, believe me, this kind of errors are pretty difficult to trace (if you don’t pay the needed attention to Release Notes, as we did). In our case, we were suddenly getting erratic Rigid Body behavior, but everything else seemed to be working fine.
Of course, the first reaction was to think that some change in our code was to blame. It was obviously something related to maths, vector operations or matrices maybe, but after checking everything for some time, we saw no change related to that.
Then we realized it had something to do with the SlimDX update, so we started checking all the changes done to the library since March 2009, looking for changes in Math code. et voilá: revision 1199: Quaternion multiply was backwards. That was making our rigid bodies go crazy…
We should definitely read the Release Notes of each new version better next time.
Warning
According to this issue, the SlimDX team is changing the method again (back to the old way) in the next June release. So pay attention to the change.
Cheers!