/**
*
* @param {*} p: 0-1
*/
function swing(p) {
p = p + 1;
// js cos是讀弧度
var res = Math.cos(p * Math.PI);
res = (res + 1) / 2;
res = res.toFixed(10);
res = Number(res);
return res;
}
for (var i = 0; i <= 1; i += 0.1) {
console.log(i, swing(i));
}