<p>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:<a href="https://i.sstatic.net/o3jR7.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/o3jR7.png" alt="enter image description here"></a></p>

<pre><code>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
</code></pre>

CC BY-SA 3.0
2017-07-14T14:02:39.433Z
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
CC BY-SA 3.0
2017-07-17T09:36:08.893Z
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
<3d><affine-transformations><matlab>
Applying 3d transformation to cuboid
2one
# Applying 3d transformation to cuboid

(Asked by: username_0 on 2017-07-14)

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:[![enter image description here](https://i.sstatic.net/o3jR7.png)](https://i.sstatic.net/o3jR7.png)

```
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

```

**Tags:** 3d, affine-transformations, matlab

> **Comments:**
> **username_1**: 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.  
> **username_0**: 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...  

---

## 0 answers

