var CENTER_X = 126, CENTER_Y = 84;
function reverse(arr) {
var res = [];
for (var i = 0; i < arr.length; i += 2) {
res[i] = arr[arr.length - i -2];
res[i+1] = arr[arr.length - i -1];
}
return res;
}
function triskelion(Nsp, Nwh, a) {
var block1 = [];
var block2 = [];
var points = [];
var a,c,r,t,x,y,x0,y0,t1,t2;
var dt = 0.04;
for (var n=0; n < Nsp; n++) {
r=0;
t=0;
x0=CENTER_X+a*Math.cos(2*Math.PI*n/Nsp);
y0=CENTER_Y+a*Math.sin(2*Math.PI*n/Nsp);
savedt=t;
do {
t=t+dt;
r=c*t;
x=x0+r*Math.cos(t+Math.PI+2*Math.PI*n/Nsp);
y=y0+r*Math.sin(t+Math.PI+2*Math.PI*n/Nsp);
points.push(x);
points.push(y);
} while (t < t1);
block1.push(points);
points=[];
t=savedt;
do {
t=t+dt;
r=c*t;
x=x0+r*Math.cos(t+2*Math.PI*n/Nsp);
y=y0+r*Math.sin(t+2*Math.PI*n/Nsp);
points.push(x);
points.push(y);
} while (t<t2);
block2.push(points);
points=[];
}
var merged = [];
merged=merged.concat(block2[0]);
for (var i = 1; i < Nsp; i++) {
merged=merged.concat(reverse(block1[i]));
merged=merged.concat(block2[i]);
}
merged=merged.concat(reverse(block1[0]));
return merged;
}
foodini.useIngredient(ingredients[0]);
var points = triskelion(5, 2, 40);
foodini.drawPolyline(points);