给定与已知坐标的 N 个点的距离,确定点在 3D 空间中的位置 [英] Determine the position of a point in 3D space given the distance to N points with known coordinates
问题描述
我正在尝试确定点 p 的 (x,y,z) 坐标.我所拥有的是与已知坐标的 4 个不同点 m1、m2、m3、m4 的距离.
I am trying to determine the (x,y,z) coordinates of a point p. What I have are the distances to 4 different points m1, m2, m3, m4 with known coordinates.
详细说明:我所拥有的是4个点(m1,m2,m3,m4)的坐标,它们不在同一个平面上:
In detail: what I have is the coordinates of 4 points (m1,m2,m3,m4) and they are not in the same plane:
m1: (x1,y1,z1),
m2: (x2,y2,z2),
m3: (x3,y3,z3),
m4: (x4,y4,z4)
欧几里得距离形成m1->p, m2->p, m3->p 和m4->p 分别是
and the Euclidean distances form m1->p, m2->p, m3->p and m4->p which are
D1 = sqrt( (x-x1)^2 + (y-y1)^2 + (z-z1)^2);
D2 = sqrt( (x-x2)^2 + (y-y2)^2 + (z-z2)^2);
D3 = sqrt( (x-x3)^2 + (y-y3)^2 + (z-z3)^2);
D4 = sqrt( (x-x4)^2 + (y-y4)^2 + (z-z4)^2);
我正在寻找 (x,y,z).我试图用matlab fsolve通过欧几里得距离来解决这个由4个方程和3个未知数组成的非线性系统,但没有成功.
I am looking for (x,y,z). I tried to solve this non-linear system of 4 equations and 3 unknowns with matlab fsolve by taking the euclidean distances but didn't manage.
有两个问题:
- 如何找到点 p 的未知坐标:(x,y,z)
- 已知坐标的最小点数是多少?为了找到 (x,y,z),我需要到 p 的距离?
这是一段没有给出解决方案的代码:
Here is a piece of code that gives no solutions:
假设我的观点是:
m1 = [ 370; 1810; 863];
m2 = [1586; 185; 1580];
m3 = [1284; 1948; 348];
m4 = [1732; 1674; 1974];
x = cat(2,m1,m2,m3,m4)';
每个点到p的距离为
d = [1387.5; 1532.5; 1104.7; 0855.6]
据我了解,如果我想运行 fsolve,我必须使用以下内容:1.创建函数2.调用fsolve
From what I understood if I want to run fsolve I have to use the following: 1. Create a function 2. Call fsolve
function F = calculateED(p)
m1 = [ 370; 1810; 863];
m2 = [1586; 185; 1580];
m3 = [1284; 1948; 348];
m4 = [1732; 1674; 1974];
x = cat(2,m1,m2,m3,m4)';
d = [1387.5; 1532.5; 1104.7; 0855.6]
F = [d(1,1)^2 - (p(1)-x(1,1))^2 - (p(2)-x(1,2))^2 - (p(3)-x(1,3))^2;
d(2,1)^2 - (p(1)-x(2,1))^2 - (p(2)-x(2,2))^2 - (p(3)-x(2,3))^2;
d(3,1)^2 - (p(1)-x(3,1))^2 - (p(2)-x(3,2))^2 - (p(3)-x(3,3))^2;
d(4,1)^2 - (p(1)-x(4,1))^2 - (p(2)-x(4,2))^2 - (p(3)-x(4,3))^2;];
然后调用 fsolve:
and then call fsolve:
p0 = [1500,1500,1189]; % initial guess
options = optimset('Algorithm',{'levenberg-marquardt',.001},'Display','iter','TolX',1e-1);
[p,Fval,exitflag] = fsolve(@calculateED,p0,options);
我正在运行 Matlab 2011b.
I am running Matlab 2011b.
我错过了什么吗?
最小二乘解是怎样的?
这里需要注意的是,m1、m2、m3、m4 和 d 值可能无法准确给出,但对于不应该成为问题的分析解决方案.
One note here is that m1, m2, m3, m4 and d values may not be given accurately but for an analytical solution that shouldn't be a problem.
推荐答案
mathematica 轻松数值求解三点问题:
mathematica readily numericall solves the three point problem:
p = Table[ RandomReal[{-1, 1}, {3}], {3}]
r = RandomReal[{1, 2}, {3}]
Reduce[Simplify[ Table[Norm[{x, y, z} - p[[i]]] == r[[i]] , {i, 3}],
Assumptions -> {Element[x | y | z, Reals]}], {x, y, z}, Reals]
这通常会返回 false
,因为随机球体通常不会有三重交点.
This will typically return false
as random spheres will typically not have triple intersection points.
当您有解决方案时,您通常会有这样的一对..
When you have a solution you'll typically have a pair like this..
(* (x == -0.218969 && y == -0.760452 && z == -0.136958) ||
(x == 0.725312 && y == 0.466006 && z == -0.290347) *)
这有点令人惊讶地有一个失败的优雅的分析解决方案.它有点涉及,所以我会等着看是否有人能方便地使用它,如果没有并且有兴趣我会尝试记住这些步骤..
This somewhat surprisingly has a failrly elegent analytic solution. Its a bit involved so I'll wait to see if someone has it handy and if not and there is interest I'll try to remember the steps..
编辑,遵循 Dmitys 最小二乘建议的近似解:
Edit, approximate solution following Dmitys least squares suggestion:
p = {{370, 1810, 863}, {1586, 185, 1580}, {1284, 1948, 348}, {1732,
1674, 1974}};
r = {1387.5, 1532.5, 1104.7, 0855.6};
solution = {x, y, z} /.
Last@FindMinimum[
Sum[(Norm[{x, y, z} - p[[i]]] - r[[i]] )^2, {i, 1, 4}] , {x, y, z}]
Table[ Norm[ solution - p[[i]]], {i, 4}]
如你所见,你离准确还很远.
As you see you are pretty far from exact..
(* solution point {1761.3, 1624.18, 1178.65} *)
(* solution radii: {1438.71, 1504.34, 1011.26, 797.446} *)
这篇关于给定与已知坐标的 N 个点的距离,确定点在 3D 空间中的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!