laurentkneip / opengv

OpenGV is a collection of computer vision methods for solving geometric vision problems. It is hosted and maintained by the Mobile Perception Lab of ShanghaiTech.
Other
1.02k stars 353 forks source link

Infinite loop in opengv::math::Sturm::bracketRoots #29

Open jkopf opened 8 years ago

jkopf commented 8 years ago

I am running into an infinite loop in above function.

It seems the problem is that there is a Bracket on the stack that has numberRoots() == 2 but _upperBound == _lowerBound. So, Bracket::dividable returns true.

Happy to try to create a minimal example of the problem if that would help.

In the meantime, does this modification seem an appropriate fix?

bool opengv::math::Bracket::dividable( double eps ) const { if( numberRoots() == 1 && (_upperBound - _lowerBound ) < eps ) return false; if( numberRoots() == 0 ) return false; // BEGIN NEW CODE if (_upperBound - _lowerBound < 1e-10) return false; // END NEW CODE return true; }

This causes the Bracket to become "undividable" eventually and the loop breaks.