# Calculate angle between oriented bounding boxes

**URL:** <https://discourse.slicer.org/t/calculate-angle-between-oriented-bounding-boxes/15241>\
**Category:** Development\
**Tags:** segmentation\
**Created:** [December 27, 2020, 7:07pm UTC](https://discourse.slicer.org/t/calculate-angle-between-oriented-bounding-boxes/15241 "2020-12-27T19:07:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Emrah\_Akay](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/emrah_akay/32/9272_2.png) [@Emrah\_Akay](https://discourse.slicer.org/u/Emrah_Akay)\
**Post date:** [December 27, 2020, 7:07pm UTC](https://discourse.slicer.org/t/calculate-angle-between-oriented-bounding-boxes/15241/1 "2020-12-27T19:07:56Z")

</div>

Operating system : Win10 x64:  
Slicer version : 4.11.20200930

I’m a medical doctor and fairly new to the slicer 3d application, I am trying to calculate the angles between oriented bounding boxes created with the python code here [Documentation/Nightly/ScriptRepository - Slicer Wiki](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Get_size.2C_position.2C_and_orientation_of_each_segment)

 ![Ekran Alıntısı](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/b/8/b880e801953933c6058c76777f5a3752add37543.jpeg)  
I tried to use the segment statistics module for this task but cannot fully understand how to use the data provided. What i need is a simple solution like the angle planes module since i’ll be dealing with huge amount of calculations. Thanks for your patience…

---

<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:** [December 27, 2020, 8:08pm UTC](https://discourse.slicer.org/t/calculate-angle-between-oriented-bounding-boxes/15241/2 "2020-12-27T20:08:05Z")

</div>

`obb_direction_ras_x`, `obb_direction_ras_y`, and `obb_direction_ras_z` are vectors specifying direction of coordinate system axes. You can get angles between vectors using standard vector math, but you can also use convenience functions in VTK, for example:

```python
v1 = box1_obb_direction_ras_x
v2 = box2_obb_direction_ras_x
box1_box2_x_angle = vtk.vtkMath.DegreesFromRadians(vtk.vtkMath.AngleBetweenVectors(v1, v2))

```

---

<div class="post-metadata">

**Author:** ![Emrah\_Akay](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/emrah_akay/32/9272_2.png) [@Emrah\_Akay](https://discourse.slicer.org/u/Emrah_Akay)\
**Post date:** [December 28, 2020, 1:40pm UTC](https://discourse.slicer.org/t/calculate-angle-between-oriented-bounding-boxes/15241/3 "2020-12-28T13:40:37Z")

</div>

Thank you for quick reply. I have managed to measure the vector angles as you described but was unable to produce accurate reproducible results. I need to measure a specific angle for each OBB like this one

 ![Ekran Alıntısı](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/9/b/9b27e4fdaeb81c38b81421146b25f072e2b89fe5.jpeg) Actually it’s the angle between the central planes of each OBB ![Ekran Alıntısı2](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/0/3/03566cad66d3b38e424532c8038aa4cea51101c2.jpeg) would you please point me to the right direction?. Thanks in advance…
