# Direction of tool tip

**URL:** <https://discourse.slicer.org/t/direction-of-tool-tip/32925>\
**Category:** Support\
**Created:** [November 21, 2023, 10:59am UTC](https://discourse.slicer.org/t/direction-of-tool-tip/32925 "2023-11-21T10:59:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![saeedeh\_lavasany](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/saeedeh_lavasany/32/7539_2.png) [@saeedeh\_lavasany](https://discourse.slicer.org/u/saeedeh_lavasany)\
**Post date:** [November 21, 2023, 10:59am UTC](https://discourse.slicer.org/t/direction-of-tool-tip/32925/1 "2023-11-21T10:59:41Z")

</div>

Hello,

I tracked a tool using the EMT system and restored transformation matrices. I have obtained the position of the tool in a 3D space, which I’ve derived from CT/SPECT images in MATLAB. Now, I aim to represent the tool’s orientation accurately. Although everything appears correctly aligned in 3D Slicer, I’m encountering issues displaying the tool’s direction accurately in MATLAB.

I’m seeking guidance on converting a rotation matrix to Euler angles. The rotm2eul function isn’t providing the correct directional information. Any advice on how to achieve accurate representation would be greatly appreciated.

---

<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:** [November 21, 2023, 12:21pm UTC](https://discourse.slicer.org/t/direction-of-tool-tip/32925/2 "2023-11-21T12:21:37Z")

</div>

You can use Pivot calibration module’s Spin calibration to determine the shaft direction of a rod-shape tool. See U-11 [SlicerIGT tutorial](https://www.slicerigt.org/wp/user-tutorial/). The module is in SlicerIGT extension.

If your tool has a more complex shape then you can determine the transform between the coordinate system of the tool’s model and the tool-attached sensor using landmark registration. See U-12 [SlicerIGT tutorial](https://www.slicerigt.org/wp/user-tutorial/).

---

<div class="post-metadata">

**Author:** ![saeedeh\_lavasany](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/saeedeh_lavasany/32/7539_2.png) [@saeedeh\_lavasany](https://discourse.slicer.org/u/saeedeh_lavasany)\
**Post date:** [November 21, 2023, 12:54pm UTC](https://discourse.slicer.org/t/direction-of-tool-tip/32925/3 "2023-11-21T12:54:14Z")

</div>

I have completed the entire process of Pivot calibration and Landmark registration, resulting in the Tool to CT transformation matrices. These matrices accurately map the tool’s tip position to the CT-based model. Now, I am seeking guidance on displaying the tool’s direction within this space using the Tool to CT Transformation matrix in MATLAB.

---

<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:** [November 21, 2023, 3:15pm UTC](https://discourse.slicer.org/t/direction-of-tool-tip/32925/4 "2023-11-21T15:15:05Z")

</div>

Regarding Matlab, the only advice I can give is that it is time to move on. 15 years ago, Matlab was one of the best environment for scientific computing and computational algorithm prototyping, but in recent years Python has made Matlab largely irrelevant. Specifically, prototyping surgical navigation systems in Matlab would be so much inferior due to lack of frameworks, libraries, licensing hassles, and difficulties in deployment and product translation that switching to Python would pay off very quickly.

---

<div class="post-metadata">

**Author:** ![saeedeh\_lavasany](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/saeedeh_lavasany/32/7539_2.png) [@saeedeh\_lavasany](https://discourse.slicer.org/u/saeedeh_lavasany)\
**Post date:** [November 22, 2023, 8:00am UTC](https://discourse.slicer.org/t/direction-of-tool-tip/32925/5 "2023-11-22T08:00:05Z")

</div>

Thank you for your advice. I’ll attempt it using Python.
