开发者

compute true north based on successive user location

开发者 https://www.devze.com 2023-01-05 06:58 出处:网络
I\'m working on an app that should include a compass (it should work on iphone 3G also). however as there is no a compass on iphone 3G i\'m looking for a way to know the true north orientation based o

I'm working on an app that should include a compass (it should work on iphone 3G also). however as there is no a compass on iphone 3G i'm looking for a way to know the true north orientation based on the CLLocation returned by the iPhone.

Note: the app should give as 开发者_如何学运维accurate as possible value even if the phone is using "cell towers" to know the actual position (not very accurate).

thanks in advance.


You can approximate the users heading assuming they have been moving in a straight line between gps updates.

I would first set the desired accuracy to the highest. You will need it since a small change in position will result in a large change in angle.

Now call the coordinate of the first location L1, and the coordinate of the next location L2.

Your heading vector , h = L2 - L1

now if h = (lon, lat)

To get the heading you need use some trig:

x = arctan ( lon / lat )

I would consider taking averages / smoothing the result somehow.

0

精彩评论

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

关注公众号