torus-three-paths.tex 1.3 KB

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