How to find 3d point with minimum sum of euclidean distances to all given segments?

Viewed 156

N segments in 3d space are given. Segment is represented by 2 points. The problem is to find the point with minimal possible sum of distances to all segments.

1 Answers

Let the segments be p1 q1, …, pn qn. We formulate an optimization problem:

minimize ∑i ‖x − ((1 − yi) pi + yi qi)‖
subject to
x ∈ ³
∀i, yi ∈ [0, 1]

The variable x is the point we’re looking for. The variables yi take advantage that we’re trying to minimize a minimum (minimum distance to x) and are used to form the convex combination in the objective.

This is a convex problem, so either cvxpy or scipy.optimize should be able to handle it nicely.

Related