function calculateReflectOffset(i, w) {
    return Math.abs((i + w) % (2 * w) - w);
}
Calculates the index offset for a given index and window size.
@param {number} i The index.
@param {number} w The window size.
@returns {number} The index offset.