# Rotational transformation matrix & surface registration of models

**URL:** <https://discourse.slicer.org/t/rotational-transformation-matrix-surface-registration-of-models/23680>\
**Category:** Support\
**Created:** [June 2, 2022, 4:10am UTC](https://discourse.slicer.org/t/rotational-transformation-matrix-surface-registration-of-models/23680 "2022-06-02T04:10:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mdhan](https://avatars.discourse-cdn.com/v4/letter/m/e47774/32.png) [@mdhan](https://discourse.slicer.org/u/mdhan)\
**Post date:** [June 2, 2022, 4:10am UTC](https://discourse.slicer.org/t/rotational-transformation-matrix-surface-registration-of-models/23680/1 "2022-06-02T04:10:41Z")

</div>

Hello,

Sorry for troubling you all, but I’d be grateful if you could kindly help with me with something I’m struggling with. I’ve been having trouble utilizing the rotational transformation matrix to suit my needs, and wanted to make sure I was interpreting things correctly.

What I am interested in knowing is the rotational transformation matrix in degrees, and I have been using an online calculator ([3D Rotation Converter](https://www.andre-gaschler.com/rotationconverter/)) to convert the 3x3 part of Slicer’s 4x4 matrix.

As a test, I created a cube on Meshmixer, and duplicated it. Then, I rotated the duplicate 11.1, 22.2, 33.3 degrees in the x, y, and z axes, respectively. After exporting these 2 surfaces, I then used the Slicer CMF registration and got the transformation matrix in the 4x4 matrix format.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/5/b/5b1167b3e8029b8f45fb07a60bebcc9eb1e2df53.jpeg)

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/1/d/1d93896fa83267449c862870e8e50773eaf32484.png)

![MATRIX](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/3/d/3d55047a37ff516b14cd3fe61aa6d57672fb2f24.jpeg)

However, when I tried to convert the 3x3 matrix to angles, all of the numbers seemed quite off from the 11.1, 22.2, 33.3 degrees. Even when accounting for possible registration errors, the discrepancies seem quite severe (plus on visual inspection the registration seems accurate).

 ![OUTPUT](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/8/1/81437bdcd1847c31bfe9094d3537c1065ddee799.jpeg)

I would again be grateful for everyone’s wisdom on this!!

---

<div class="post-metadata">

**Author:** ![mau\_igna\_06](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mau_igna_06/32/9056_2.png) [@mau\_igna\_06](https://discourse.slicer.org/u/mau_igna_06)\
**Post date:** [June 2, 2022, 4:46pm UTC](https://discourse.slicer.org/t/rotational-transformation-matrix-surface-registration-of-models/23680/2 "2022-06-02T16:46:12Z")

</div>

If you can build Slicer, you could test my Dynamicmodeler Tool: transformMaker  
It let’s you compose any number of angles, convert them in transforms and it will return the resulting rotation matrix angle

See more info here:

> [@DynamicModeler Transform Maker](https://discourse.slicer.org/t/dynamicmodeler-transform-maker/23626/8):
>
> Hi Andras. I’ll take time to give a full answer on the afternoon but here you have a preview video: And here is the branch, thanks for testing: Please don’t be confused by the name of the branch, the idea of the transform maker came while I was developing the AddGeometries tool so it’s on this branch Best regards, Mauro

---

<div class="post-metadata">

**Author:** ![mikebind](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@mikebind](https://discourse.slicer.org/u/mikebind)\
**Post date:** [June 2, 2022, 8:21pm UTC](https://discourse.slicer.org/t/rotational-transformation-matrix-surface-registration-of-models/23680/3 "2022-06-02T20:21:19Z")

</div>

You might also find this module helpful: [GitHub - mikebind/SlicerCharacterizeTransformMatrix](https://github.com/mikebind/SlicerCharacterizeTransformMatrix)

Could your issue be that there are multiple ways to decompose a net rotation into series of rotations?

---

<div class="post-metadata">

**Author:** ![mdhan](https://avatars.discourse-cdn.com/v4/letter/m/e47774/32.png) [@mdhan](https://discourse.slicer.org/u/mdhan)\
**Post date:** [June 13, 2022, 3:08am UTC](https://discourse.slicer.org/t/rotational-transformation-matrix-surface-registration-of-models/23680/4 "2022-06-13T03:08:59Z")

</div>

Thank you very much mau\_igna\_06 and mikebind, it’s incredibly helpful and I’m now able to do what I wanted thanks to you! Hope one day I’d be able to contribute to the community like you folks!

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [June 13, 2022, 1:43pm UTC](https://discourse.slicer.org/t/rotational-transformation-matrix-surface-registration-of-models/23680/5 "2022-06-13T13:43:52Z")

</div>

> [@mikebind](#):
>
> You might also find this module helpful: [GitHub - mikebind/SlicerCharacterizeTransformMatrix](https://github.com/mikebind/SlicerCharacterizeTransformMatrix)

@mikebind Would you consider adding this module to the [Sandbox extension](https://github.com/PerkLab/SlicerSandbox)? We maintain this extension to make it easier for users to install small, experimental modules (few clicks instead of downloading and extracting a zip package, setting additional module paths, etc.).

---

<div class="post-metadata">

**Author:** ![mikebind](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@mikebind](https://discourse.slicer.org/u/mikebind)\
**Post date:** [June 13, 2022, 10:09pm UTC](https://discourse.slicer.org/t/rotational-transformation-matrix-surface-registration-of-models/23680/6 "2022-06-13T22:09:38Z")

</div>

Yes, I’ll work on that. I have already forked the Sandbox repo to work on adding the DICOM stitching module but got bogged down trying to improve it and add some tests, so had not finished that process yet. This transformation matrix module is very simple and I think will not really require much modification, so it should be quicker to add when I get a chance. I’ll try to get to that soon.
