- Axis other = other_axis (ax);
- Interval lr (l, r);
- vector<Real> solutions;
-
- // Possible solutions are:
- // t = 0 or 1, or...
- solutions.push_back (0);
- solutions.push_back (1);
-
- // t is a critical point for the other-axis polynomial, or...
- Polynomial p_prime (polynomial (other));
- p_prime.differentiate ();
- vector<Real> criticals = p_prime.solve ();
- solutions.insert (solutions.end (), criticals.begin (), criticals.end ());
-
- // t solves curve_coordinate(t, X_AXIS) = l or r.
- Direction dir = LEFT;
- do
- {
- Polynomial p (polynomial (ax));
- p.coefs_[0] -= lr[dir];
+ Axis bx = other_axis (ax);
+
+ // The curve could hit its bounding box limit along BX at:
+ // points where the curve is parallel to AX,
+ Offset vec (0.0, 0.0);
+ vec[ax] = 1.0;
+ vector<Real> sols (solve_derivative (vec));
+ // or endpoints of the curve,
+ sols.push_back (0.999);
+ sols.push_back (0.001);
+ // (using points just inside the ends, so that an endpoint is evaulated
+ // if it falls within rounding error of L or R and the curve lies inside)