Need some help understanding the Blender matrix_world

I’m writing an exporter for LDraw in blender, and I’m having a hard time understanding how and why the values in object.matrix_world don’t line up with how the matrix is described in the documentation.

Here is a link to the file format specs.

I was able to find the proper order of matrix_world elements to put in the matrix values for the LDraw subpart through brute force, but I don’t understand what the values in matrix_world mean, other than x,y,z. Changing the values affects the model and strange ways if they are changed on their own without changing its linked value.

There looks to be a pattern, but I don’t know enough about matrix math to even look for an answer. I would love if someone could help me understand this.

I’ve attached the blend file I’m working on, which outputs a valid and properly transformed LDraw part. If you want to export a part, you will have to change the path it exports to, since I’m not to the interface part of the process yet.

export.blend (800.6 KB)