%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                            Michael Pokojovy                             % 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
figure(1);

set(gcf, 'PaperUnits', 'centimeters');
xSize = 20; ySize = 10;
xLeft = (21 - xSize)/2; yTop = (30 - ySize)/2;
set(gcf,'PaperPosition', [xLeft yTop xSize ySize]);
set(gcf,'Position',[0 0 xSize*50 ySize*50]);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
M = 21;
N = 21;

M2 = ceil(M/2);
N2 = ceil(N/2);

[X, Y] = meshgrid(linspace(pi/40, pi - pi/40, M), linspace(-2, 2, N));
Z = zeros(M, N);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
subplot(1, 2, 1);
hold on;

t = title('Cartesisches Gitter im Ausgangsbereich', 'interpreter', 'latex');
set(t, 'FontSize', 16);

surf(X, Y, Z);
colormap pink;

axis([0 pi -2 - 0.1 2 + 0.1]);

plot(X(1,   :), Y(end, :), 'r', 'LineWidth', 2);
plot(X(end, :), Y(1,   :), 'r', 'LineWidth', 2);
plot(X(:,   1), Y(:, end), 'r', 'LineWidth', 2);
plot(X(:, end), Y(:,   1), 'r', 'LineWidth', 2);

plot(X(M2, :),  Y(M2,  :), 'b', 'LineWidth', 2);
plot(X(:,  N2), Y(:,  N2), 'm', 'LineWidth', 2);

grid on;
view([0 90]);

xlabel('x');
ylabel('y');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
subplot(1, 2, 2);
hold on;

t = title('Gekr\"ummtes Gitter im Bildbereich', 'interpreter', 'latex');
set(t, 'FontSize', 16);

U = cos(X).*cosh(Y);
V = sin(X).*sinh(Y);
Z = zeros(M, N);

surf(U, V, Z);
colormap pink;

plot(U(1,   :), V(end, :), 'r', 'LineWidth', 2);
plot(U(end, :), V(1,   :), 'r', 'LineWidth', 2);
plot(U(:,   1), V(:, end), 'r', 'LineWidth', 2);
plot(U(:, end), V(:,   1), 'r', 'LineWidth', 2);

plot(U(M2, :),  V(M2,  :), 'b', 'LineWidth', 2);
plot(U(:,  N2), V(:,  N2), 'm', 'LineWidth', 2);

grid on;
view([0 90]);

xlabel('cos(x) cosh(y)');
ylabel('sin(x) sinh(y)');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%