function F14anim()
f = @(x) 1 + x - x.^2;
g = @(x) x.^3;
x = .5:.04:1; xr = x(end:-1:1);
clf
X = [x, xr];
Y = zeros(size(X));
Z = [f(x), g(xr)];
patch(X, Y, Z,'g', 'FaceAlpha', 0.2, 'EdgeColor', 'green')
axis([-1.2, 1.2, -1.2, 1.2, 0, 2])
shg
pause(1.0)
N = 20;
theta = 2*pi/N;
XYr = [X; Y];
for i = 1:N;
    XYr = rotatepatch(XYr(1, :), XYr(2, :), Z, theta, 'b');
    shg
    pause(0.3)
end

pause(1.0)

for k = 1:length(x) - 1;
    XX = x([k, k+1, k+1, k]);
    YY = zeros(size(XX));
    ZZ = [f(x([k, k])), g(x([k, k]))];
    XXYYr = [XX; YY];
    for i = 1:N
        XXYYr = rotatepatch(XXYYr(1, :), XXYYr(2, :), ZZ, theta, 'r');
        shg
        pause(0.1)
    end
end
end

function XYr = rotatepatch(X, Y, Z, theta, col)
R = [cos(theta), -sin(theta); sin(theta), cos(theta)];
XYr = R*[X;Y];
for i = 1:length(X) - 1
    patch([X(i), X(i+1), XYr(1, i+1), XYr(1, i)], ...
          [Y(i), Y(i+1), XYr(2, i+1), XYr(2, i)], ...
          [Z(i), Z(i+1), Z(i+1), Z(i)], ...
          col, 'FaceAlpha', 0.2, 'EdgeColor', 'none')
end
patch([X(1), X(end), XYr(1, end), XYr(1, 1)], ...
      [Y(1), Y(end), XYr(2, end), XYr(2, 1)], ...
      [Z(1), Z(end), Z(end), Z(1)], ...
      col, 'FaceAlpha', 0.2, 'EdgeColor', 'none')
end