Type of figure:
Contents of file poncelet.m:
function psi = poncelet(b, c, phi, nHops) psi = zeros(nHops+1, 1); psi(1) = phi; for k=1:nHops beta = atan2(b*sin(phi), 1.0 - b*cos(phi)); p = norm([b*sin(phi), 1.0 - b*cos(phi)]); xi = asin(c/p); phi = phi + pi + 2*(beta-xi); psi(k+1) = phi; end ang = linspace(-pi, pi, 1001); ca = cos(ang); sa = sin(ang); plot(ca, sa, 'b', b+c*ca, c*sa, 'm', cos(psi), sin(psi), 'r'); axis('equal'); grid on; % Try each of the following. % poncelet(0.5, 0.2432, pi, 5) % poncelet(0.5, 0.1773, pi, 7) % poncelet(0.5, 0.2967, pi, 8) % poncelet(0.5, 0.3750, pi, 3) % poncelet(0.4, 0.5515, pi, 4) % % The third argument can be varied in each case to see that the % polygon is still closed.