function mod_resz(modindex,s1,s2)

% function mod_resz(modindex,s1,s2)
%
% This function if used in conjunction with FD3.  It is used to resize the
% module FD3MODULES(:,modindex).  'S1' and 's2' are respectively x and y
% scaling factors.  Modules are initially defined with scaling factors of one.
% By increasing 's1', one can create wider modules.  By increasing 's2', one
% can create taller modules.
%
% ACP

% Last update:  July 11, 1993
% Author:       Adrian C. Penisson

global FD3MODULES

% Get old scaling factors.

olds1=FD3MODULES(14,modindex);
olds2=FD3MODULES(15,modindex);

% Get x/ydata from PRIMARY OBJECT

xdata=get(FD3MODULES(1,modindex),'Xdata');
ydata=get(FD3MODULES(1,modindex),'Ydata');

% Adjust Primary x/ydata and rexet PRIMARY OBJECT

xdata=(xdata-FD3MODULES(4,modindex))*s1/olds1+FD3MODULES(4,modindex);
ydata=(ydata-FD3MODULES(5,modindex))*s2/olds2+FD3MODULES(5,modindex);

set(FD3MODULES(1,modindex),'Xdata',xdata,'Ydata',ydata);

if FD3MODULES(3,modindex)

   % If there is a SECONDARY OBJECT, also adjust its x/ydata.

   xdata=get(FD3MODULES(3,modindex),'Xdata');
   ydata=get(FD3MODULES(3,modindex),'Ydata');

   xdata=(xdata-FD3MODULES(4,modindex))*s1/olds1+FD3MODULES(4,modindex);
   ydata=(ydata-FD3MODULES(5,modindex))*s2/olds2+FD3MODULES(5,modindex);

   set(FD3MODULES(3,modindex),'Xdata',xdata,'Ydata',ydata);

end

FD3MODULES(14:15,modindex)=[s1 s2]';

% Adjust thetas so that sides are still defined properly

theta=FD3MODULES(10:13,modindex);
theta=rem(atan2(abs(tan(theta)).*sign(sin(theta))*(s2/olds2),...
   sign(cos(theta))*(s1/olds1))+2*pi,2*pi);
FD3MODULES(10:13,modindex)=theta;
