COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### Suggestions for Inverse Euler Rotation

• Email
• Follow

```I have a device which can rotate about three axis and measure force along the x,y,z axis in it's frame of reference. This device is rotated relative to the earth where a known force is applied to it (the x,y,z components in earth reference is known). I am attempting to determine the Euler rotation angles (aircraft style - rotate about x, y', then z'' axis) to determine the orientation of the device at a given time.

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.
```
 0

See related articles to this posting

```"Rob Fogle" <Robert.Fogle_take.out.all.after.underscore@lord.com> wrote in message <ias714\$aee\$1@fred.mathworks.com>...
> I have a device which can rotate about three axis and measure force along the x,y,z axis in it's frame of reference. This device is rotated relative to the earth where a known force is applied to it (the x,y,z components in earth reference is known). I am attempting to determine the Euler rotation angles (aircraft style - rotate about x, y', then z'' axis) to determine the orientation of the device at a given time.
>
> 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:

http://www.mathworks.com/matlabcentral/fileexchange/20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors

James Tursa
```
 0

```"Rob Fogle" <Robert.Fogle_take.out.all.after.underscore@lord.com> wrote in message <ias714\$aee\$1@fred.mathworks.com>...

>
> 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
```
 0

```"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <iascdk\$3o3\$1@fred.mathworks.com>...
> "Rob Fogle" <Robert.Fogle_take.out.all.after.underscore@lord.com> wrote in message <ias714\$aee\$1@fred.mathworks.com>...
>
> >
> > 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
```
 0

```"James Tursa" <aclassyguy_with_a_k_not_a_c@hotmail.com> wrote in message <iasf5p\$563\$1@fred.mathworks.com>...
> "Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <iascdk\$3o3\$1@fred.mathworks.com>...
> > "Rob Fogle" <Robert.Fogle_take.out.all.after.underscore@lord.com> wrote in message <ias714\$aee\$1@fred.mathworks.com>...
> >
> > >
> > > 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).
```
 0

```"Rob Fogle" <Robert.Fogle_take.out.all.after.underscore@lord.com> wrote in message <iasg5l\$a5s\$1@fred.mathworks.com>...
>
> 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
```
 0

```>
> 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).

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
```
 0

```> 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.)

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).
```
 0

```"Rob Fogle" <ftf697y-with-gs-not-fs@gmail.com> wrote in message <iau82c\$rst\$1@fred.mathworks.com>...
> > 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.)
>
> 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.
```
 0