// Given some number of polynomials (where each polynomial c0*t^n + // + c1*t^(n-1) + ... + cn is represented by the std::vector containing // (c0, c1, ..., cn), find the first time t >= 0 for which: // 1. Each polynomial is >= 0 at t; // 2. Each polynomial is > 0 at t + any sufficiently small number epsilon. // If no such time exists, returns infinity instead. // // Does not need to be changed by students. double PolynomialIntervalSolver::findFirstIntersectionTime(const std::vector<Polynomial> &polys) { s_polynomials.insert(s_polynomials.end(), polys.begin(), polys.end()); if(polys.size() == 0) return std::numeric_limits<double>::infinity(); std::vector<Polynomial>::const_iterator it = polys.begin(); Intervals inter = findPolyIntervals(*it); for(++it; it != polys.end(); ++it) { Intervals nextint = findPolyIntervals(*it); inter = intersect(inter, nextint); } return inter.findNextSatTime(0.0); }