I'm trying to retrieve my current heading from an android device using Delphi Rad 10.1 Berlin.
There is a function in the OrientationSensor that is True Heading, however, this is only enabled on Windows, according to the Embarcadero knowledgebase.
So, I think to do it, I need to convert the following Variables into one heading.
OrientationSensor1.Sensor.HeadingX
OrientationSensor1.Sensor.HeadingY
OrientationSensor1.Sensor.HeadingZ
As I only need heading(and don't care about altitude), I believe I can disregard Z.
In return I need to retrieve current heading which should be from 0-360.
I used a formula I found online which is :-
angle = atan2(Y, X);
Which seemed to help, but was wildly inaccurate at some positions, and was negative at others.
Any help or advice would be appreciated.
Some details that may help are :
It's a Multi-Device Application in Delphi.
It's only going on Android Devices(and also only being tested on them).
Thanks in advance.