%Visualize a 2-D Gaussian function in 3-D

%define the sample point along the X-axis
x_start=-1.0;
x_end=1.0;
x_sub=0.2;
Nx=(x_end-x_start)/x_sub
x_value=x_start:x_sub:x_end;
%define the sample points along the Y-axis
y_start=-1.0;
y_end=1.0;
y_sub=0.2;
Ny=(y_end-y_start)/y_sub
y_value=y_start:y_sub:y_end;

%calculate the Gaussian function value on the sample points
for i=[1:Nx+1]
    for j=[1:Ny+1]
            f(i,j)=exp(-(power(x_value(i),2)+power(y_value(j),2)));
    end
end

%visualize the first Figure: constant interpolation on the surface

%Show the Figure in Window 1
figure(1);
surf(x_value,y_value,f);

%define the limit of the axis
xlim([-1.0,1.0]);
ylim([-1.0,1.0]);

%set up the green color
colormap([0,1,0])

%set up the light and specify the  lighting
light('Position',[-1,-1,0.5],'Style','infinite');

lighting flat
%lighting gouraud

%set the plot to be half transparent
alpha(0.2);


%add the grid
hold on % keep the figure

for i=[1:Nx+1]
    x_line=x_value;
    y_line=zeros(Ny+1)+y_value(i);
    z_line=zeros(Ny+1);
    plot3(x_line,y_line,z_line);
end

%colormap([0,0,0]);

%save the figure in png format
print -dpng 'Gaussian_2D_flat.png'


%-------------------------------------------------

%visualize the second Figure: linear interpolation with tranparency and the
%mesh shown
%show the Figure in Window 2
%figure(2);
%surf(x_value,y_value,f);