small = 0.01
t = [0:0.01:1];
y= t.^3;
#plot(t,y)


# F = (k+1)/(twopi) * (E*I)^(k-1)
# 2 pi F = (k+1) * E^(k-1) * I^(k-1) 
# log(2 pi f) = log(k+1) + (k-1)*(log(E) + log(I))
# log(2 pi f) = log(k-1) log(E) + log(k-1) log(I) + log(k+1)

# or, L = 2pi F I = (k+1)/(twopi) * E^(k-1) I^k
# so log (2 pi L) = log(k+1) + (k-1) log(E) + K log(I)
# so the nomogram should be
# A1(L) = log(2 pi L)
# A23(K, E) = log(K+1)/2 + (K-1) log(E)
# -A24(K, I) = -log(K+1)/2 - K log(I)

k = [small:0.01:1];
E = [0.01:0.08:0.9];

x = 0.0
k = [x:0.01:1-x];
colorspec = {[0.9 0.9 0.9]; [0.8 0.8 0.8]; [0.6 0.6 0.6]; [0.4 0.4 0.4]; [0.2 0.2 0.2]};


%{
for e = E 
  plot(sqrt(k) .* e .^ k); hold on;
end

for e = E 
  plot(-sqrt(k) .* e .^ k); hold on;
end

hold off;

%}



%%%%% ORIENTED NOMOGRAM WITH TRANSPARENCY
# A1(L) = log(2 pi L)
# A23(K, E) = log(K+1)/2 + (K-1) log(E)
# -A24(K, I) = -log(K+1)/2 - K log(I)


color1 = [0 0.3 0.9];
color2 = [0.3 0.3 0.3];

q = 1.0; # convex combination of coefficient ln(k+1)
E = [0.00:0.05:1];
 for e = E
   plot(log(k+1)*q*1 +  (k-1)* log(e), k, "Color", color1); hold on;
   
   r = 0;
   text((log(r+1)*(q)*1 + (r-1)* log(e)), r-0.01, num2str(e), 'rotation',-90); hold on;
   

t = text(0.5, 1.1, "Cosine of incident angle", "Color",color2);
t = text(0.5, -0.1, "Cosine of exident angle", "Color",color1);
t = text(-0.4, 0.5, "Minnaert constant k", "Color", [0 0 0], 'rotation', -90);
   set(t, 'horizontalAlignment', 'center');

set(gca, 'XTickLabelMode', 'Manual')
set(gca, 'XTick', [])

 end
 for i = E
   plot(-(log(k+1)*(1-q)*1 + k* log(i)), k, 'Color', color2); hold on;
   r = 0;
   # text(-(log(r+1)*(1-q)*1 + (r-1+1)* log(i)), r-0.01, num2str(i), 'rotation',-90); hold on;
   # text(-(log(r+1)*(1-q)*1 + (r-1+1)* log(i)), 1.05, num2str(i), 'rotation',-90); hold on;
   #text(log(r+1)*(1-q)*1 +  (r-1)* log(i), (r-0.01), num2str(i), 'rotation',-90); hold on;
   r = 1;
   t = text(-(log(r+1)*(1-q)*1 + (r-1+1)* log(i)), r+0.01, num2str(i), 'rotation',-90); hold on;
   set(t, 'horizontalAlignment', 'right');
 end

 left = 0;
 top = -0.1;
plot(left,top, "w");
plot(left,1-top, "w");

q = 0.1;
left = 0.4
 for f = [q:0.1:1]
   text(left+log(2*pi*f), 1.2+0.01, num2str(f))
  # text(2.5 - log(2*pi) + log(2*pi*f), 1.2+0.01, num2str(f))
end

# 2.5 1.2
plot(left,1.2, "r");
plot([3 -0.5], [1.2 1.2], 'Color',[0.7 0.7 0.7]);
set(gca,'YTick',0:0.1:1);
 
 
# plot(0*k, k);
# plot(log(k+1), k);
hold off;



few = [0:0.1:1];
many = [0:0.01:1];
