summaryrefslogtreecommitdiff
path: root/graphics/asymptote/examples/RiemannSphere.asy
blob: ec1ab7586a9b3a5b500c2f7ac253d44882a62e56 (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 graph3;
import solids;

currentlight=White;
defaultrender.merge=true;

size(10cm,0);

pair k=(1,0.2);
real r=abs(k);
real theta=angle(k);

real x(real t) { return r^t*cos(t*theta); }
real y(real t) { return r^t*sin(t*theta); }
real z(real t) { return 0; }

real u(real t) { return x(t)/(x(t)^2+y(t)^2+1); }
real v(real t) { return y(t)/(x(t)^2+y(t)^2+1); }
real w(real t) { return (x(t)^2+y(t)^2)/(x(t)^2+y(t)^2+1); }

real nb=3;
for (int i=0; i<12; ++i) draw((0,0,0)--nb*(Cos(i*30),Sin(i*30),0),yellow);
for (int i=0; i<=nb; ++i) draw(circle((0,0,0),i),lightgreen+white);


path3 p=graph(x,y,z,-200,40,operator ..);
path3 q=graph(u,v,w,-200,40,operator ..);

revolution sph=sphere((0,0,0.5),0.5);
draw(surface(sph),green+white+opacity(0.5));

draw(p,1bp+heavyred);
draw(q,1bp+heavyblue);

triple
	A=(0,0,1),
	B=(u(40),v(40),w(40)),
	C=(x(40),y(40),z(40));

path3 L=A--C;
draw(L,1bp+black);

pen p=fontsize(8pt);

dot("$(0,0,1)$",A,N,p);
dot("$(u,v,w)$",B,E,p);
dot("$(x,y,0)$",C,E,p);