9
$\begingroup$

Three attempts at drawing a torus

All 3 images are produced using ParametricPlot3D The left example is produced with no extra options. Note that the black lines, which is all I really want to see, cut in and out and are not connected. In the right example, the colors are gone, but the mesh lines are still broken up and the picture looks terrible. In the middle frame, I've tried changing the PlotStyle so the faces are only 0.8 opaque. This helps, but I don't want the surface to be transparent. How can I draw a simple black and white mesh picture of a torus?

Code for middle picture:

SetOptions[ParametricPlot3D,
    Axes->False,
    Boxed->False,
    Mesh->20,
    Lighting -> {White},
    PlotStyle->FaceForm[{White,Opacity[0.8]}]
    ]
 ParametricPlot3D[
    {Cos[u]*(Sqrt[2]+Cos[t]), Sin[u]*(Sqrt[2]+Cos[t]),Sin[t]
    },
    {u,0,2Pi},{t,0,2Pi}]
$\endgroup$
6
  • $\begingroup$ adding the options PlotStyle->None, Mesh -> {20, 20} and BoundaryStyle -> Black seems to work in v9 (windows 10) and v11.3 (wolfram cloud). $\endgroup$
    – kglr
    Jul 31, 2018 at 3:18
  • $\begingroup$ @kgir Those options yield a transparent torus (for me), not an opaque one (my goal). Can you post your image? $\endgroup$
    – edgeloss
    Jul 31, 2018 at 3:35
  • $\begingroup$ edgeloss, sorry i missed your requirement. Do the options PlotStyle -> White, and Lighting -> "Neutral" help? $\endgroup$
    – kglr
    Jul 31, 2018 at 3:41
  • $\begingroup$ Unfortunately not. $\endgroup$
    – edgeloss
    Jul 31, 2018 at 3:59
  • $\begingroup$ What version of Mathematica and what hardware are you using under what operating system? $\endgroup$ Jul 31, 2018 at 8:12

1 Answer 1

21
$\begingroup$

I think you can do this:

ParametricPlot3D[{Cos[u]*(Sqrt[2] + Cos[t]), 
  Sin[u]*(Sqrt[2] + Cos[t]), Sin[t]}, {u, 0, 2 Pi + Pi/10}, {t, 0, 
  2 Pi + Pi/10}, Axes -> False, Boxed -> False, Mesh -> 20, 
  PlotStyle -> Glow[White], MeshStyle -> Thick, 
  PlotPoints -> 100]

torus

The main point is is to use Glow in the PlotStyle option to make the white surface independent of the lighting.

I also added a fix for another annoying shortcoming: the Mesh lines are drawn at subdivisions of the periodicity interval that leave a gap, unless you extend the parameter ranges by one interval size ($2\pi/n$ where $n$ is the number specified in the Mesh option).

Finally, I increased PlotPoints to make the lines smoother.

Instead of extending the parameter intervals, you can also fix the gaps in the mesh lines by adding BoundaryStyle:

ParametricPlot3D[{Cos[u]*(Sqrt[2] + Cos[t]), 
  Sin[u]*(Sqrt[2] + Cos[t]), Sin[t]}, {u, 0, 2 Pi}, {t, 0, 2 Pi}, 
 Axes -> False, Boxed -> False, Mesh -> 20, PlotStyle -> Glow[White], 
 MeshStyle -> Thick, PlotPoints -> 100, BoundaryStyle -> Thick]

The ends of the torus surface in the given parametrization are considered a boundary curve and therefore don't get a mesh line. The BoundaryStyle -> Thick option adds lines where the mesh is missing.

$\endgroup$
2
  • $\begingroup$ g= ParametricPlot3D[{Cos[u]*(Sqrt[2] + Cos[t]), Sin[u]*(Sqrt[2] + Cos[t]), Sin[t]}, {u, 0, 2 Pi + Pi/10}, {t, 0, 2 Pi + Pi/10}, Axes -> False, Boxed -> False, Mesh -> 20, PlotStyle -> Glow[White], MeshStyle -> Thick, PlotPoints -> 100] Works well, except when I try Export["pic.pdf",g] the image is as attached. i.stack.imgur.com/tsd14.png $\endgroup$
    – edgeloss
    Jul 31, 2018 at 5:47
  • $\begingroup$ @edgeloss. If I export to pdf, MMA 11.3 give me a nice torus.On Windows 8.1 64 bit.Jens code works perfect. $\endgroup$ Jul 31, 2018 at 8:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.