I would like to draw a torus, like the one on the question How to draw a torus, with a 3d package. I would like to avoid drawing the torus in 2d with inkscape (or directly with tikz) because I will need to add other elements (like, say, in 3D helix torus with hidden lines, and view them from different points of view.
However, the resulting figure is to be printed (in black and white, etc.), so I want to use only contour figure, instead of shiny, color-shaded pictures like the ones in 3D helix torus with hidden lines.
In the end, I would like to have something like that (but this one was drawn in 2d with tikz)
So I tried to use asymptote, and, well, with
import solids;
settings.render=0;
settings.prc=false;
size(12cm,0);
currentprojection=orthographic(0,20,10);
real R=3, a=0.8, d=R+2a;
revolution tore=revolution(shift(R*X)*Circle(O,a,Y,32),Z);
draw(tore.silhouette(),black);
i get something like that :
So is there a method to do that without the hideous bug ?
I tried to do it with asymptote, but something else (tikz, sketch, black magic, etc.) would be fine, at least if it gives a vector output. However, I'm not interested in directly drawing the result in 2d (and it has already been done in How to draw a torus).
Thanks in advance.
Best Answer
Update:
This new solution is a bit longer, but overcomes all three difficulties I list for the previous solution (below). In particular, this is a vector graphic.
Since you expressed an interest in imitating a 3D helix with hidden lines, I also produced an example of that (in grayscale vector graphics with no shading):
To compile either of these, first save the following code in a file called
surfacepaths.asy
:To get the first image (with the two circles), in the same directory, run the following
*.asy
code:To get the torus wrapped in a helix, run the following Asymptote code:
Old (rasterized-only) solution:
Here's an Asymptote solution that sort of works.
![enter image description here](https://i.stack.imgur.com/onuRr.png)
Note that as currently formulated, it has the following difficulties:
Anyway, here's the code: