简体   繁体   English

确定对象是否远离某个点而朝着某个点移动

[英]Determining if an object is moving away from a point versus towards it

I am trying to practice my skills with using latitude and longitude and I'm attempting to determine the following: given a center point X on a map and a point around it called Y, how do I tell whether or not the points around the center are moving away from the center object or towards it using latitude and longitude? 我正在尝试使用经度和纬度来练习我的技能,并且尝试确定以下各项:给定地图上的中心点X和围绕它的点Y,如何判断中心点是否是使用纬度和经度远离中心对象还是朝着它移动?

Right now I have the center latitude and longitude and am focusing on one of the points around it. 现在,我有了中心纬度和经度,并专注于围绕它的一点。 I have used the Haversine method to calculate distance in miles between two lats and longs. 我使用Haversine方法来计算两个纬度和经度之间的距离(以英里为单位)。 Using this I measured the initial distance the from X to Y and assigned it to a variable. 使用这个,我测量了从X到Y的初始距离,并将其分配给变量。 Upon Y's first move I recalculated the overall distance from X to Y and compared it with the initial. 在Y的第一个举动之后,我重新计算了X到Y的总距离,并将其与初始距离进行了比较。 If the new measurement is greater than the old then your distance from the point X is increasing, if not it's decreasing. 如果新的测量结果大于旧的测量结果,则您到X点的距离在增加,如果没有,则在减少。 Also, I have check to make sure what I'm working with the point Y is ACTUALLY moving some distance with each move, not just going around the radius of point X in some weird fashion. 另外,我还要检查以确保我在Y点上所做的工作实际上每次移动一定距离,而不是以某种怪异的方式绕着X点的半径移动。

Is the way I'm doing things sound alright? 我的处事方式听起来不错吗? I keep feeling like I need to fine tune something but I just can't put my finger on it. 我一直觉得我需要微调一些东西,但我只是不能将手指放在上面。

Hopefully everything I'm saying makes sense and is not falling on deaf ears and this doesn't get flagged as an non-constructive question. 希望我所说的一切都是有道理的,不会让您耳聋,并且这不会被标记为非建设性的问题。 It definitely is. 肯定是。

Yes, this is the correct way, I have done this some years ago: 是的,这是正确的方法,我几年前就这样做过:
In praxis you get the coordinates from a GPS device. 在实践中,您可以从GPS设备获取坐标。 Therfore you may consider additional filtering, eg ignore situtions where the device stands still. 因此,您可以考虑进行其他过滤,例如,忽略设备静止不动的情况。 Because this may introduce positional jumps. 因为这可能导致位置跳跃。 In your question I saw that you already use a filtering by distance moved: this is suitable! 在您的问题中,我看到您已经使用了按移动距离进行的过滤:这很合适!

You can use the haversine formula, like you propose. 您可以像建议的那样使用Haversine公式。 For high load situations, there are faster distance formulas, for your task (small distances), which do not need so much trigonometric calls, but this is a minor topic. 对于高负载情况,对于您的任务(较小的距离),有更快的距离公式,不需要太多的三角函数调用,但这只是一个小问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM