开发者

How to get real north and magnetic north with getOrientation function

How to get real north and magnetic north with getOrientation function?

getOrientation function returns float[3]开发者_JAVA百科 with bearing, pitch and roll in second parameter... How I can calculate real north from these values?

Thank you


The first float in your array is what you want to use to figure magnetic north.

For "true" north, you need to use GeomagneticField.getDeclination(). You have to initialize that class with the approximate location (network-provided is sufficient).


I am not sure this is the right answer, but my guess is that you will only be able to get the magnetic north because that's what the compass will give you.

To "calculate" the true north, you will need your (or the phone's) location and then map that to find the right deviation. You could use some online tool or maybe based on maps you can try to have some simple formula to compute it... (can work if you target it to a specific area).

Couple of notes also...

  • It will not be too precise anyway, you will always have errors introduced by the variation which is caused by the environment of the compass.
  • The difference between true and magnetic north changes constantly... not very fast, but over a couple of years, you'll definitely have a difference (depends how accurate you want to be)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜