clc; clear;
pr=180/pi;
%=========
%LOXODROMA
%=========
d=[ 10  %U1
    70  %U2
    20  %V1
    90]/pr %V2


A=atan2((d(4)-d(3)),(log(tan(d(2)/2+pi/4))-log(tan(d(1)/2+pi/4))));
Apr=A*pr
R=6380;
L=R*(d(2)-d(1))/cos(A)

V=[ 10
    20
    30
    40
    50
    60
    ]/pr;
U=[ 10
    20
    30
    40
    50
    60
    ]/pr;

for a=1:size(V,1)
Un(a,1)=2*atan(exp(((V(a)-d(3))/tan(A)+log(tan(d(1)/2+pi/4)))))-pi/2;
end
for a=1:size(U,1)
Vn(a,1)=d(3)+tan(A)*(log(tan(U(a)/2+pi/4))-log(tan(d(1)/2+pi/4)));
end

Unpr=Un*pr
Vnpr=Vn*pr

%=========
%ORTODROMA
%=========

o=acos(sin(d(1))*sin(d(2))+cos(d(1))*cos(d(2))*cos(d(4)-d(3)));
opr=o*pr
O=R*o

A1=asin((cos(d(2))*sin(d(4)-d(3)))/sin(o))
A1pr=A1*pr

A2=asin((cos(d(1))*sin(d(4)-d(3)))/sin(o))
A2pr=A2*pr

for a=1:size(V,1)
Am=acos(cos(A1)*cos(V(a)-d(3))-sin(A1)*sin(V(a)-d(3))*sin(d(1)));
Um(a,1)=acos(sin(A1)*cos(d(1))/sin(Am));
end
Umpr=Um*pr

for a=1:size(U,1)
Am=asin(cos(d(1))*sin(A1)/cos(U(a)))
dV=2*atan2(cos((d(1)-U(a))/2),(tan((A1+pi-Am)/2)*cos(pi/2-(d(1)+U(a))/2)));
Vm(a,1)=d(3)+dV;
end

Vmpr=Vm*pr

