问题
Let's look at four (m) points in 3-d space- I want to generalize to n-d, but 3 should suffice for a solution ( Part 1).
a= (x1, y1, z1)
b= (x2, y2, z2)
c= (x3, y3, z3)
.
.
p= (x , y , z)
Find point q = c1* a + c2* b + c3* c + ..
where c1 + c2 + c3 +.. = 1
and c1, c2, c3, .. >= 0
s.t.
euclidean distance pq is minimized.
What algorithms can be used ? Idea or pseudocode is enough.
Part 2: solve for m points in n-dimensions :
I thought it would be trivial to generalize to m points in n dimensions, but turns out it is not straightforward. I created another problem for the general problem here: minimize euclidean distance from sets of points in n-dimensions
回答1:
I think your question in 3D can be reduced to a simple affine 2D geometry problem by projecting the point P
on the plane defined by the three points A, B, C
, or the two vectors AB
and AC
(or another combinations of AB, AC, and BC
).
At first sight, it seems likely that the 3+1 points problem generalizes to N dimensions (3 points always defining a triangle and a plane).
However, it is not immediately clear if this approach would work for more points that would not be coplanar.
1- reduction to 2D by projecting P
to a point P'
on the plane defined by vectors AB
, and AC
.
2- understand that the position of P'
is determined by only one coefficient t in the Reals
s.t. P'
is an affine combination of AB
and AC
:P' = t * AB + (1-t) * AC
3- from there, P'
can be in 3 distinct locations:
(a) inside the triangle
ABC
: in that case,Q = P'
(b) in the areas delimited by an orthogonal outwards projection of one of the segments; in that case
Q
is the orthogonal projection ofP'
on the closest segment.(c) not in (a) or (b); in that last trivial case,
Q
is the closest ofA, B, or C
来源:https://stackoverflow.com/questions/52129598/minimize-euclidean-distance-from-sets-of-points-in-3-d