function [ax,delta,theta]=normalizeellipse(ax,delta,theta)
%NORMALIZEELLIPSE Make sure ellipse axes are positive and ax(1)>ax(2).
%
%[ax,delta,theta]=normalizeellipse(ax,delta,theta)
%Return parameters have ax(1) as major axis and ax(2) as minor
%axes. Delta and theta are adjusted accordingly.

% v1.0  2000-05-17. Niclas Borlin, niclas@cs.umu.se.

if (ax(1)<0)
	% First axis negative.
	ax(1)=-ax(1);
	delta=delta+pi;
	theta=-theta;
end
if (ax(2)<0)
	% Second axis negative.
	ax(2)=-ax(2);
	theta=-theta;
end
% Now both axes are non-negative.
if (ax(2)>ax(1))
	% Swap axes to make ax(1) major axis.
	ax=ax([2,1]);
	delta=delta+pi/2;
	theta=theta-pi/2;
end
