I am currently trying to solve an issue regarding the azimuth being outputted by my android phone.
Briefly put, I am utilizing its rotation vector to acquire the current azimuth of the device and outputting it to the screen. As of now this currently does work when my android device is laying flat but I noticed that as soon as I adjust the pitch of the device when I pick up the phone and angle it up/down while maintaining the same direction, the azimuth begins to gradually change and would differ by up to 10 or even 20 degrees from its original position.
I have already posted a similar thread over on stackoverflow here which contains the method that acquires the phone's rotational vector, remaps it based on the device's current orientation, and then retrieves the resulting azimuth. Unfortunately I have not received any responses to my thread as of posting this so I was hoping I could take an approach that would go down a more mathematical approach.
Use case wise, ideally it would perform similar to how Google Maps' compass mode works where whether the device is flat or its pitch is adjusted by a certain angle of degrees, the azimuth stays the same and only changes when you make changes to the tilt.