3

My goal was drawing a 90° section of a torus filled with some pattern (dots in this case), such that only the inside and the outside border of the torus are solid lines, but not the artificial lines where the torus was cut. What I tried is in the code section below, but without the desired outcome.

enter image description here

\documentclass{article} 
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{patterns}
\usetikzlibrary{calc}
\usetikzlibrary{arrows.meta}
\begin{document}

\begin{tikzpicture}[scale=5]
\filldraw[pattern=  dots] (-1,0) arc (180:90:1)  (0, 0.9) arc (90:180:0.9);
\end{tikzpicture}

\end{document}

When you change the significant line to

\filldraw[pattern=  dots] (-1,0) arc (180:90:1) -- (0, 0.9) arc (90:180:0.9) -- cycle;

you get what I am looking for, but with two straight lines that I do not want in the picture. Why isn't this working the way I imagine it should and how can I still achieve this effect?

EDIT: I did find solutions that work, but that seem to be unnecessarily verbose or make editing the picture very cumbersome due to much copypasta, like e.g.

\filldpattern=  dots] (-1,0) arc (180:90:1) -- (0, 0.9) arc (90:180:0.9) -- cycle;
\draw[-] (-1,0) arc (180:90:1)  (0, 0.9) arc (90:180:0.9);
3

like this?

enter image description here

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{%arrows.meta, calc, 
                patterns}

\begin{document}

\begin{tikzpicture}[scale=5]
\fill[pattern= dots]        ( 0,0.0) -- (-1,0) arc (180:90:1) -- cycle;
\draw                       (-1,0.0) arc (180:90:1);
\fill[white]                ( 0,0.0) -- (0, 0.9) arc (90:180:0.9) -- cycle;
\draw                       ( 0,0.9) arc (90:180:0.9);
\end{tikzpicture}

\end{document}

addendum: the same result you can obtain with:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{%arrows.meta, calc,
                patterns}

\begin{document}
\begin{tikzpicture}[scale=5]
\fill[pattern= dots]        (-1,0.0) arc (180:90:1) -- (0, 0.9)
                                     arc (90:180:0.9) -- cycle;
\draw                       (-1,0.0) arc (180:90:1);
\draw                       ( 0,0.9) arc (90:180:0.9);
\end{tikzpicture}
\end{document}

as you can see, it differ from yours code, that it connect both arc in one closed curve.

  • Yes this would be a solution. I do however see some disadvantages to a "one liner": It is on the one hand quite verbose, and on the other hand it covers up everything in the sector between the inner arc and (0,0). Do you have an idea why my example does not work the way I imagined? – flawr Nov 1 '17 at 16:20
  • all what you drawing after \fill[white] ` will be visible ... but i provide new example, which is close to what you try to achieve, see addendum in my answer. – Zarko Nov 1 '17 at 17:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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