1

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

这篇文章中, Don Reba的回答非常适合二维。但是如何将其扩展到 3-D?

这是我的二维代码:

    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)
4

2 回答 2

2

维基百科三边测量文章描述了答案。计算步骤为:

  1. e x = (P2 - P1) / ‖P2 - P1‖</li>
  2. i = e x (P3 - P1)
  3. e y = (P3 - P1 - i · e x ) / ‖P3 - P1 - i · e x ‖</li>
  4. d = ‖P2 - P1‖</li>
  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 )
于 2014-05-02T05:01:04.013 回答
0

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

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

可以求解三个方程组并使用第四个来选择合适的解(从两个中)。

这就是 GPS 的工作方式(时间延迟是距离)。

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

于 2014-05-01T03:18:59.480 回答