点与路径之间的最短距离 [英] Shortest distance between point and path

查看:222
本文介绍了点与路径之间的最短距离的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于基于地理的在线游戏,我正在寻找一种算法,该算法可以找到指定点与通过x/y坐标连接的已知路径之间的最短距离,以便杀死所有多余的点/节点.该算法的链接或关键字对我有很大帮助!感谢阅读

for a geo-based online game I'm looking for an algorithm which finds the shortest distance between a specified point and a known path connected by x/y-coordinates, so that I can kill all redundant points/nodes. A link or keyword for this algorithm would help me a lot! thanks for reading

为了更好地理解:

推荐答案

您是否要计算此值,以便说出类似如果点到路径的距离为零,则删除该点"?如果是这样,则可能有一种更简便的方法来删除冗余节点.一次获取三个点(分别称为ABC).计算AB之间的角度以及BC之间的角度.如果两个角度相同,则点B位于AC之间的路径中,并且是多余的.您可以使用"atan2"功能(或您所用语言的等效功能)进行角度计算.

Are you wanting to calculate this in order to say something like "if the point-to-path distance is zero, then remove the point"? If so, then there is probably an easier way to remove redundant nodes. Take the points three at a time (call them A, B, and C). Calculate the angle between A and B, as well as the angle between B and C. If the two angles are the same, then point B lies in the path between A and C and is redundant. You can use the 'atan2' function (or your language's equivalent) to do the angle calculations.

这篇关于点与路径之间的最短距离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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