-// silly name
-Interval
-quantise_iv (Array<Real> const& positions, Real period, Real x)
-{
- /*
- ugh
- assume that
- * positions are sorted,
- * positions are nonnegative
- * period starts at zero
- */
-
- int n = (int)(x / period);
- Real frac = (x / period - n) * period;
- if (frac < 0)
- {
- frac += period;
- n--;
- }
-
- Slice slice = get_bounds_slice (positions, frac);
- Interval iv(positions[slice[SMALLER]], positions[slice[BIGGER]]);
-
- if (slice[SMALLER] == slice[BIGGER])
- {
- if (slice[SMALLER] == 0)
- iv[SMALLER] = - period + positions.top ();
- else
- iv[BIGGER] = period + positions[0];
- }
-
- iv += period * n;
-
- return iv;
-}