2011-05-02 47 views
5

給出3D中四條線(表示爲幾個點),我想要找到空間中的點,使點和每條線之間的距離之和最小。最接近3D中一組四條線的點

我試圖找到一種方法來將此作爲一個最小二乘問題來制定,但我不太確定我應該如何。我目前正在嘗試使用距離定義:http://mathworld.wolfram.com/Point-LineDistance3-Dimensional.html

任何想法?

+1

看起來更像東西math.stackexchange.com – fvu 2011-05-02 09:00:01

+0

感謝您的想法,貼:HTTP:// math.stackexchange.com/questions/36398/point-closest-to-a-set-four-of-lines-in-3d – 2011-05-02 09:15:27

回答

1

我在Mathematica中製作了一個計算點座標的程序。 結果是一個大的代數公式。我把它上傳到ideone給你。

這裏是程序,如果你手頭有數學:

(*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 *) 

RESULT

+0

嗨,鏈接已過期,你可以再次上傳嗎?謝謝 – elect 2015-06-22 13:47:55