如何从x,y位置检查10米的半径 - 从GPS开始 [英] how to check radius of 10 meter from x,y position - from GPS

查看:111
本文介绍了如何从x,y位置检查10米的半径 - 从GPS开始的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从GPS获得这个位置:

40.715192,-74.005795

如何检查我是否在10米半径的范围?

提前致谢

解决方案

使用Haversine公式 http://en.wikipedia.org/wiki/Haversine_formula



伪代码:

  R = 6371; //校正的地球半径,km 
dLat = degToRad(lat2-lat1);
dLon = degToRad(lon2-lon1);
a = sin(dLat / 2)* sin(dLat / 2)+
cos(degToRad(lat1))* cos(degToRad(lat2))*
sin(dLon / 2)*罪(dLon / 2);
c = 2 * atan2(sqrt(a),sqrt(1-a));
distance = R * c;

degToRad 将degress转换为弧度, 此处


i have this position from GPS:

40.715192,-74.005795

how to check if i in the range of 10 meter radius ?

thank's in advance

解决方案

Use Haversine formula http://en.wikipedia.org/wiki/Haversine_formula

Pseudocode:

R = 6371; // corrected earth radius, km
dLat = degToRad(lat2-lat1);
dLon = degToRad(lon2-lon1); 
a = sin(dLat/2) * sin(dLat/2) +
        cos(degToRad(lat1)) * cos(degToRad(lat2)) * 
        sin(dLon/2) * sin(dLon/2); 
c = 2 * atan2(sqrt(a), sqrt(1-a)); 
distance = R * c;

degToRad converts degress to radians, see e.g. here

这篇关于如何从x,y位置检查10米的半径 - 从GPS开始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆