Hi Alexy, thank you for your help.

I eventually managed to shift the position of my scene by subtracting the average location of my markers from the transform matrix.

I also eventually managed to properly orient my scene by calculating the appropriate 3x3 matrix and plugging that into the transform matrix.

However, when I do both, the position is once again wrong and I have no idea why. I've tried doing is sequentially, I've tried getting the old position vector and transforming the coordinates to my new coordinate matrix but not a single combination I can come up with seems to work.

how do you simultaneously adjust the rotation and the translation, and which coordinates are required for the translation? (the coordinates of the 0.0.0 position prior to rotating, the coordinates of the 0.0.0 position AFTER the rotation, or something else?)

Note: if I ONLY input the iM rotation values, the scene is properly oriented. If I ONLY input the locAvg values, the scene is properly positioned. I've tried with locAvg, and with locAvg2 (and also with a locAvg calculated from the regular, non-inversed version of my rotation matrix).

#Transform locAvg to new matrix coordinates:

locAvg2 = Metashape.Vector((0, 0, 0))

locAvg2[0] = locAvg[0] * iM[0, 0] + locAvg[1] * iM[0, 1] + locAvg[2] * iM[0,2]

locAvg2[1] = locAvg[0] * iM[1, 0] + locAvg[1] * iM[1, 1] + locAvg[2] * iM[1, 2]

locAvg2[2] = locAvg[0] * iM[2, 0] + locAvg[1] * iM[2, 1] + locAvg[2] * iM[2, 2]

#Determine adjustment matrix

chunkAdjust = Metashape.Matrix([[iM[0,0], iM[0,1], iM[0,2], - locAvg[0]],

[iM[1,0], iM[1,1], iM[1,2], - locAvg[1]],

[iM[2,0], iM[2,1], iM[2,2], - locAvg[2]],

[0.0, 0.0, 0.0, 1.0]])

chunk.transform.matrix = chunkAdjust

#Other ways to apply new matrix

#chunk.transform.matrix = Metashape.Matrix().Translation(locAvg) * chunkAdjust

#chunk.transform.matrix = Metashape.Matrix().Translation(locAvg) * Metashape.Matrix().Rotation(chunkAdjust.rotation())

chunk.updateTransform()