Geometry 垂直线(横向/纵向)

Geometry 垂直线(横向/纵向),geometry,2d,Geometry,2d,我试图实现所提出的关于在给定的垂直距离上找到一个点的方程。不幸的是,我收到的线不是直的。这是因为我将纵横坐标与常规x/y坐标混合,还是我做错了什么 double distPoint = 0.02; double latDiff = temp2.Latitude - temp.Latitude; double longDiff = temp2.Longitude - temp.Longitude; double length = Math.Sqrt(latDiff * latDiff

我试图实现所提出的关于在给定的垂直距离上找到一个点的方程。不幸的是,我收到的线不是直的。这是因为我将纵横坐标与常规x/y坐标混合,还是我做错了什么

 double distPoint = 0.02;

 double latDiff = temp2.Latitude - temp.Latitude;  
 double longDiff = temp2.Longitude - temp.Longitude;
 double length = Math.Sqrt(latDiff * latDiff + longDiff * longDiff); 
 double uLat = latDiff / length; 
 double uLong = longDiff / length;

 double newLat1 = temp2.Latitude + (distPoint / 2) * uLat;  
 double newLong1 = temp2.Longitude - (distPoint / 2) * uLong;

 double newLat2 = temp2.Latitude -  (distPoint / 2) * uLat;  
 double newLong2 = temp2.Longitude + (distPoint / 2) * uLong;
现在已经更改了代码和变量名。仍在接收故障:-(

 double distPoint = 0.02;

 double latDiff = temp2.Latitude - temp.Latitude;  
 double longDiff = temp2.Longitude - temp.Longitude;
 double length = Math.Sqrt(latDiff * latDiff + longDiff * longDiff); 
 double uLat = latDiff / length; 
 double uLong = longDiff / length;

 double newLat1 = temp2.Latitude + (distPoint / 2) * uLat;  
 double newLong1 = temp2.Longitude - (distPoint / 2) * uLong;

 double newLat2 = temp2.Latitude -  (distPoint / 2) * uLat;  
 double newLong2 = temp2.Longitude + (distPoint / 2) * uLong;
以下是变量值:

 double distPoint = 0.02;

 double latDiff = temp2.Latitude - temp.Latitude;  
 double longDiff = temp2.Longitude - temp.Longitude;
 double length = Math.Sqrt(latDiff * latDiff + longDiff * longDiff); 
 double uLat = latDiff / length; 
 double uLong = longDiff / length;

 double newLat1 = temp2.Latitude + (distPoint / 2) * uLat;  
 double newLong1 = temp2.Longitude - (distPoint / 2) * uLong;

 double newLat2 = temp2.Latitude -  (distPoint / 2) * uLat;  
 double newLong2 = temp2.Longitude + (distPoint / 2) * uLong;
latDiff = -0.0046187639236450195
longDiff = -0.0058203935623168945

length = 0.0074303405980227239
uLat = -0.62160864131505777
uLong = -0.78332796263279647

newLat1 = 58.39273776863341
newLong1 = 15.558675147558933

newLat2 = 58.408404327886061
newLong2 = 15.546242974732632

更新:我得出的结论是,该故障是由于lat/long问题造成的。认为lat/long等同于正方形,而事实上并非如此,这似乎是合理的。尤其是在北欧工作时。

在您链接的公式中,最后4行有一个乘法序列作为:

 double distPoint = 0.02;

 double latDiff = temp2.Latitude - temp.Latitude;  
 double longDiff = temp2.Longitude - temp.Longitude;
 double length = Math.Sqrt(latDiff * latDiff + longDiff * longDiff); 
 double uLat = latDiff / length; 
 double uLong = longDiff / length;

 double newLat1 = temp2.Latitude + (distPoint / 2) * uLat;  
 double newLong1 = temp2.Longitude - (distPoint / 2) * uLong;

 double newLat2 = temp2.Latitude -  (distPoint / 2) * uLat;  
 double newLong2 = temp2.Longitude + (distPoint / 2) * uLong;
[dy,dx,dy,dx]
=
[uLong,uLat,uLong,uLat]

 double distPoint = 0.02;

 double latDiff = temp2.Latitude - temp.Latitude;  
 double longDiff = temp2.Longitude - temp.Longitude;
 double length = Math.Sqrt(latDiff * latDiff + longDiff * longDiff); 
 double uLat = latDiff / length; 
 double uLong = longDiff / length;

 double newLat1 = temp2.Latitude + (distPoint / 2) * uLat;  
 double newLong1 = temp2.Longitude - (distPoint / 2) * uLong;

 double newLat2 = temp2.Latitude -  (distPoint / 2) * uLat;  
 double newLong2 = temp2.Longitude + (distPoint / 2) * uLong;
无论您如何使用:

 double distPoint = 0.02;

 double latDiff = temp2.Latitude - temp.Latitude;  
 double longDiff = temp2.Longitude - temp.Longitude;
 double length = Math.Sqrt(latDiff * latDiff + longDiff * longDiff); 
 double uLat = latDiff / length; 
 double uLong = longDiff / length;

 double newLat1 = temp2.Latitude + (distPoint / 2) * uLat;  
 double newLong1 = temp2.Longitude - (distPoint / 2) * uLong;

 double newLat2 = temp2.Latitude -  (distPoint / 2) * uLat;  
 double newLong2 = temp2.Longitude + (distPoint / 2) * uLong;
[dx,dy,dx,dy]
=
[uLat,uLong,uLat,uLong]

 double distPoint = 0.02;

 double latDiff = temp2.Latitude - temp.Latitude;  
 double longDiff = temp2.Longitude - temp.Longitude;
 double length = Math.Sqrt(latDiff * latDiff + longDiff * longDiff); 
 double uLat = latDiff / length; 
 double uLong = longDiff / length;

 double newLat1 = temp2.Latitude + (distPoint / 2) * uLat;  
 double newLong1 = temp2.Longitude - (distPoint / 2) * uLong;

 double newLat2 = temp2.Latitude -  (distPoint / 2) * uLat;  
 double newLong2 = temp2.Longitude + (distPoint / 2) * uLong;
最后4行应该是:

 double distPoint = 0.02;

 double latDiff = temp2.Latitude - temp.Latitude;  
 double longDiff = temp2.Longitude - temp.Longitude;
 double length = Math.Sqrt(latDiff * latDiff + longDiff * longDiff); 
 double uLat = latDiff / length; 
 double uLong = longDiff / length;

 double newLat1 = temp2.Latitude + (distPoint / 2) * uLat;  
 double newLong1 = temp2.Longitude - (distPoint / 2) * uLong;

 double newLat2 = temp2.Latitude -  (distPoint / 2) * uLat;  
 double newLong2 = temp2.Longitude + (distPoint / 2) * uLong;
double newLat1 = temp2.Latitude + (distPoint / 2) * uLong;   //dy appears first
double newLong1 = temp2.Longitude - (distPoint / 2) * uLat;  //then dx

double newLat2 = temp2.Latitude -  (distPoint / 2) * uLong;  
double newLong2 = temp2.Longitude + (distPoint / 2) * uLat;

在如此小的范围内,x/y和lat/long之间的差异是不相关的。您还做了其他错误;您应该做的是:

 double distPoint = 0.02;

 double latDiff = temp2.Latitude - temp.Latitude;  
 double longDiff = temp2.Longitude - temp.Longitude;
 double length = Math.Sqrt(latDiff * latDiff + longDiff * longDiff); 
 double uLat = latDiff / length; 
 double uLong = longDiff / length;

 double newLat1 = temp2.Latitude + (distPoint / 2) * uLat;  
 double newLong1 = temp2.Longitude - (distPoint / 2) * uLong;

 double newLat2 = temp2.Latitude -  (distPoint / 2) * uLat;  
 double newLong2 = temp2.Longitude + (distPoint / 2) * uLong;
 double distPoint = 0.02;

 double latDiff = temp2.Latitude - temp.Latitude;
 double longDiff = temp2.Longitude - temp.Longitude;
 double length = Math.Sqrt(latDiff * latDiff + > longDiff * longDiff); 
 double uLat = latDiff / length; 
 double uLong = longDiff / length;

 double newLat1 = temp2.Latitude + (distPoint / 2) * uLong;
 double newLong1 = temp2.Longitude - (distPoint / 2) * uLat;

 double newLat2 = temp2.Latitude - (distPoint / 2) * uLong;
 double newLong2 = temp2.Longitude + (distPoint / 2) * uLat;

也就是说,向量
(uLat,uLong)
是直线方向上的单位向量,因此垂直单位向量是
(uLong,-uLat)
-注意坐标交换的位置,除了一个被否定的位置。

这里的图像:较长的线应该是垂直的。对于我们这些视觉类型的人-谢谢你的图像!在这一点上,我认为图像可以通过注释哪些点(或它们的x-y值)变得更有用来自伪代码中的值,因为我不确定是否来自变量名。我认为您的问题不完整-或者结果未定义。您似乎在球面极坐标中指定了两个位置(但问题是2D,而不是3D?)。您似乎希望确定一个点的极坐标,该点与连接两个点的直线之间的距离为给定的距离。您没有指定球体的半径(这一点很重要,因为距离是给定的)。而且,通常有许多点(两条线的值)这是给定的直线距离。因此,您需要提供更多的解决方案条件。@svanerik:在您对Daniel Martin和LFSR Consulting的评论中,您提到他们的解决方案仍然不起作用。它怎么不起作用?您可以发布另一张图片吗?尽管CptSkippy的数字不正确,但我相信原则仍然有效相关:也就是说,我认为你必须考虑你的纬度(甚至比他的英国汉普郡的例子还要高)。请注意,此比率并非在所有位置都准确。事实上,纬度和经度之间的表面距离比率取决于您离赤道的距离,因此您的数字是错误的,除非询问者的地图位于同一纬度。这甚至在链接页面中有解释。我非常想因此而投反对票,但这是一个错误NSWER确实有一定的价值,因为它是ASK可能要考虑的东西。1度经度在赤道上大约69.13英里,在极点上有0。这不是一个简单的比率。如果你在汉普郡,在英国,或者在其他纬度相当的地方,这个等式是正确的。大多数人都不是。我的位置是在Sout。瑞典的h。嗨,这似乎是有道理的。我尝试过实施它,但没有效果。数字真的很小,这是原因吗?我在上面公布了数字。“最终结果”你的答案基本上等同于LFSR咨询公司的答案,但我更喜欢你的垂直矢量解释。这取决于你是想垂直于地球表面还是想垂直于坐标。记住,90度的纬度在赤道附近几千公里/英里,在两极附近几厘米/英寸。这使得直线的梯度更小如果你从局部墨卡托投影到1:1拉特长的投影。嗨,我试着实现了这个,但没有成功。我已经公布了问题中变量的值,这样你就可以看到它是否与此有关。谢谢!
 double distPoint = 0.02;

 double latDiff = temp2.Latitude - temp.Latitude;  
 double longDiff = temp2.Longitude - temp.Longitude;
 double length = Math.Sqrt(latDiff * latDiff + longDiff * longDiff); 
 double uLat = latDiff / length; 
 double uLong = longDiff / length;

 double newLat1 = temp2.Latitude + (distPoint / 2) * uLat;  
 double newLong1 = temp2.Longitude - (distPoint / 2) * uLong;

 double newLat2 = temp2.Latitude -  (distPoint / 2) * uLat;  
 double newLong2 = temp2.Longitude + (distPoint / 2) * uLong;