% ____ Umwandlung : Radian Coords  in  Polar Coords ____
%  ______________________________________________

clear all;close all; clf;

% > It seems clear that your values are in radians so I have altered the 
%    following to use radians. :
Radi = pi/180*[ 90,0 ; 180,0 ; 270, 0; 360, 0 ; 0,90  ];

az = Radi(: , 1);    % azimuth
el = Radi(: , 2);     % elevation
r = 4;
h = 1;
x =   r *sin(az).*cos(el);
y = -r *cos(az).*cos(el);
z =  r *sin(el / h);                     % > High.
X = [zeros(size(x)) , x]';
Y = [zeros(size(y)) , y]';
Z = [zeros(size(z)) , z]';

hp1 = plot3(X,Y,Z, 'ko-', 'Linewidth',1.5)
% axis equal off;
hold on
% :::::::::::::::::::::::::::::::::::::::::::::::::::::::::
% __________ Design : Equator - Netz _____________
Phi = (0: 10: 360)* pi/180;
R = 0 :1: r;
[theta, r] = meshgrid(Phi,  R);
% > Now use the transformations 1 to change from cylindrical coordinates 
%    to Cartesian coordinates.
x = r.*cos(theta);
y = r.*sin(theta);
Z = zeros(size(x));
hm = mesh(x, y, Z)
set(hm, 'EdgeColor', 'k','Edgealpha', 0.9, 'FaceColor','none','Linewidth',1.)
grid on
% ::::::::::::::::::::: Create Earth :::::::::::::::::::::::.
axis equal
load('topo.mat');         % >  Suchen :   'earth','topomap1
[ U V W] = sphere;
hp9 = surf ( 1.4*U, 1.4*V, 1.4*W);
set(hp9, 'CData', W, 'FaceColor', 'texturemap','meshstyle', 'row', 'facealpha', 0.5);
pause(1)
hold on
Eksun = -23.5;                                       % Erd-Ekliptik : Sommerzeit Juni
Ekwin  = 23.5;                                        % Erd-Ekliptik : Winterzeit Dezember
view(80,4)
pause(1)
% rotate(hp9, [1 0 0], Eksun, [0 0 0 ])         % rotate only Erde
BogEk = (180-Eksun : -5: 180)* pi/180;
REk = 0 :0.5: 3;
[Thek, rek] = meshgrid( BogEk, REk);
% > Now : transformations to change from Cylindrical to Cartesian coordinates.
xEk = rek.*cos(Thek);
yEk= rek.*sin(Thek);
ZEk = zeros(size(xEk));
hm1 = mesh(ZEk, xEk, yEk)
set(hm1, 'EdgeColor', 'g','Edgealpha', 0.9, 'FaceColor', 'none', 'Linewidth', 1.2)
pause(1)
hh(8) = text(1, -5,1,   '\bf Ekliptik = 23.45°', 'Color','g');
set(hh(8),  'fontsize', 14)

% ::::::::::::: Rotate all Graphics together :::::::::::::::::::::::::::::::::.
rotate([hp1;  hp9], [1 0 0], Eksun, [0 0 0 ])
pause(1)
axis('off')
camva(5)
pause(3)
% :::::::::::::::::::: Design : Sonnen-Einfalls-Winkel für Dortmund ::::::::::::::::::
Dortmund = 51.3;
BetaD = 90 - Dortmund - Eksun
% :::::::::::::::::::::::::::::::::::::::::
Bogen = (360: -5: 330)* pi/180;
R = 0 :0.5: 3;
[Th, rb] = meshgrid( Bogen,  R);
% > Now : transformations to change from Cylindrical to Cartesian coordinates.
x1 = rb.*cos(Th);
y1 = rb.*sin(Th);
Z1 = zeros(size(x1));
% ::::::::::::::::  Seek :  Tangenten-Points für Location :::::::::::::::::::::::::
AZp1 = 1.4*cos((Dortmund-23.5)* pi/180)          % AZ-Tangentenpoint für Dortmund
ELp1 = 1.4*sin((Dortmund-23.5)* pi/180)           % EL-Tangentenpoint
hm1 = mesh(Z1, x1+AZp1, y1+ELp1)
set(hm1, 'EdgeColor', [1 0 0],'Edgealpha', 0.9, 'FaceColor', 'none', 'Linewidth', 1.2)
pause(1)
titstr(1) ={'\bf Sonnen - Einfallswinkel für Dortmund - '};
titstr(2) = {'\bf 21.Juni für 12:00 uhr = 62° '};
title(titstr, 'VerticalAlignment','bottom','Color','r', 'fontsize', 14);

% ::::::::::::::::: Alternativ :  Topo - Map :::::::::::::::::::::::::::::::::::::::
set(hp9, 'CData', topo, 'FaceColor', 'texturemap','EdgeColor','none','facealpha', 0.7);
colormap(topomap1);
% ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::.
view(91, 2)
rotate3d
