function visualize_result( GRID, fn )
    colormap = parula;
    %% visualize the virtual tip with its sections
    figure('Position',[100 100 1000 1000]);
    grid('on')
    box('on')
    view(0,90)
    view(90,0)
    fontszcap = 26;
    fontszax = 26;
    fontnm = 'Calibri';
    xlabel({'x (m)'},'FontSize',fontszcap,'FontName',fontnm);
    ylabel({'y (m)'},'FontSize',fontszcap,'FontName',fontnm);
    zlabel({'z (m)'},'FontSize',fontszcap,'FontName',fontnm);
    
    pbaspect([ 1 1 1])
    set(gca,'FontSize',fontszcap,'FontName',fontnm,'LineWidth',1.5)
    set(gcf,'PaperUnits','Inches')
    set(gcf,'PaperSize',[30 30])
    set(gcf,'color','w')
    xlim([-16e-9 16e-9]);
    xt = [-16e-9:8e-9:16e-9];
    xticks(xt);
    ylim([-16e-9 16e-9]);
    yt = [-16e-9:8e-9:16e-9];
    yticks(yt);
    zlim([-1e-9 66e-9]);
    zt = [-1e-9:10e-9:66e-9];
    zticks(zt);
    view(38,14);
    
    %GRID = FINALGRID;
    %base plate
    hold on
    these = GRID(4,:)==2;
    plot3(GRID(1,these),GRID(2,these),GRID(3,these),'.','MarkerSize',2,'Color',[0 0 0]);
    %tip
    hold on
    these = GRID(4,:)==10;
    plot3(GRID(1,these),GRID(2,these),GRID(3,these),'.','MarkerSize',2,'Color',colormap(1,:)); %0 0 1]);
    %legend('Base plate','Tip')
    print(gcf,[fn '.TipAndBase.png'],'-dpng','-r600')
    %inner capsule
    hold on
    these = GRID(4,:)==1;
    plot3(GRID(1,these),GRID(2,these),GRID(3,these),'.','MarkerSize',2,'Color',colormap(32,:)); %[0 0 0 0.05]);
    %outer vacuum capsule
    hold on
    these = GRID(4,:)==0;
    plot3(GRID(1,these),GRID(2,these),GRID(3,these),'.','MarkerSize',2,'Color',colormap(50,:)); %[0 1 0]);
    %legend('Base plate','Tip','Inner vac','Outer vac')
    print(gcf,[fn '.Everything.png'],'-dpng','-r600')
    close(gcf)
end
