class Spirograph {
constructor (center,geom=[[100,1]]) {
this.c = center;
this.hands = geom.map(rv => ({radius:rv[0], vel:rv[1], angle:0}));
}
step(dt = 1) {
for (let h of this.hands) {
h.angle += h.vel*dt;
}
}
get pos () {
let {x,y} = this.c;
for (let {radius,vel,angle} of this.hands) {
angle *= Math.PI/180;
x += radius*Math.cos(angle);
y += radius*Math.sin(angle);
}
return ({x:x,y:y});
}
}