Matrices and axes are the source of some confusion in 3d programming because it's not obvious if a matrix is column-major or row-major without reading the source, and because 3D game engines and 3D editing applications do not consistently use the same axes for the same things. For example, the Unity engine uses +Z forward, but the Unreal engine uses +X forward, and SteamVR uses -Z forward.
This can be written with row-major storage as:
m[0][0] m[0][1] m[0][2] m[0][3] m[1][0] m[1][1] m[1][2] m[1][3] m[2][0] m[2][1] m[2][2] m[2][3]This is stored in memory as:
m[0][0], m[0][1], m[0][2], m[0][3], m[1][0], m[1][1], m[1][2], m[1][3], m[2][0], ...Given the three axes AX, AY, AZ, and translation T, we would represent that in the above layout as:
AXx AYx AZx Tx AXy AYy AZy Ty AXz AYz AZz TzNote this implies these use column-major mathematical notation. The axes and translation vectors are represented as column vectors, while their memory layout is row-major.
This is important because column-major notation uses Post-Multiplication (Mv = matrix times vector) rather than Pre-Multiplication (vM = vector times matrix).
// right-handed system
// +y is up
// +x is to the right
// -z is going away from you
+Y
^
|
|---------> +X
\\
\\
+Z
VerticeInWorldSpace = WorldFromLocalSpace * LocalSpaceFromModelSpace * VerticeInModelSpace.
出典: https://github.com/ValveSoftware/openvr/wiki/Matrix-Usage-Example
出典2: https://github.com/ValveSoftware/openvr/issues/675#issuecomment-355739193