This is the third article in a series about coordinate systems comparison between 3ds Max, Unity 3D and Unreal Engine. Here is the complete list of articles:
The picture below shows the different basis orientations[a] for the three platforms.
- 3ds Max – right handed, z-up
- Unity 3D – left handed, y-up
- Unreal Engine – left handed, z-up
Calculating Cross Products
When calculating a cross product, the rule says you should apply the right-hand rule[b] to obtain the direction of the resulting vector. This is true if you are working in a standard (right-handed) basis[c] as in 3ds Max. If you are working in Unity 3D or in Unreal Engine, you should use the left-hand rule to calculate the direction of a cross product.
To calculate n = a × b using the right-hand rule, one simply points the forefinger of the right hand in the direction of a and the middle finger in the direction of b. Then, the vector n is coming out of the thumb (see the picture on the right).
Personally I prefer using the rule where you point your open hand in the direction of a and then close it in the direction of b. Then the n vector is coming out of the thumb.
For the left-hand rule, follow the same instructions but using your left hand.
Given these rules is easy to figure out how to multiply each couple of basis versors to obtain a third vector. For example, you want to get the z vector in Unity? You have two possibilities: x×y or y×x. You can just apply the left-hand rule and see which one is correct by looking at the basis gizmo you can find in the scene view. No need to memorize anything.
Here is the complete list of identities for the vectors of an orthonormal basis (you don’t have to remember it, just use the previous technique):
- x × y = z
- z × x = y
- y × z = x
If you don’t remember which orientation your platform is using, you can just remember the first identity above: x × y = z. Then look at the basis gizmo in the viewport of your software and figure out which rule, right or left hand, gives the z vector as a result.