简体   繁体   中英

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] with bearing, pitch and roll in second parameter... How I can calculate real north from these values?

Thank you

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)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM