function prev(i,p)
{
return i>0?i-1:p-1;
}
function nex(i,p)
{
return i<p-1?i+1:0;
}
function smooth(pi)
{
var pathes = [];
var gb, center, sign;
var d, i, j, p, v;
p = pi.pathPoints;
for(i = 0; i < p.length; i++){
d0=(p[nex(i,p.length)].anchor[0]-p[prev(i,p.length)].anchor[0])/6;
d1=(p[nex(i,p.length)].anchor[1]-p[prev(i,p.length)].anchor[1])/6;
p[i].leftDirection = [p[i].anchor[0]-d0,p[i].anchor[1]-d1];
p[i].rightDirection = [p[i].anchor[0]+d0,p[i].anchor[1]+d1];
}
}
var piRef = activeDocument.pathItems;
var N=10;
var C=50;
var points = new Array(N*4+1);
var pathRef = piRef.add();
points[0]=new Array(0,0);
points[N+1]=new Array(0,0);
for ( i = 0; i != N ; i++ )
{
p=(i+1)/(N+1);
x=C*Math.sqrt(2)*(p+p*p*p)/(1+p*p*p*p);
y=C*Math.sqrt(2)*(p-p*p*p)/(1+p*p*p*p);
points[i+1]=new Array(x,y);
points[2*N-i]=new Array(x,-y);
points[2*N+i+1]=new Array(-x,y);
points[4*N-i]=new Array(-x,-y);
}
pathRef.setEntirePath(points);
pathRef.closed=true;
smooth(pathRef);