- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想找到从固定位置到由两个 GPS 位置连接的线的最近位置。我试图用图表的方式来说明它。所有位置均采用 GPS 坐标。我想找到从位置 P 到位置 A 和位置 B 连接的线的最短距离,即,从 P 开始的线与连接 A 和 B 的线成 90 度。如果您知道现有的实现或算法,那就太好了。非常感谢。
我被告知计算的方式是:首先将 GPS 位置转换为笛卡尔坐标。对于转换,它使用引用位置(Q_Ref_longitude、Q_Ref_latitude)。
x=(longitude-reflong)*π/180*r_e, r_e radius of earth
y=artanh(sin(latitude))
Therefore the reference point has the Cartesian coordinates (0,artanh(sin(reflat))).
conv(refp)=(0,artanh(sin(reflat)))
All positions A,B, P are converted to (x,y) coordinate system
Calculation of the intercept point with reference Cartesian coordinates (x,y)∈R^2:
In the following context (vp) ⃗∈R^2 is the position vector of the P in reference Cartesian coordinates.
<a ⃗,b ⃗> is the dot product of two vectors a ⃗ and b ⃗.
(op2) ⃗ refers to position A
(op1) ⃗ refers to position B
(vp) ⃗ refers to position P
(op1) ⃗,(op2) ⃗,(vp) ⃗∈R^2
intPoint=[(<((op2)-(op1)),((vp)-(op1))>)/(<((op2)-(op1)),((op2)-(op1))>)]*((op2)-(op1))+(op1)
The intercept point has to be transformed back into GPS coordinates with the following inverse formula:
Iconv:R^2→[-180°,180°]×[-90°,90]
longitude=x+reflong
latitude=arcsin(tanh(y))
有人知道这个方法吗?我尝试这样做,但它给出了负值。
最佳答案
鉴于距离如此短,如果您不靠近极点,则可以使用基于规则平面几何的廉价近似值。
您要做的第一件事是更改坐标系:将经度乘以纬度的余弦,以考虑到两极附近的经度较短的事实。否则计算投影时将无法得到 90° 角。
之后,像平常一样计算点 P 在直线 AB 上的投影。
完成后,将经度除以纬度以撤消之前所做的坐标更改。
这是基本算法:
// input:
double Alat, Alng, Blat, Blng, Plat, Plng;
// output:
double Xlat, Xlng;
// change of coordinate system
Alng *= cos(Alat * PI/180);
Blng *= cos(Blat * PI/180);
Plng *= cos(Plat * PI/180);
// compute projection
double scale = ((Blng-Alng)*(Plng-Alng)+(Blat-Alat)*(Plat-Alat)) /
((Blng-Alng)*(Blng-Alng)+(Blat-Alat)*(Blat-Alat));
Xlat = (1-scale)*Alat + scale*Blat;
Xlng = (1-scale)*Alng + scale*Blng;
// change to original coordinate system
Xlng /= cos(Xlat * PI/180);
return (Xlat, Xlng)
您可以通过仅计算其中一个纬度的余弦来使其更便宜;没有什么大的区别。
如果您靠近杆子或出于某种原因需要更准确的结果,则必须使用更复杂的算法。
关于java - 查找从固定位置到两个 GPS 位置连接线的最近位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19046774/
我有如下所示的文本文件: 1. SometextSometextSometextSometextSometext 2. SometextSometextSometextSometextSometext
这一章实现的连接线,目前仅支持直线连接,为了能够不影响原有的其它功能,尝试了2、3个实现思路,最终实测这个实现方式目前来说最为合适了。 请大家动动小手,给我一个免费的 Star 吧~ 大家
假设我的流是 x*N 行长,其中 x 是记录数,N 是每条记录的列数,并且按列输出。例如,x=2,N=3: 1 2 Alice Bob London New York 我如何加入每一行,以记录数为模,
如何在下面的 jsfiddle 中用虚线连接数字。 我希望这些线从内圈的边界开始,无论是来自 jQuery 还是来自 css。我的意思是围绕内圈的边界从内边界边缘开始到数字 ....... 1, ..
我正在使用 C#,但将来我可能需要在其他语言上使用它。 很多游戏都有这样的谜题。有一组电线(有两种类型的电线:直的和弯的。),有一个地方是信号进来的地方,还有一个地方是信号必须离开的地方。但是电线的布
本章响应小伙伴的反馈,除了算法自动画连接线(仍需优化完善),实现了可以手动绘制直线、折线连接线功能。 请大家动动小手,给我一个免费的 Star 吧~ 大家如果发现了 Bug,欢迎来提 Is
使用新版本的 Java 物质外观,不绘制典型 JTree 中的连接线(父子线)。 在 java.net 的官方论坛上有人问 same thing开发人员对此的回答是,这是基于较新的 UI 的选择,并且
我正在使用 matplotlib 绘制一些数据,这些数据需要一段时间,因此我必须使用 plot_date 来绘制我的线条。但出于某种原因,就连接线而言,Plot_Date 和 Plot 具有完全不同的
我是一名优秀的程序员,十分优秀!