# quat2angle / atan2 strange quadrant change when calculating angle

11 views (last 30 days)

Show older comments

Hi,

I'm working with IMU systems and calculating rotation angles from quaternions using the quat2angle function. I encountered a problem I believe in the atan2 function. As you can see in the first figure below the computed angle becomes negative.

In Fig1, you can see three lines:

- In blu, the angle was computed using the quat2angle function with the rotation sequence 'YZX', (it is the first output).
- In orange, the angle was computed with an Android app (Dart language).
- In dashed yellow, the angle was computed with my Dart algorithm translated into Matlab code.

I think the problem is in the atan2 function because it is used to compute the angle in my algorithm.

This behavior doesn't always happen. I have recordings where the angle computation is fine, like here:

Do you know what the reason is, and do you have a solution for it?

I have attached the files containing the quaternions of the two recordings

##### 2 Comments

David Goodmanson
on 23 Feb 2024

Hi Matteo,

How do you know that your dart calculation in Matlab is the one that's incorrect? It always agrees with quat2angle so if anything the data seems to imply that the dart calculation in red is the one with the problem..

### Answers (1)

James Tursa
on 4 Mar 2024

### See Also

### Categories

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!