function func = vnorm;
% VNorm
%
% This m-file is part of the material of the lecture
%   Numerical Mathematics
% at the Math Department of Halle University, Germany.
% Winter term 2004/05
%
% Author :      Prof. Dr. M. Arnold, arnold@mathematik.uni-halle.de
% Version of :  Nov 1, 2004
%
% Visualization of unit balls in various Vector Norms
%
% Parameters:
%   none
%
% Examples:
%   vnorm;   % print -dpng ../png/vnorm

graphwidth  = 24.0;
graphheight =  8.0;
fac         =  1.0;
shift       =  0.6;
papershift  =  0.0;

ActFontSize  = 14;
ActLineWidth =  3;
RatioFlag    =  0;

border      = 1.0;

%
% -> Bestimme Groesse des Bildschirms und Skalierungsfaktor fuer die Ausgabe
root = 0;
set ( root, 'Units', 'centimeters' );
screensize = get ( root, 'ScreenSize' );
left   = screensize(1);
bottom = screensize(2);
width  = screensize(3);
height = screensize(4);
set ( root, 'Units', 'pixels' );
if RatioFlag==0,
  screenscale = 1.0;
elseif RatioFlag==1,
  screenscale = (width-2*border) / graphwidth;
end;

%
% -> Definiere den Bildschirmausschnitt
if length ( get ( root, 'Children' ) ) == 0,
  h = figure;
else
  h = gcf;
  clf;
end;
set ( h, 'Units',    'centimeters' );
set ( h, 'Position', ...
  [ left+width-screenscale*graphwidth-border height-2*border-screenscale*graphheight ...
    screenscale*graphwidth                   screenscale*graphheight ] );
set ( h, 'Units',    'pixels' );

%
% -> Skalierung der Ausgabe in PostScript
%
set ( gcf, 'PaperUnits',    'centimeters' );
set ( gcf, 'PaperPosition', [ papershift papershift graphwidth graphheight ] );

% -> control data 
xmin = -1.8;
xmax =  1.8;
ymin = -1.8;
ymax =  1.8;

% -> plot
for iplot=1:3,
    subplot ( 1, 3, iplot );
    if iplot==1,
        h = fill ( [ 1 0 -1 0 ], [ 0 1 0 -1 ], [ 1 0.5 0.5 ]    ...
                 , 'EdgeColor', 'r'                             ...
                 , 'LineWidth', ActLineWidth                    ...
                 );
        title ( '1 - Norm' );
    elseif iplot==2,
        tt = linspace ( 0, 2*pi, 1001 );
        h = fill ( sin(tt), cos(tt), [ 0.5 1 0.5 ]              ...
                 , 'EdgeColor', 'g'                             ...
                 , 'LineWidth', ActLineWidth                    ...
                 );
        title ( 'Euklidische Norm' );
    elseif iplot==3,
        h = fill ( [ 1 -1 -1 1 ], [ 1 1 -1 -1 ], [ 0.5 0.5 1 ]  ...
                 , 'EdgeColor', 'b'                             ...
                 , 'LineWidth', ActLineWidth                    ...
                 );
        title ( 'Maximumnorm' );
    end;
    set ( gca, 'PlotBoxAspectRatio', [ 1 1 1 ] );
    set ( gca, 'DataAspectRatio',    [ 1 1 1 ] );
    xlabel ( 'x_1' );
    ylabel ( 'x_2' );
    grid;
    axis ( [ xmin xmax ymin ymax ] );
end;

%
% -> Korrektur der Groesse und Lage der Koordinatensysteme
allax = get ( gcf, 'Children' )';
for ax = allax,
  rect    = get ( ax, 'Position' );
  rect(2) = rect(2) + shift * (1-fac) * rect(4);
  rect(4) = fac * rect(4);
  set ( ax, 'Position', rect );
end;

%
% -> Aenderung der Schriftgroesse
for hf = allax,
  set ( hf, 'FontSize', [ActFontSize] );
  set ( get ( hf, 'title' ), 'FontSize', [ActFontSize] );
  set ( get ( hf, 'xlabel' ), 'FontSize', [ActFontSize] );
  set ( get ( hf, 'ylabel' ), 'FontSize', [ActFontSize] );
end;