使用距离将点定位到3-D中的其他三个点

时间:2014-05-01 00:32:32

标签: math geometry trilateration

假设我们在3-D中有4个点(P1,P2,P3,P4)。 如果这些点的坐标以其欧几里德距离给出第五个点P5(r1,r2,r3,r4),那么如何计算P5的坐标?

this帖子中,Don Reba的回答非常适合2-D。但是我该如何将它扩展到3-D?

这是我的2D代码:

    static void localize(double[] P1, double[] P2, double[] P3, double r1, double r2, double r3)
    {
        double[] ex = normalize(difference(P2, P1));
        double i = dotProduct(ex, difference(P3, P1));
        double[] ey = normalize(difference(difference(P3, P1), scalarProduct(i, ex)));
        double d = magnitude(difference(P2, P1));
        double j = dotProduct(ey, difference(P3, P1));
        double x = ((r1*r1) - (r2*r2) + (d*d)) / (2*d);
        double y = (((r1*r1) - (r3*r3) + (i*i) + (j*j)) / (2*j)) - ((i*x) / j);
        System.out.println(x + " " + y);

    }

我想用签名

重载函数
static void localize(double[] P1, double[] P2, double[] P3, double[] P4, double r1, double r2, double r3, double r4)

2 个答案:

答案 0 :(得分:2)

Wikipedia trilateriation article描述了答案。计算步骤如下:

  1. e x =(P2 - P1)/‖P2 - P1‖
  2. i = e x (P3 - P1)
  3. e y =(P3 - P1 - i·e x )/‖P3 - P1 - i·e x
  4. d =‖P2 - P1‖
  5. j = e y (P3 - P1)
  6. x =(r 1 2 - r 2 2 + d 2 )/ 2d
  7. y =(r 1 2 - r 3 2 + i 2 + j 2 )/ 2j - ix / j
  8. z =±sqrt(r 1 2 - x 2 - y 2

答案 1 :(得分:0)

你需要求解四个方程的系统(i = 1..4,Di是到第i个点的距离)

(X-Xi)^2+(Y-Yi)^2+(Z-Zi)^2=Di^2

可以解决三个方程的系统,并使用第四个来选择适当的解(从两个)。

这就是GPS的工作原理(时间延迟适用于距离)。

在GPS接收机中经常使用优化方法,特别是当许多卫星可用且代数解决方案可能不稳定时。