0

How to plot a donut whose Fig is attached herewith

enter image description here

The donut looks very nice. I want to plot it. The parametric equation of the torus is

$$x = (R + a cos(p)) cos(t);$$ $$y = (R + a cos(p)) sin(t);$$ $$z = a sin(p);$$ where $t,p\in [0, 2\pi]$ How to do that? EDIT: What I have tried is given below:

 \documentclass{article}
    \usepackage[margin=0.5in]{geometry}
    \usepackage[utf8]{inputenc}
    \usepackage{comment}
    
    \usepackage{pgfplots}
    \pgfplotsset{width=10cm, compat=1.16}
    
    \begin{document}
    
    \begin{tikzpicture}
\begin{axis}
    [
    view={60}{30},
    ]
\addplot3[surf,shader=interp,
    domain=0:2*pi,
    p domain=0:2*pi,
    samples=101,
    samples x=2,R=5,a=2
]
({(R + a*cos(deg(p)))*cos(deg(x))},
{(R + a*cos(deg(p)))*sin(deg(x))},{a*sin(deg(x))});
\end{axis}
\end{tikzpicture}
\end{document}
10
  • 1
  • 3
    Do-this-complicated-thing-for-me questions are often less than well-received (unless they involve something cute like a duck). Please show us what you've tried or hire somebody to create your images from scratch, if you don't want to. Also, you shouldn't use $$ in LaTeX and/or MathJax is not enabled on this site.
    – cfr
    Sep 20 at 14:53
  • the codes are not executing \usepackage{pst-solides3d} in overleaf
    – math131
    Sep 20 at 15:22
  • 1
    As I've already explained, that's not how this site works. Frankly, I also think you're bizarrely unappreciative of the many answers you've been directed to, including an entire page of possibilities, many of which I find rather attractive. If you want to create something different, you have to put the time in to learn how to use the tools or put the money up for a professional. Yes, people sometimes get lucky and somebody draws something for them if the question interests them, but something like this is a lot of work. If you put the effort in, people will help when you get stuck.
    – cfr
    Sep 21 at 5:51
  • 1
    Start with something simple. Work through the tutorials in the TikZ manual until you can draw basic stuff. Then you can start looking at TikZ's 3D and plotting stuff or at pgfplots. That's if you want to learn pgf/TikZ. Obviously, if you prefer one of the other tools, you should start there. If you need something quickly \includegraphics is your friend. If you need to modify it, try Inkscape or equivalent. (Inkscape can produce TikZ code, though it is not very wieldy in my experience.)
    – cfr
    Sep 21 at 5:56

0

Browse other questions tagged .