private static int mod(int val, int n) {
        return ((val % n) + n) % n;
    }
Euclidean modulo (cycle on 0,n instead of -n,0; 0,n)

@param val
@param n
@return
jme3-core/src/main/java/com/jme3/anim/interpolator/FrameInterpolator.java