summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/asymptote/examples/electromagnetic.asy
blob: d229f76b74826493e96fd4f360025614d7720f31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import graph; 
import palette;
texpreamble("\usepackage[amssymb,thinqspace,thinspace]{SIunits}"); 
 
size(800,200); 
 
real c=3e8;
real nm=1e-9;
real freq(real lambda) {return c/(lambda*nm);} 
real lambda(real f) {return c/(f*nm);} 
 
real fmin=10; 
real fmax=1e23; 
 
scale(Log(true),Linear(true)); 
xlimits(fmin,fmax); 
ylimits(0,1); 
 
real uv=freq(400);
real ir=freq(700);
 
bounds visible=bounds(Scale(uv).x,Scale(ir).x);
palette(visible,uv,ir+(0,2),Bottom,Rainbow(),invisible);

xaxis(Label("\hertz",1),Bottom,RightTicks,above=true); 
 
real log10Left(real x) {return -log10(x);}
real pow10Left(real x) {return pow10(-x);}

scaleT LogLeft=scaleT(log10Left,pow10Left,logarithmic=true);

picture q=secondaryX(new void(picture p) { 
    scale(p,LogLeft,Linear); 
    xlimits(p,lambda(fmax),lambda(fmin));
    ylimits(p,0,1); 
    xaxis(p,Label("\nano\metre",1,0.01N),Top,LeftTicks(DefaultLogFormat,n=10)); 
  }); 
 
add(q,above=true); 

margin margin=PenMargin(0,0);
draw("radio",Scale((10,1))--Scale((5e12,1)),S,Arrow); 
draw("infrared",Scale((1e12,1.75))--Scale(shift(0,1.75)*ir),LeftSide,Arrows,margin);
draw("UV",Scale(shift(0,1.75)*uv)--Scale((1e17,1.76)),LeftSide,Arrows,margin);
draw("x-rays",Scale((1e16,1))--Scale((1e21,1)),RightSide,Arrows); 
draw("$\gamma$-rays",Scale((fmax,1.75))--Scale((2e18,1.75)),Arrow);