%animates a cycloida of a circle rolling in a circle
FPS = 10;
R1 = 9;
R2 = 13;
N = lcm(R1,R2);
dt = .1/FPS*(N*pi);
clf;
for i=0:FPS*200    
    t=[i*dt:0.1:(i+1)*dt];
    x = (R2-R1).*cos(t*R1/R2) + R1.*cos(-1*t);
    y = (R2-R1).*sin(t*R1/R2) + R1.*sin(-1*t);
    plot(x,y); hold on;
    axis equal;
    axis([-R2 R2 -R2 R2]*1.1);
    pause(1/FPS);
end