# Applying 3d transformation to cuboid

I have the 8 vertices of a cuboid (red points)(XYZvox) with known distance in millimetres (vox to mm) between each vertex which I transform in 3d space using the 4d transformation matrix (M). I am really struggling to work out the new voxel to millimetre conversion for the transformed vertices. How can I work this out? I feel it should be relatively straightforward:

XYZvox =[ 1     1     1     1   409   409   409   409
1     1   389   389     1     1   389   389
1   162     1   162     1   162     1   162]

M =[0.0337    0.0958   -0.9616   -2.5360
0.3706    0.0107    0.1012 -150.2009
0.0201   -0.3571   -0.2550 -231.0513
0         0         0    1.0000]

for i=1:8

poi1=XYZvox(:,i);
poi2=[XYZvox(:,i)];
poi2(4,1)=1;

poi_trans=M*poi2;

poi_trans=poi_trans(1:3);

scatter3(poi1(1),poi1(2),poi1(3),'red','filled'); xlabel('x'); hold all;
scatter3(poi_trans(1),poi_trans(2),poi_trans(3),'green','filled'); xlabel('x'); ylabel('y'); zlabel('z');

end

• There isn't necessarily a conversion factor afterwards. If your M is a projection or a non-uniform scale, then the distance between a pair of points depends on where it was in the original space. – Dan Hulme Jul 14 '17 at 14:02
• Just to clarify the original data is 3d imaging data in imager coordinates and the transformed data is in world coordinates. If there were no rotation, only scaling and translation I could work out the new pix/vox->mm conversion but because the volume is also rotated it makes it more difficult... – 2one Jul 17 '17 at 9:36