二维三边测量 [英] 2d trilateration

查看:34
本文介绍了二维三边测量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一些代码来参加 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.

我的程序可以调用一个方法来从充电器获取距离测量值.所以使用三边测量,我应该能够通过调用这个方法来定位充电器,记录我的 ai 当前位置以及充电器与该点的距离 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 空间.我只处理二维空间.此外,我不明白如何使用维基百科中显示的公式,在网络上搜索插入数字并归结到最终坐标的工作示例在 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.

推荐答案

作为维基百科三边形文章 描述,您通过连续计算来计算 (x,y) 坐标:ex, i, ey, d, j, x, y.您必须熟悉向量表示法,例如,ex = (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:

  • ex,x = (P2x - P1x)/sqrt((P2x -P1x)2 + (P2y - P1y)2)
  • ex,y = (P2y - P1y)/sqrt((P2x -P1x)2 + (P2y - P1y)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);r1 = 8
  • P2 = (13, 39);r2 = 11
  • P3 = (16, 40);r3 = 8
  • P1 = (39, 28); r1 = 8
  • P2 = (13, 39); r2 = 11
  • P3 = (16, 40); r3 = 8

计算步骤为:

  1. ex = (P2 - P1)/‖P2 - P1‖
  2. i = ex(P3 - P1)
  3. ey = (P3 - P1 - i · ex)/‖P3 - P1 - i · ex
  4. d = ‖P2 - P1‖
  5. j = ey(P3 - P1)
  6. x = (r12 - r22 + d2)/2d
  7. y = (r12 - r32 + i2 + j2)/2j - ix/j
  1. ex = (P2 - P1) / ‖P2 - P1‖
  2. i = ex(P3 - P1)
  3. ey = (P3 - P1 - i · ex) / ‖P3 - P1 - i · ex
  4. d = ‖P2 - P1‖
  5. j = ey(P3 - P1)
  6. x = (r12 - r22 + d2) / 2d
  7. y = (r12 - r32 + i2 + j2) / 2j - ix / j

这篇关于二维三边测量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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