Am 26.07.2013 11:06, schrieb Thomas Nordhaus: > Am 26.07.2013 05:33, schrieb William Elliot: >> How do we find the shortest distance between two lines L, L' in R^3 ? >> >> 2. >> http://at.yorku.ca/cgi-bin/bbqa?forum=calculus;task=show_msg;msg=0792 >> > > How about doing it straight forward from scratch? Let P1(s) = v0 +s*v, > P2(t) = w0 + t*w be arbitrary points on the line L, L' resp. > > Let f(s,t) = ||P1(s)-P2(t)||^2 = <P1(s)-P2(t),P1(s)-P2(t)> where <,> is > the dot-product. Compute the partials D1f, D2f w.r.t. s and t: > > D1(s,t) = 2<P1'(s),P1(s)> - 2<P1'(s),P2(t)> > D2(s,t) = 2<P2'(t),P2(t)> - 2<P2'(t),P1(s)>
> > You want that D1 and D2 vanish simultaneously. This results in the > equations: > > (A): > s*<v,v> - t*<v,w> = <v,w0-v0> = 0 > -s*<v,w> + t*<w,w> = <w,v0-w0> = 0 > > This can be written as a matrix-equation: > > (B): > M*[s,t] = [<v,w0-v0>,<w,v0-w0>]' > where M is a 2x2 matrix and ' is a 2x1 column-vectors. > > M is invertible provided its determinant is non-zero: > > det(M) = <v,v><w,w> - <v,w>^2 > > ***** (Case I, det(M)= 0) ***** > > Now, by the Cauchy-Schwarz inequality det(M) is zero iff v and w are > collinear, i.e. there is a real number a !=0 such that w = a*v. Then > > det(M) <v,v><a*v,a*v> - <v,a*v>^2 = 0. > > This refers to the case that L and L' are parallel. In this case going > back to (A) results in: > > (s-at)*<v,v> = <v,w0-v0> > (-as+a^2*t)*<v,v> = a<v,v0-w0> > > which are the same equations. Therefore one has to solve > > (s-at)*<v,v> = <v,w0-v0>. So s = s(t) = at + <v,w0-v0>/<v,v>. > > Next we compute f(s(t),t), the square of the distance. This value must > be independent of t. Choosing t=0 one obtains: > > f(s(0),0) = <v0+s(0)v-w0,v0+s(0)v-w0>. The distance D between L and L' > therefore is > > D = || v0 - w0 + (<v,w0-v0>/||v||^2)*v || > > > ***** (Case II, det(M)!= 0) ***** > > In this case you have to solve (A) for s and t. The unique solution > (S,T) is then given by: > > [S,T] = M^(-1) * [<v,w0-v0>,<w,v0-w0>]'
should be [S,T]' (' denotes transpose)
> > The distance D between L and L' is then given by > > || v0+S*v - w0-T*w||. > > Hope I got it right!
Would be a shame if not - the equations look so nice.
I did a numerical check for a few randomly generated lines L, L' for Case I and II looking for minimal distance on an (s,t)-grid. I got a good agreement with the solution-formulas.