Created
April 14, 2017 09:39
-
-
Save Dzinlife/a3aacfd0978f0f59fb82a83a90899893 to your computer and use it in GitHub Desktop.
osx dock effect math
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var n = 9 | |
var r = n/2 | |
function range(i){ | |
var left = -r + i | |
var right = -r + i + 1 | |
if( left < - r ){ | |
left = -r | |
} | |
if ( right > r ){ | |
right = r | |
} | |
return [left, right] | |
} | |
function integral(x) { | |
var t = n | |
var c = 2 * Math.PI / t | |
// integration of cos(c * x) + 1 | |
return 1/c * Math.sin(c * x) + x | |
} | |
function integralRange(range){ | |
var left = range[0] | |
var right = range[1] | |
return integral(right) - integral(left) | |
} | |
for(var i = -1; i <= 0; i+= 0.01){ | |
var sum = 0 | |
for (var j = 0; j <= 9 ; j++){ | |
var area = integralRange( range(j + i) ) | |
sum += area | |
} | |
console.log(sum) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment