My problem originates from some code that I'm writing to parse an obscure file-type in which a geometric entity is defined in it's own 'local space', and a rotation and translation are provided to convert into 'global 3D space'.
My issue is that rotations aren't given in the form of a matrix, quaternion, euler, or other "useful" form of rotation. Instead, they provide 2 of the 3 axes for the local-space (the 3rd is derived via the cross-product).
Normally this isn't an issue, as a point would be transformed by separately multiplying it's xyz values with the appropriate xyz local-axes adding them up, and then adding the translation to that. However, there are times in which I need to combine these rotations together, so my thought is to convert them to quaternions, 'add' them up, and then pull the resulting axes out of that.
To explicitly state my question: how would I derive a quaternion given the three principle axes after the rotation?
Given the axes of the geometric body (hereafter: "body axes"), described with respect to some fixed global axes, you should be able to derive the corresponding rotation matrix that would rotate the global axes onto the body axes and vice versa.
In other words, if the body axes are $b_1, b_2, b_3$ and the global axes are $g_1, g_2, g_3$, then you want a rotation $R$ that does
$$R(g_1) = b_1, R(g_2) = b_2, R(g_3) = b_3$$
Or perhaps vice versa. Since inversion is the same as transposition for rotations, vice versa isn't hard to do either.
Now, again, let the body axes be described in terms of the global axes like so:
$$b_1 = B^{11} g_1 + B^{21} g_2 + B^{31} g_3$$
And similarly for $b_2, b_3$. Then, the matrix is basically computed for you. If you wrote out the above relations in matrix language, using the $g$ basis, you would have
$$R \begin{bmatrix} 1 \\ 0 \\ 0 \end{bmatrix} = \begin{bmatrix} B^{11} \\ B^{21} \\ B^{31}\end{bmatrix}$$
You should recognize now that this is just the first column of the matrix $R$. The columns of $R$ are just the body axes' unit vectors, expressed in terms of the global basis vectors.
Now that the matrix is known, you can use well-established algorithms to translate that into quaternions, if you should need to.