[R] How to compute the minimal distanct between a point and curve in N-dim space

apjaworski@mmm.com apjaworski at mmm.com
Tue Feb 10 18:54:46 CET 2004

In general there will be no closed form solution.  In fact, for a general
curve in N dimensions one can have multiple discrete solutions or even a
continuum of solutions.  A trivial example of this is a problem of finding
a point on a circle in 2D closest to its center.

A curve in N dimensions can be described by a set of N coordinate functions
of a single parameter.  For example, a straight line in 3D going through
the (x0, y0, z0) point and having the "directional vector" (a, b, c) can be
described by

      x(t) = x0 + a*t
      y(t) = y0 + b*t
      z(t) = z0 + c*t

Then, the (Euclidean) distance between an arbitrary point (x1, y1, z1) and
a point on the curve can be written as:

      d(t) = sqrt((x(t) - x1)^2 + (y(t) - y1)^2 + (z(t) - z1)^2).

This function could be minimized either analytically or numerically with
respect to t.  In the straight line example, an analytical solution is
possible.  In fact the minimum value of the parameter t happens to be

      t(min) = (a*(x1-x0) + b*(y1-y0) + c*(z1-z0))/(a^2 + b^2 + c^2)

and substituting this value into the line equations gives the coordinates
of the minimum solution.

Hope this helps,


Andy Jaworski
Process Laboratory
3M Corporate Research Laboratory
E-mail: apjaworski at mmm.com
Tel:  (651) 733-6092
Fax:  (651) 736-3122

|         |           "Feng Zhang"         |
|         |           <f0z6305 at labs.tamu.ed|
|         |           u>                   |
|         |           Sent by:             |
|         |           r-help-bounces at stat.m|
|         |           ath.ethz.ch          |
|         |                                |
|         |                                |
|         |           02/10/2004 09:17     |
|         |                                |
  |                                                                                                                             |
  |      To:       "R-help mailing list" <r-help at stat.math.ethz.ch>                                                             |
  |      cc:                                                                                                                    |
  |      Subject:  [R] How to compute the minimal distanct between a point and curve       in N-dim space                       |

Dear All,

In the N-dimensional space, give a data point A and a curve f,
how to write the explicit expression for calculating the
minimal distance between A and f?

Or have to use some nonlinear optimization method to calcualte it?

Thanks for your point.


             [[alternative HTML version deleted]]

R-help at stat.math.ethz.ch mailing list
PLEASE do read the posting guide!

More information about the R-help mailing list