1

I have the following MWE that evenly distributes \n dots around a circle of some \radius:

MWE

\documentclass[tikz]{standalone}
\usepackage{pgf}
\usetikzlibrary{arrows,shapes,backgrounds} 
\usepackage{xcolor}

\definecolor{RoyalAzure}{rgb}{0.0, 0.22, 0.66}
\pgfplotsset{compat=1.16}
\begin{document} 
    \begin{tikzpicture}
            \def \n {4}
            \def \radius {3}
            \draw[dashed] circle(\radius);
            \filldraw[color = RoyalAzure] 
                  foreach \s in{1,...,\n}{
                     [color =  black] (-360/\n*\s:-\radius)circle(1.7pt)
                      node[anchor=-360/\n*(\s)]{$g^{\s}$}
                  }; 
    \end{tikzpicture}
\end{document}

This generates the following image:

constellation

How can I relabel the nodes such that $g^0$ starts from the positive $x$-axis (i.e. at 0 angle) and iterates with increasing angle?

Sid
  • 1,806

1 Answers1

3

Clockwise rotation:

\documentclass[tikz]{standalone}
\usepackage{xcolor}

\definecolor{RoyalAzure}{rgb}{0.0, 0.22, 0.66}

\begin{document}

\begin{tikzpicture}
  \def\n{4}
  \def\radius{3}
  \draw[dashed] circle[radius=\radius];
  \filldraw[color=RoyalAzure]
    foreach \s in {0,...,\numexpr\n-1\relax} {
      (-360/\n*\s:\radius) circle[radius=1.7pt]
      node[color=black, anchor=360/\n*\s] {$g^{\s}$}
    };
\end{tikzpicture}

\end{document}

screenshot

Anti-clockwise rotation (only one minus sign to remove):

\documentclass[tikz]{standalone}
\usepackage{xcolor}

\definecolor{RoyalAzure}{rgb}{0.0, 0.22, 0.66}

\begin{document}

\begin{tikzpicture}
  \def\n{4}
  \def\radius{3}
  \draw[dashed] circle[radius=\radius];
  \filldraw[color=RoyalAzure]
    foreach \s in {0,...,\numexpr\n-1\relax} {
      (360/\n*\s:\radius) circle[radius=1.7pt]
      node[color=black, anchor=360/\n*\s] {$g^{\s}$}
    };
\end{tikzpicture}

\end{document}

screenshot

Note: I converted circle(\radius) and circle(1.7pt) to the new syntax circle[radius=〈radius〉], because the old syntax circle (〈radius〉) is deprecated and may cause problems (at least with pgfplots, see Drawing circles within an axis of pgfplots for instance).

frougon
  • 24,283
  • 1
  • 32
  • 55
  • I converted the examples to use the new syntax for the circle operation, namely circle[radius=〈radius〉]. You should reflect this change in your code in order to avoid problems in the future. – frougon Jan 27 '20 at 17:17