# Relative rotation and a new reference frame as the rotation of the first object

this is my first post on this forum

I have $$n$$ IMUs which outputs its rotation their matrices in the $$XYZ$$ world coordinate system $$w$$. I would like to use multiple IMUs $$n$$, such as $$n_{1}, n_{2}, n_{3} ...$$. IMUs are connected by spherical joints with a fixed arm length $$d$$ such as $$d_{1}, d_{2}, d_{3} ...$$.

The relative rotation represented in $$w$$ between two IMUs $$n_{1}$$ and $$n_{2}$$ is:

$$R_{n_{1}\leftarrow n_{2}} = (R_{n_{1}\leftarrow w})(R_{n_{2}\leftarrow w})^{T}$$

but instead of the $$w$$ coordinate system, I would like to read the relative rotation of the $$R_{n_{1}\leftarrow n_{2}}$$ in the $$n_{1}$$ coordinate system as $$X'Y'Z'$$.

How do I calculate it?

I've found the solution.

Instead of using intrinsic matrix to angle conversions such as:

$$yaw = atan2(R_{n_{1}\leftarrow n_{2}}(2,1),R_{n_{1}\leftarrow n_{2}}(1,1))$$

$$pitch = asin(−R_{n_{1}\leftarrow n_{2}}(3,1))$$

$$roll = atan2(R_{n_{1}\leftarrow n_{2}}(3,2),R_{n_{1}\leftarrow n_{2}}(3,3))$$

I should use extrinsic matrix to angle conversions such as:

$$yaw = atan2(−R_{n_{1}\leftarrow n_{2}}(1,2),R_{n_{1}\leftarrow n_{2}}(1,1))$$

$$pitch = asin(R_{n_{1}\leftarrow n_{2}}(1,3))$$

$$roll = atan2(−R_{n_{1}\leftarrow n_{2}}(2,3),R_{n_{1}\leftarrow n_{2}}(3,3))$$