I initially attempted to do this based on a rotation matrix in the form of [Rot. Matrix (3x3)] * [earth frame force components (3x1)] = [device frame force components (3x1)]. For those not familiar with Euler rotation matrices, the elements of the matrix are functions of the three angles of rotation (theta, psi, phi).
As I know the earth and device frame components I would like to back calculate the Rotation matrix. I cannot simply say [Rot. Matrix] = [device frame]/[earth frame] as this does not keep the relationships between the elements of the matrix.
Is there a way to back calculate the matrix (or values of theta, psi, phi) so that the caluclated matrix / angles satisfy that the elements of rotation matrix (1,1) = cos(psi)cos(theta); (1,2) = sin(psi)cos(theta); etc.
Yes. See this SpinCalc FEX submission by John Fuller:
James Tursa
>
> Is there a way to back calculate the matrix (or values of theta, psi, phi) so that the caluclated matrix / angles satisfy that the elements of rotation matrix (1,1) = cos(psi)cos(theta); (1,2) = sin(psi)cos(theta); etc.
No. One vector and its rotation is not enough to recover the rotation. You need at least two vectors and their rotations.
Bruno
My understanding was that he had the rotation matrix and wanted to get the equivalent euler angle sequence from it. But if he just has the resulting 3-element vector to use, then yes I agree there is not enough information.
James Tursa
Correct. I guess an easy example is to use gravity. Assuming the device is aligned with the surface of the earth, the gravitational field on it would be [0;0;-1] (x,y,z in g's). If the device is rotated 10 deg around X axis, 30 deg around the new Y' axis, then 25 deg around the new Z'' axis the output would be [0.5;-0.15;-0.85]. I can measure the new output from the device and know the base output; I'm trying to determine the rotation matrix to relate the two.
I was hoping there was some way to do this by coding into MATLAB that even though there are 9 elements in the rotation matrix they are functions of three variables (the three rotation angles).
There are an infinite number of solutions. Would any of them work for you? e.g., a minimum total rotation angle solution? (You could get that with a simple cross product to get the rotation axis and a dot product to get the angle.)
James Tursa
As I said, one point F1 and its rotation F2 is not enough to resolve the rotation. Rotation has 3 DOFs, one point and its rotation provides only two independent information about the rotation (since the norm of force vectors are equal regardless the rotation |F1|=|F2|). So there are infinity rotation that maps one vector F1 to its image F2 as James told you.
Those rotations have the rotation vector belongs to the median plane to vector F1 and F2.
Bruno
In this case I'm trying to determine the orientation of an object, so I'm afraid that there's only one that would be correct. Thanks for your help James and Bruno; I was afraid this was the answer (there is no single solution).
Quick update (in case some future user needs this):
After thinking about the above (cross product to find rotation axis; dot product to find rotation angle) I remembered that the previously linked function SpinCalc can take that as input and tell the rotation along different Euler angles. The MATLAB function vrrotvec can take in two vectors and give the rotation axis and angle, so these outputs (converted to degrees) put into SpinCalc gave the result I needed.
Thanks again for the help; had the two of you not given me these comments to think on it would have taken me considerably longer to come to this conclusion.