2D三边测量 [英] 2d trilateration
问题描述
我正在编写一些代码来参与AI挑战. AI挑战的主要目标是乘坐模拟机器人,并通过迷宫将其导航到目标区域.可选的第二个目标是找到一个放置在迷宫中未知位置的充电器.这些都是在2D网格中完成的.
I am writing some code to participate in an AI challenge. The main objective for the AI challenge is to take a simulated robot and navigate it through a maze to a destination zone. The secondary objective which is optional is to find a recharger placed in the maze at an unknown location. This is all done in a 2D grid.
我的程序可以调用一种方法来从充电器获取距离测量值.因此,使用三边测量法,我应该能够通过调用此方法来定位充电器,记录我的人工智能的当前位置以及充电器远离该点3倍的距离.
My program can call a method to get a distance measurement from the recharger. So using trilateration I should be able to locate the recharger by calling this method, recording my ai's current position and the distance the recharger is away from that point 3 times over.
我在维基百科 http://en.wikipedia.org/wiki/Trilateration ,但这适用于3d空间.我只处理2D空间.同样,我也不明白如何使用Wikipedia中显示的公式,在Google搜索中,在网络上搜索带有数字插入并逐渐减少到最终坐标的有效示例.
I found this example of trilateration on wikipedia http://en.wikipedia.org/wiki/Trilateration but this applies to a 3d space. I'm only dealing with a 2D space. Also I don't understand how to use the formula shown in Wikipedia, searching the web for a working example with numbers plugged in and boiling down to the final coordinates is scarce with Google searches.
我不是数学专业;我只是一个探索AI问题的狂热者.
I'm not a math major; I am just an enthusiast exploring AI problems.
我所需要的是如何计算问题的解释和分步示例,因为数学并不是我的强项.以下是一些示例数据:
An explanation and step by step example of how to calculate the problem is what I need as mathematics are not my strong point. Below is some sample data:
- 点1:x = 39,y = 28,距离= 8
- 点2:x = 13,y = 39,距离= 11
- 第3点:x = 16,y = 40,距离= 8
任何使用我的示例数据的示例将不胜感激.一旦我将脑袋绕到数学上,对此的编程将非常简单.
Any example using my sample data would be greatly appreciated. The programming to this will be very straight forward once I can wrap my head around the mathematics.
推荐答案
作为维基百科的三边形文章描述,您可以通过依次计算:e x ,i,e y ,d,j,x,y来计算(x,y)坐标.您必须熟悉向量符号,例如,e x =(P2-P1)/"P2-P1"的意思是:
As the Wikipedia trilateriation article describes, you compute (x,y) coordinates by successively calculating: ex, i, ey, d, j, x, y. You have to be familiar with vector notation, so, for example, ex = (P2 - P1) / ‖P2 - P1‖ means:
- e x,x =(P2 x -P1 x )/sqrt((P2 x - P1 x ) 2 +(P2 y -P1 y ) 2 )
- e x,y =(P2 y -P1 y )/sqrt((P2 x - P1 x ) 2 +(P2 y -P1 y ) 2 )
- ex,x = (P2x - P1x) / sqrt((P2x - P1x)2 + (P2y - P1y)2)
- ex,y = (P2y - P1y) / sqrt((P2x - P1x)2 + (P2y - P1y)2)
您的数据是:
-
P1 =(39,28); r 1 = 8
P1 =(13,39); r 2 = 11
P1 =(16,40); r 3 = 8
- P1 = (39, 28); r1 = 8
- P2 = (13, 39); r2 = 11
- P3 = (16, 40); r3 = 8
计算步骤为:
- e x =(P2-P1)/"P2-P1"
- i = e x (P3-P1)
- e y =(P3-P1-i·e x )/‖P3-P1-i·e x '
- d ="P2-P1"
- j = e y (P3-P1)
- x =(r 1 2 -r 2 2 + d 2 )/2天
- y =(r 1 2 -r 3 2 + i 2 + j 2 )/2j-ix/j
- ex = (P2 - P1) / ‖P2 - P1‖
- i = ex(P3 - P1)
- ey = (P3 - P1 - i · ex) / ‖P3 - P1 - i · ex‖
- d = ‖P2 - P1‖
- j = ey(P3 - P1)
- x = (r12 - r22 + d2) / 2d
- y = (r12 - r32 + i2 + j2) / 2j - ix / j
这篇关于2D三边测量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!