*/
public void setInterpolatedTime(final double time) {
// initialize the search with the complete steps table
int iMin = 0;
final StepInterpolator sMin = steps.get(iMin);
double tMin = 0.5 * (sMin.getPreviousTime() + sMin.getCurrentTime());
int iMax = steps.size() - 1;
final StepInterpolator sMax = steps.get(iMax);
double tMax = 0.5 * (sMax.getPreviousTime() + sMax.getCurrentTime());
// handle points outside of the integration interval
// or in the first and last step
if (locatePoint(time, sMin) <= 0) {
index = iMin;
sMin.setInterpolatedTime(time);
return;
}
if (locatePoint(time, sMax) >= 0) {
index = iMax;
sMax.setInterpolatedTime(time);
return;
}
// reduction of the table slice size
while (iMax - iMin > 5) {
// use the last estimated index as the splitting index
final StepInterpolator si = steps.get(index);
final int location = locatePoint(time, si);
if (location < 0) {
iMax = index;
tMax = 0.5 * (si.getPreviousTime() + si.getCurrentTime());
} else if (location > 0) {
iMin = index;
tMin = 0.5 * (si.getPreviousTime() + si.getCurrentTime());
} else {
// we have found the target step, no need to continue searching
si.setInterpolatedTime(time);
return;
}
// compute a new estimate of the index in the reduced table slice
final int iMed = (iMin + iMax) / 2;
final StepInterpolator sMed = steps.get(iMed);
final double tMed = 0.5 * (sMed.getPreviousTime() + sMed.getCurrentTime());
if ((Math.abs(tMed - tMin) < 1e-6) || (Math.abs(tMax - tMed) < 1e-6)) {
// too close to the bounds, we estimate using a simple dichotomy
index = iMed;
} else {