From: Nathan H. <nj...@nj...> - 2014-07-20 00:32:51
|
Hi Krzysztof, I agree with everything you've said. For the epsilon version you pretty much just need to call multiroots on the distance polynomial to get the intervals once you've identified a global minimum, then solve for each separately: best = roots(dd); ... lsqr = dd(best) sqr = dot(c-p, c-p)-(lsqr+2*eps); // slightly inaccurate hack to avoid sqrt of polynomial portions = roots(sqr) // is there a ranged version of roots? // minimise inside each portion. nearest_point(c.portion(portions[i])); There may be a more efficient way to do this, let's implement a simple and clean version and reassess if it comes up in profiling. njh On Sat, Jul 19, 2014 at 02:40:30AM +0200, Krzysztof Kosiński wrote: > This method is a little pointless, because it will return more than > one point only if they are at exactly the same distance. Due to > limited precision of doubles, this will only happen in very specific > circumstances - basically only if someone deliberately constructs the > object and the point with carefully chosen values. It's nearly > impossible to get more than one result by manipulating shapes on the > screen. Therefore arbitrarily picking one of the points doesn't change > much. > > It would be more useful if the method accepted a tolerance parameter > and returned the local minima of each subset of the shape not further > than this tolerance from the true nearest time. The attached image > explains this. > > Regards, Krzysztof > ------------------------------------------------------------------------------ > Want fast and easy access to all the code in your enterprise? Index and > search up to 200,000 lines of code with a free copy of Black Duck > Code Sight - the same software that powers the world's largest code > search on Ohloh, the Black Duck Open Hub! Try it now. > http://p.sf.net/sfu/bds > _______________________________________________ > Lib2geom-devel mailing list > Lib...@li... > https://lists.sourceforge.net/lists/listinfo/lib2geom-devel |