最接近3D中的四行的点

Pra*_*gta 5 algorithm math geometry computational-geometry

给定3D中的4条线(表示为几个点),我想找到空间中的点,该点最小化该点与每条线之间的距离之和.

我试图找到一种方法将其表述为最小二乘问题,但我不太确定我应该如何做.我目前正在尝试使用以下网址提供的距离定义:http://mathworld.wolfram.com/Point-LineDistance3-Dimensional.html

有任何想法吗?

Dr.*_*ius 1

我在 Mathematica 中编写了一个程序来计算点坐标。结果是一个大的代数公式。我上传给ideone你了。

如果您手头有 Mathematica,这里是程序:

(*Load package*)
Needs["VectorAnalysis`"]
(*Define four lines, by specifying 2 points in each one*)
Table[p[i, j] = {x[i, j], y[i, j], z[i, j]}, {i, 4}, {j, 2}];

(*Define the target point*)
p0 = {x0, y0, z0};

(*Define a Norm function // using Std norm squared here*)
norm[a_] := a[[1]]^2 + a[[2]]^2 + a[[3]]^2

(*Define a function for the distance from line i to point v
used http://mathworld.wolfram.com/Point-LineDistance3-Dimensional.html (11) *)
d[i_, v_] :=  norm[Cross[(v - p[i, 1]), (v - p[i, 2])]]/norm[p[i, 2] - p[i, 1]]

(*Define a function for the sum of distances*)
dt[p_] := Sum[d[i, p], {i, 4}]

(*Now take the gradient, and Solve for Gradient == 0*)
s = Solve[Grad[dt[p0], Cartesian[x0, y0, z0]] == 0, {x0, y0, z0}]

(* Result tooooo long. Here you have it for downloading
http://ideone.com/XwbJu *)  
Run Code Online (Sandbox Code Playgroud)

结果