precision in binsearch

This commit is contained in:
Zeno Rogue 2022-05-07 15:18:20 +02:00
parent 9c29f39f7e
commit c8e5c3e763
1 changed files with 2 additions and 2 deletions

View File

@ -904,8 +904,8 @@ template <class T> void texture_order(const T& f) {
/** find the smallest value of x in range [dmin..dmax] such that f(x) returns true */
template<class T> ld binsearch(ld dmin, ld dmax, const T& f) {
for(int i=0; i<200; i++) {
template<class T> ld binsearch(ld dmin, ld dmax, const T& f, int iterations = 200) {
for(int i=0; i<iterations; i++) {
ld d = (dmin + dmax) / 2;
if(dmin == d || dmax == d) break;
if(f(d)) dmax = d;