function elliPlot(D, c, a, b)
%elliPlot elliPlot(D,c) draws the ellipse of equation (x-c)' D (x-c) = 1
%         elliPlot(D,c,a) draws also as crosses the N points in a, an 2-by-N matrix
%         elliPlot(D,c,a,b) draws also as circles the M points in b, an 2-by-M matrix
%         If needed, elliplot projects on the two first components.
%clf;
% CODED BY FRANCOIS GLINEUR
color = 'b';
nPoints = 250; 			% Number of ellipse points to draw
[V, D] = eig(D);     
if size(D, 1) > 2
    disp('! Projection on the two first components !');
    V = V(1:2, :);
    D = V*D*V';
    [V, D] = eig(D);     
    c = c(1:2); 
end
V = V * D^(-1/2);
index = (1:nPoints)*pi*2/nPoints;   
Point = V * [cos(index) ; sin(index)] + c * ones(1, nPoints); % ! parfois +c, parfois -c
plot(c(1),c(2),[color 'x'],Point(1,:),Point(2,:),[color ':']);
set(gca, 'color', 'k'); 
hold on;
if nargin > 2
   plot(a(1,:),a(2,:),'rx');
end
if nargin > 3
   plot(b(1,:),b(2,:),'go');
end
% hold off;
figure(gcf);


