function Koordinatensysteme

% http://geometrie.hs-nb.de/MATLAB-Programme/Koordinatensysteme.m   Bearbeitungsstand: 4.6.2004
% (C) Martin Nitschke, nitschke@hs-nb.de

clc;
close('all')
deg=pi/180;

figure('numbertitle','off','name','kartesisch');
[X,Y]=meshgrid(0:0.05:1,0:0.05:1);
KS(X,Y,1)
print('-depsc','Koordinatensysteme-kartesisch');

figure('numbertitle','off','name','schiefwinklig');
A=[1 -3;-3 2];
z=A\[1;1];
[U,V]=meshgrid(linspace(0,z(1),30),linspace(0,z(2),30));
KS(A(1,1)*U+A(1,2)*V,A(2,1)*U+A(2,2)*V,2);
print('-depsc','Koordinatensysteme-schief');

figure('numbertitle','off','name','krumm');
[T,R]=meshgrid([0:3:90]*deg,[0.2:0.05:2]);
Z=tan(R.*exp(i*T));
KS(real(Z)-0.2,imag(Z)-0.2,3);
print('-depsc','Koordinatensysteme-krumm');

figure('numbertitle','off','name','krumm und schief');
[T,R]=meshgrid([0:3:90]*deg,[0.2:0.05:2]);
Z=tan(R.*exp(i*T));
Z=real(Z)+0.4*imag(Z)*i;
KS(real(Z)-0.2,imag(Z),4);
print('-depsc','Koordinatensysteme-krumm-schief');

function KS(X,Y,axTxt)
plot(X,Y,X',Y','color',0.75*[1 1 1])
hold('on')
[m,n]=size(X);
plot(X(round(m/2),:),Y(round(m/2),:),'k',X(:,round(n/2)),Y(:,round(n/2)),'k','linewidth',2.0)
m0=round(0.25*m);
n0=round(0.35*n);
plot(X(m0,n0),Y(m0,n0),'.k','MarkerSize',30);
Schrift([X(m0,n0);Y(m0,n0)],'^{ }\itP','HorizontalAlignment','right','VerticalAlignment','top')
plot(X(m0:round(m/2),n0),Y(m0:round(m/2),n0),'k')
plot(X(m0,n0:round(n/2)),Y(m0,n0:round(n/2)),'k')
switch axTxt
  case 1
    Schrift([X(round(m/2),n0);Y(round(m/2),n0)],'{\itp}_1','HorizontalAlignment','center','VerticalAlignment','bottom')
  case 2
    Schrift([X(round(m/2),n0);Y(round(m/2),n0)],'_{ }{\itp}_2','HorizontalAlignment','left','VerticalAlignment','middle')
  case {3,4}
    Schrift([X(round(m/2),n0);Y(round(m/2),n0)],'{\itu}_1','HorizontalAlignment','center','VerticalAlignment','bottom')
end
switch axTxt
  case 1
    Schrift([X(m0,round(n/2));Y(m0,round(n/2))],'_{ }{\itp}_2','HorizontalAlignment','left','VerticalAlignment','middle')
  case 2
    Schrift([X(m0,round(n/2));Y(m0,round(n/2))],'{\itp}_1','HorizontalAlignment','center','VerticalAlignment','bottom')
  case 3
    Schrift([X(m0,round(n/2));Y(m0,round(n/2))],'{\itu}_{2 }','HorizontalAlignment','right','VerticalAlignment','middle')
  case 4
    Schrift([X(m0,round(n/2));Y(m0,round(n/2))],'{\itu}_2','HorizontalAlignment','right','VerticalAlignment','bottom')
end
hold('off')
axis('equal')
axis([0 1 0 1])
axis('off')

function Schrift(P,txt,varargin)
text(P(1),P(2),txt,'FontName','TimesNewRoman','FontSize',30,varargin{:});

