//Cloud distances calculator
//units: [m], [rad]
Re=6.371e6; //earth radius
R=Re+10e3; //cloud radius
h=1.65; //eye level height

phi=linspace(0,1e-3,200); //angle from center of earth
x=sin(phi)*R; //points of view in earth coordinates
y=(cos(phi))*R-Re; //y=0 at observer

l=sqrt(x.^2+y.^2); //straight-line (tunnel) distance to earth point
gm=acos((l.^2+Re^2-R^2)./(2*Re*l)); //angle from origin to point
d=sqrt(h^2+l.^2-2*h*l.*cos(%pi-gm)); //eye height to point distance
th=acos((h^2+d.^2-l.^2)./(2*h*d)); //theta angle from eye height to point
arcd=R*phi; //arc diameter (cloud size along the circle of radius R)
