Cartoon of flexing a planar x-ray mirror to vary the bending radius Matlab code

% Cartoon of flexing a mirror to change the bending radius

clear; close all

vid = VideoWriter('flexedMirror.mp4','MPEG-4');

vid.FrameRate = 60;    % Default 30

vid.Quality = 100;    % Default 75

open(vid);

set(0,'defaultfigurecolor',[1 1 1]);    % Make background colour white

figure('units','pixels','position',[0 0 1920 1080],'ToolBar','none');

tighten = 20:20:4000;

relax = 4000:-20:20;

tightenrelax = [0.1 tighten relax 0.1];

for i = tightenrelax

hold off

r = 1000000/i; % Vary the radius of arc between 50 m and 250 mm

l = 180; % Set the length of arc to 180 mm

crcm = 2*pi*r;                                     % Full circle circumference

arcfrac = l/crcm;                                  % Arc length fraction of circumference

angfrac = 2*pi*arcfrac;                            % Angle fraction of circumference (rad)

halfang = 180*arcfrac;

angv = linspace(-pi/2-angfrac/2, -pi/2+angfrac/2); % Angle vector in radians

x = r*cos(angv);

y = r*sin(angv) + r;

plot(x, y, 'Color', [37 44 94]/256, 'LineWidth',32)

hold on

axis equal

axis off

axis([-150  150  -20  150])

str1 = 'Subtended angle = +/- ';

str2 = num2str(halfang,'% 4.2f');

str3 = '^{o}';

strTot = [str1,str2,str3];

hText = text(0, 100, strTot, 'FontSize',22,'HorizontalAlignment', 'center');

frame = getframe(gcf);

writeVideo(vid,frame);

hold on

end

% Output the movie as an mpg file

close(vid);