var s = 1.70158 * 1.525; n = n*2; if(n < 1){ return (Math.pow(n, 2)*((s+1)*n - s))/2; } n-=2; return (Math.pow(n, 2)*((s+1)*n + s) + 2)/2;