1

I need to create this tikzpicture enter image description here It was taken from A Homomorphic Encryption Illustrated Primer. All I have managed to create so far was this

arc

using this code

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

\begin{document}
\begin{tikzpicture}
    % Create equidistant points and arc
    \foreach \x [count=\p] in {0,...,11} {
        \node[shape=circle,fill=black, scale=0.5] (\p) at (-\x*30:2) {};
    };

    % Create labes with numbers starting from 0
    \foreach \x [count=\p] in {0,...,11} {
        \draw (-\x*30:2.4) node {\x};
    };

    % Draw the arrow
    \draw[->,>=stealth',thick, blue!60!black] (212:2) arc[radius=2, start angle = 212, end angle = 90];
    \node at (0,0){TEXT};
    \end{tikzpicture}
\end{document}

I've searched in the direction of creating a torus but I'm still nowhere close to my Need.

TalG
  • 113
  • 4
  • from 113 hits on this site alone I see one of these as close to what you may want https://tex.stackexchange.com/questions/400810/tikz-draw-a-wireframe-torus –  Mar 23 '19 at 13:19

1 Answers1

2

This does something of that sort. If you add more explanation, it might be possible to improve it.

\documentclass[border=3.14mm,tikz]{standalone}
\usepackage{tikz-3dplot} 
\usetikzlibrary{3d,decorations.markings}
\begin{document}
\tdplotsetmaincoords{60}{2}
\begin{tikzpicture}[tdplot_main_coords]
\def\r{2}
\def\R{5}
 \foreach \X in {0,...,15}
 {\tdplotsetrotatedcoords{-\X*360/16}{0}{0}
  \begin{scope}[tdplot_rotated_coords] 
   \begin{scope}[canvas is yz plane at x=0] %,transform shape
    \draw[postaction={decorate,decoration={markings,
    mark=between positions 0 and 1 step 0.05 with {%
    \pgfmathtruncatemacro{\itest}{\pgfkeysvalueof{/pgf/decoration/mark
    info/sequence number}}
    \ifnum\itest=20
      \fill[green] (0,0) coordinate(p\X-\itest) circle[radius=2pt];
    \else
      \fill[gray] (0,0) coordinate(p\X-\itest) circle[radius=2pt];
    \fi}}},rotate=18] (\R,0) node{$x^{\X}$} circle[radius=\r];
   \end{scope}
  \end{scope}}
  \fill[red] (p14-2) circle[radius=2pt];
  \draw[red,thick,-latex] plot[smooth,variable=\x,samples at={14,15,0,1,2}] (p\x-2); 
  \fill[red] (p2-2) circle[radius=2pt];
  \draw[red,thick,-latex] plot[smooth,variable=\x,samples at={2,1,20,19}] (p2-\x); 
\end{tikzpicture}
\end{document} 

enter image description here

EDIT: Made the green circle in the foreground visible, as suggested by KJO.

  • But :-) it does not have the same errors as the original :-) and there is one green dot missing :-( –  Mar 23 '19 at 15:22
  • @KJO Well, I can't do much about the errors but the green dot is not missing but hidden behind a gray one. –  Mar 23 '19 at 15:31
  • third dot up at the bottom should be visibly green in foreground hiding the grey one –  Mar 23 '19 at 15:43
  • 1
    @marmot thank you very much it is very close to what I need. I'll be playing with your example to get what I need. – TalG Mar 23 '19 at 16:46
  • @marmot is there a way to change the number of points in the smaller circles? – TalG Mar 23 '19 at 22:41
  • @TalG Yes. Everything is in mark=between positions 0 and 1 step 0.05 with. If you increase/decrease the step size, you get less/more circles. You may have to adjust the number 20 in \ifnum\itest=20 as well, as this indicates which circle goes green. –  Mar 23 '19 at 23:11
  • @marmot thanks it worked. I've changed the value before but I didn't notice any change. I guess my new value wasn't different enough from the old one. – TalG Mar 23 '19 at 23:41
  • @marmot do you know why setting \ifnum\itest=1 doesn't highlight all the 1st points in green? – TalG Mar 24 '19 at 17:53
  • @TalG There is a chance it gets overpainted by the last one. mark=between positions 0 and 1 step ... tells TikZ to also add a mark at position 1, which is the same as 0 on a circle, if the 1/step is an integer. Note that sometimes the last decoration may get swallowed. –  Mar 24 '19 at 17:57
  • @marmot I used the suggested dirty hack in your link to change mark=between positions 0 and 1 into mark=between positions 0 and 0.9997 – TalG Mar 24 '19 at 18:17