Having two Cartesian coordinate systems:
C1(X1,Y1,Z1)
C2(X2,Y2,Z2)
(where X1,Y1,Z1 and X2,Y2,Z2 are orthogonal unit vectors)
Is it possible to have a third Cartesian coordinate system C3(X3,Y3,Z3) as an "average" of these?
Making a component-wise average X3=X1+X2, Y3=Y1+Y2 and Z3=Z1+Z2 (followed by normalization), could result in a zero component, if e.g. X1=-X2. Is there a better way, using perhaps circular means or using rotation matrixes and finding a half-way rotation between C1 and C2 that leads to C3?
(Or am I asking the wrong question? I couldn't find any quick answers online)
Relate the two coordinate frames by a rotation matrix, that is, find the relative rotation matrix $R$ such that
$ R_2 = R R_1 $
where $R_1$ is the rotation matrix whose columns are the unit vectors along the $X_1, Y_1, Z_1$ axes of the first frame, and similarly for $R_2$.
Identify the axis and rotation angle of $R$, then take half of that rotation angle to generate the average of $R_1$ and $R_2$.
The identification of $R$ relies on the Rodrigues' formulation of a rotation matrix, namely
$R = a a^T + (I - a a^T) \cos \theta + S_a \sin \theta $
Here $a$ is the unit vector along the axis of rotation, $\theta$ is the angle of rotation, and $S_a$ is defined as
$ S_a = \begin{bmatrix} 0 && - a_z && a_y \\ a_z && 0 && - a_x \\ -a_y && a_x && 0 \end{bmatrix} $
Note that if add the diagonal elements of $R$ (the trace of $R$) you get
$ R_{11} + R_{22} + R_{33} = 1 + \cos \theta (3 - 1) = 1 + 2 \cos \theta $
Thus you get the rotation angle immediately. Next we want to find the coordinates of the unit vector $a$ (the axis), and this can be done by using the fact that the first two terms in the Rodrigues' formula are symmetric matrices while the third is skew-symmetric. So by taking the difference:
$ R_{12} - R_{21} = -2 a_z \sin \theta $
and similarly for the other off-diagonal entries.
Once $a$ and $\theta$ are known, generate the rotation matrix corresponding to $\dfrac{\theta}{2} $, while keeping the same axis.
Plug these values in the Rodrigues' formula, to get $R_{ \theta/2} $, and finally the average coordinate frame will be
$ R_{av} = R_{ \theta /2} R_1$
The columns of $R_{av} $ are the average $X, Y, Z$ axes.