function [hh] = plotGauss(mu,covar,plopt,plopt2)
%function [hh] = plotGauss(mu,covar,plopt,plopt2)
%
%PLOT A 2D Gaussian
%This function plots the given 2D gaussian on the current plot.
%
%It takes as input a 2d vector mu, which holds the mean and
% a 2 by 2 matrix covar which holds the covariance matrix.

if(nargin<4) plopt2 = 'r+'; end
if(nargin<3) plopt = 'r'; end

t = -pi:.01:pi;
k = length(t);
x = sin(t);
y = cos(t);

[vv,dd] = eig(covar);
A = real((vv*sqrt(dd))');
z = [x' y']*A;

holdss = ishold;
hold on;
hh = plot(z(:,1)+mu(1),z(:,2)+mu(2),plopt);
plot(mu(1),mu(2),plopt2);
if(holdss~=1) hold off; end
