当前位置:网站首页>已经两点经纬度,计算两点之间距离
已经两点经纬度,计算两点之间距离
2022-07-22 11:03:00 【panfei263031】
距离计算有两种公式,Vincenty和Haversine,前者经度很高,可以达到0.5毫米,但是速度慢;后者速度快,但是经度差点,但是也不含糊,实际中很常用,只要是精度要求不是特别高的例如航空、导弹等的领域,还是很实用的。例如在只能网联汽车领域,后者应用很广泛。
原文见:
计算球面两点间距离实现Vincenty+Haversine
这里将上述链接中Vincenty公式的源码copy过来:
double toRadians(double a)
{
return a*(PI/180)
}
//return the distance of two point, unit is meter
double distance_2(double latitude1, double longitude1, double latitude2, double longitude2) {
// R is the radius of the earth in meters
double R = 6371004; //EARTH_RADIUS
double deltaLatitude = toRadians(latitude2-latitude1);
double deltaLongitude = toRadians(longitude2-longitude1);
latitude1 =toRadians(latitude1);
latitude2 =toRadians(latitude2);
double a = pow(sin(deltaLatitude/2), 2)+ cos(latitude1)* cos(latitude2)* pow(sin(deltaLongitude/2), 2);
double c = 2 * atan2(sqrt(a),sqrt(1-a));
double d = R * c;
return d;
}
更详细的讲解见:根据两点的经纬度求方位角和距离
这里有详细的公式噢~
文章中的提到的球面正弦定律,没有详细展开,这里补充下:
球面三角正弦定理
边栏推荐
- Juc-7.1 thread collaboration semaphore
- 校园英语调频台在江西陶瓷工艺美术职业技术学院的应用
- Notes d'apprentissage du système intégré
- Bash basic functions alias and shortcut keys
- Bash variables - numeric operations and operators
- 嵌入式系统学习笔记
- Simple sentences -one
- Buctf passing Diary - - [Netting Cup 2020 Qinglong Group] areuserialz
- 校园IPTV数字电视教学直播系统在淮安生态文旅区实验小学的应用
- [LTTng学习之旅]------在用户程序中简单的添加一个trace点
猜你喜欢
Chapter 8: custom exception return
YOLO9000: Better, Faster, Stronger
Significance learning record of FFT in MATLAB
[lttng learning journey] - a preliminary study of trace view
大喇叭疫情防控广播解决方案
Chapter 6: EASYCODE code generator
JUC-6.3-并发容器-队列
Buuctf breakthrough diary -- [geek challenge 2019] hardsql1
四六级英语听力发射无线广播系统在广东海洋大学阳江校区的应用
Network Accounting - layered structure, OSI communication process, tcp/ip model and 5-layer reference model
随机推荐
Process control
JVM principle and performance tuning
Juc-7.1 thread collaboration semaphore
RPM package management - Yum online management - IP address configuration and network Yum source
Character interception command
小区IP网络广播背景系统解决方案-基于局域网、专网或广域网传输
Buuctf entry diary 01 -- easysql
Bash basic functions alias and shortcut keys
5. Network and security
5.网络和安全
1. Virtualization and container technology
Significance learning record of FFT in MATLAB
Using openresty as the gateway to authenticate and access static resources
Pytorch custom data set loading (label in CSV file)
Chapter 1: Minio introduction and installation
[lttng practice] - design a set of things to monitor the execution time and cycle of user programs running in a certain cycle -- demand analysis and scheme design
Juc-6.3-concurrency container queue
Bash variable -- position parameter variable
New cover of time: metauniverse will change everything
Buuctf entry diary -- [mrctf2020] how about you (super detailed)