
Re: Distance Between Lines in R^3 (fwd)
Posted:
Jul 26, 2013 7:35 AM


A few notational corrections:
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/cgibin/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 dotproduct. 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)>
That should be D1f(s,t), D2f(s,t) of course.
> > this yields > > D1(s,t) = 2<v,v0+s*v  w0t*w> > D1(s,t) = 2<w,w0+t*w  v0s*v>.
D1f(s,t), D2f(s,t)
> > You want that D1 and D2 vanish simultaneously. This results in the > equations: > > (A): > s*<v,v>  t*<v,w> = <v,w0v0> = 0 > s*<v,w> + t*<w,w> = <w,v0w0> = 0 > > This can be written as a matrixequation: > > (B): > M*[s,t] = [<v,w0v0>,<w,v0w0>]' > where M is a 2x2 matrix and []' is a 2x1 columnvectors. > > M is invertible provided its determinant is nonzero: > > det(M) = <v,v><w,w>  <v,w>^2 > > ***** (Case I, det(M)= 0) ***** > > Now, by the CauchySchwarz 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: > > (sat)*<v,v> = <v,w0v0> > (as+a^2*t)*<v,v> = a<v,v0w0> > > which are the same equations. Therefore one has to solve > > (sat)*<v,v> = <v,w0v0>. So s = s(t) = at + <v,w0v0>/<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)vw0,v0+s(0)vw0>. The distance D between L and L' > therefore is > > D =  v0  w0 + (<v,w0v0>/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,w0v0>,<w,v0w0>]'
should be [S,T]' (' denotes transpose)
> > The distance D between L and L' is then given by > >  v0+S*v  w0T*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 solutionformulas.
 Thomas Nordhaus

