C# - 查找坐标以将线延长一定的公里数
我需要计算将现有线延伸一定公里的点的坐标。
给定输入: (1) 现有线的起点和终点坐标(以度为单位)。 (2) 新线应延伸超过上面给出的“结束”坐标的长度(公里)。
输出: 延伸线的点的纬度和经度(以度为单位)
我目前有一种方法可以计算两组坐标之间的方位(如果有帮助的话)。我还有一种方法可以找到一条线上的点,但它是两组给定坐标之间的点,而不是延伸现有的线。我似乎不知道如何根据我的需要改变它。
另外,我使用的是 WGS-84,所以(根据我的理解)不需要考虑地球的曲率。
任何帮助将不胜感激,谢谢!
编辑:
嗯,我看到的问题是距离以公里为单位,而坐标为 GPS 度数。但我最终使用向量来解决它:
C = B - k(A - B),其中 k = 放置 C 的距离的比例
注意:在我的例子中 k=1.5,因为我希望新点是原始线外距离的一半。 0 位于 A 点,1 位于 BI 点。
我已经在谷歌地球上绘制了它,它似乎有效。
I need to calculate the coordinates of a point that extends an existing line by a certain amount of kilometers.
Given Input:
(1) beginning and ending coordinates of an existing line (in degrees).
(2) length (km) of how far the new line should extend past the "ending" coordinate given above.
Output:
Latitude and longitude (in degrees) of point that extends the line
I currently have a method that calculates the bearing between 2 sets of coordinates if that helps. I also have a method that finds a point on a line, but it's a point between the 2 sets of given coordinates, not extending the existing line. I cannot seem to figure out how to alter that for my needs.
Also, I'm using WGS-84, so (from my understanding) the curvature of the earth does not need to be taken into account.
Any help would be appreciated, thank you!
Edit:
Well the problem I saw was that the distance was in kilometers while the coordinates were GPS degrees. But I just ended up using vectors to solve it:
C = B - k(A - B), where k = proportion of distance to place C
Note: k=1.5 in my case because I wanted the new point to be one half the distance outside of the original line. 0 would be at point A and 1 at point B I believe.
I've plotted it in Google Earth and it seems to work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您想研究直线方程。通过幅度和起点,您可以轻松计算给定长度的终点。
Y = mx + b
这是一个快速教程:
http://www.mathsisfun.com/equation_of_line.html< /a>
你也可以用谷歌搜索共线点,这实际上就是你正在寻找的。
You want to look into the equation of a straight line. With the magnitude and start point you can easily calculate the end point for a given length.
Y = mx + b
Here is a quick tutorial:
http://www.mathsisfun.com/equation_of_line.html
You could also google for collinear points which is actually what you are looking for.
确实需要考虑地球的曲率。您还需要决定是否使用更大的圆(最短距离)或恒向线。如果是前者,则需要计算端轴承,然后从该轴承延伸。以下链接包含您需要的公式。
http://www.movable-type.co.uk/scripts/latlong.html
The Earth's curvature does need to be taken into account. You also need to decide whether you are working with greater circles (shortest distance) or rhumb lines. If it is the former then you need to calculate the end bearing and then extend from this bearing. The following link contains the formulas you need.
http://www.movable-type.co.uk/scripts/latlong.html