Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

📚 The CoCalc Library - books, templates and other resources

132932 views
License: OTHER
1
\documentclass[margin=1cm]{standalone}
2
\usepackage{asymptote}
3
\begin{document}
4
\begin{asy}
5
settings.render = 0;
6
settings.prc = false;
7
8
import graph3;
9
import contour;
10
size3(8cm);
11
12
currentprojection = orthographic(10,1,4);
13
defaultrender = render(merge = true);
14
15
// create torus as surface of rotation
16
int umax = 40;
17
int vmax = 40;
18
surface torus = surface(Circle(c=2Y, r=0.6, normal=X, n=vmax), c=O, axis=Z, n=umax);
19
torus.ucyclic(true);
20
torus.vcyclic(true);
21
22
pen meshpen = 0.3pt + gray;
23
24
draw(torus, surfacepen=material(diffusepen=white+opacity(0.6), emissivepen=white));
25
for (int u = 0; u < umax; ++u)
26
draw(torus.uequals(u), p=meshpen);
27
for (int v = 0; v < vmax; ++v)
28
draw(graph(new triple(real u) {return torus.point(u,v); }, 0, umax, operator ..),
29
p=meshpen);
30
31
pair a = (floor(umax/2) + 2, 3);
32
dot(torus.point(a.x, a.y), L="$a$", align=W);
33
pair b = (5, floor(vmax/2));
34
dot(torus.point(b.x, b.y), L="$b$", align=2Z + X);
35
36
path3 abpath(int ucycles, int vcycles) {
37
pair bshift = (ucycles*umax, vcycles*vmax);
38
triple f(real t) {
39
pair uv = (1-t)*a + t*(b+bshift);
40
return torus.point(uv.x, uv.y);
41
}
42
return graph(f, 0, 1, operator ..);
43
}
44
45
real linewidth = 0.8pt;
46
47
draw(abpath(0,0), p=linewidth + orange);
48
draw(abpath(1,0), p=linewidth + red);
49
draw(abpath(1,-1), p=linewidth + darkgreen);
50
\end{asy}
51
\end{document}
52
53