It’s funny that not too long after my boss posted on the company development blog about the whole annoying left/right handedness issue (perhaps after wrestling with some inherited tools which likely flip-flop between handedness and contain lots of kludges to convert between them), we run into another pesky set of competing maths conventions while converting some “optimised” (i.e., obfuscated) swept sphere to plane collision detection code from PS2 Vector Unit assembly language to more portable C++.
I should add that we don’t have any PS2 VU documentation and that the VU docs available freely on the web are somewhat thin on the ground.
Anyway, all the hassle was about plane representation. Firstly, there are two competing canonical plane representations:
- Ax + By + Cz + D = 0
- Ax + By + Cz = D
Where (A, B, C) is the vector normal to the plane, and D is the signed distance from the origin to the plane along the plane’s normal. Of course the only real difference between the two is that the constant D is either negated or not, depending on which form you like best.
So, no big deal. For example, when you want to calculate the distance from a point to the plane, you either (depending on your convention) add or subtract D from the dot product of the normal and the point.
The second competing convention is to do with the plane’s normal. It’s easy to imagine that if you have a normal vector pointing out of a plane, that side can be called either the “front” or the “back” of the plane. Thankfully my boss and I are on the same page on this one. We reckon the normal points out of the front of the plane. So if we have some collision geometry, say a ground plane, the normal will be pointing upwards.
Now if I can only convince the world that +Z=up (a la Quake) and I’ll be set!