Brain Teaser - Minimum distance between two curves
|
11-21-2015, 09:39 PM
Post: #13
|
|||
|
|||
RE: Brain Teaser - Minimum distance between two curves
May I suggest a slight variation?
One can compute the distance between two arbitrary points on the curves as a function of two variables: x1, x2. Let D(x1,x2) be that function. It is fairly easy to compute its gradient G(x1,x2) which has two components. Then finding the minimum distance is equivalent to find (x1,x2) such that G(x1,x2)=(0,0). Let's then introduce an auxiliary function G2 which is the square of the module of G. G2(x1,x2) is now a scalar. The root of this function can be found by using a Newton algorithm extended at two dimensions. The only difficulty is that you have now to compute the gradient of G2 which is a bit tedious by hand. Being lazy, I used a numerical approximation. After some iterations I ended up with: x1=0.331696159945 x2=0.56807264531 d(x1,x2)=0.427592353669 The accuracy of the solution in that case is mainly dependent of the accuracy of the approximation of the gradient, which in turn is limited by the accuracy of the floating point operations. Regards |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)