# Averaging rotations and calculating the variability

**URL:** <https://discourse.slicer.org/t/averaging-rotations-and-calculating-the-variability/30605>\
**Category:** Support\
**Tags:** transforms\
**Created:** [July 14, 2023, 2:06pm UTC](https://discourse.slicer.org/t/averaging-rotations-and-calculating-the-variability/30605 "2023-07-14T14:06:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Melanie](https://avatars.discourse-cdn.com/v4/letter/m/35a633/32.png) [@Melanie](https://discourse.slicer.org/u/Melanie)\
**Post date:** [July 14, 2023, 2:06pm UTC](https://discourse.slicer.org/t/averaging-rotations-and-calculating-the-variability/30605/1 "2023-07-14T14:06:12Z")

</div>

Hi,

I use the model registration module to register bones and calculate the 3-d displacements.  
My aim is to define the axis of rotation (finite helical axis).  
I would like to calculate a mean rotation for all transforms (I can leave the translations for the minute) and then calculate the variability. (Ultimately to calculate the mean rotation axis and the variability around the mean axis)

What’s the best way to do this pls

---

<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:** [July 14, 2023, 2:21pm UTC](https://discourse.slicer.org/t/averaging-rotations-and-calculating-the-variability/30605/2 "2023-07-14T14:21:44Z")

</div>

This topic has been discussed on this forum:

> [@Calculate axis of rotation](https://discourse.slicer.org/t/calculate-axis-of-rotation/15871/17):
>
> Thanks for kind support @lassoan Found this, after some research "Similarly we can also calculate backwards and find the intantanous axis of rotation at some distance − ⃗ r from any point if we know the linear velocity of the point and the angular velocity. This is given by: [\begin{equation} \label{eq:2} -\vec{r}= \frac{\vec{\omega} \times \vec{v}\_P }{ \vec{\omega}\cdot\vec{\omega} } \end{equation}] Thus if know the position of a point ⃗ r P , its linear velocity ⃗ v P we can fi…

An algorithm is provided for computing axis of rotation for a single pair of transforms and a perfect rotation around a single axis. Nobody volunteered to develop a more robust algorithm that could approximate the rotation axis from many imperfect measurements, so you would need to figure it out.

It may not be very hard, as there are not too many unknowns (you only have to determine position and orientation of the rotation axis and for each pair of transforms a rotation angle, so if you have 4 pair of transforms then in total you have 10 unknowns) and you may be able to get an approximate initial guess based on anatomical knowledge. You need to specify some error metric (such as residual position error of some anatomical landmark points) and then you can compute the uknowns using any non-linear optimizer.
