7

I'm trying plot the regular polygon induced by the equation x^(11)+1=0. I've drawn the polygon and the circunference with this code:

\documentclass[a4paper]{article}

\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}


\begin{document}

\begin{tikzpicture}[scale=3]
\draw [very thick,<->] (-1.5,0)--(1.5,0);
\draw [very thick,<->] (0,-1.5)--(0,1.5);
\draw[thick,red!90!black] (0,0) circle (1cm);
\node [draw, thick, blue!90!black,rotate=90,minimum size=6cm,regular polygon, regular polygon sides=11] at (0,0) {};    

\end{tikzpicture}
\end{document}

Now, I want to add the text w_i to the i-th vertex. How can I do it?

5
  • Time to call \foreach I guess.
    – Sigur
    Commented Oct 31, 2013 at 17:25
  • This answer was written to help you. Commented Oct 31, 2013 at 17:26
  • Mmmm... that would be very boring, Doesn't exist an option using regular polygon to refer explicitly to vertices of a regular polygon? I've read the official TIKZ in regular polygon section but it cannot put any reference about this.
    – Tobal
    Commented Oct 31, 2013 at 17:54
  • @Tobal Where is the w_1 located and what direction do w_2, w_3, etc go?
    – Alenanno
    Commented Oct 31, 2013 at 18:06
  • w_1 is the first vertex of the polygon, the exactly position is very difficult to know, but it must be located in (cos(pi/11),sin(pi/11)) and so on. But with Polygon Regular tikz option i don't use this Euler formula because I only plot a regular polygon centered in (0,0) with 11 sides and then i've rotated 90 degrees, this is the phase angle. I've written that I've drawn the regular polygon of all solutions of x^11+1=0 equation.
    – Tobal
    Commented Oct 31, 2013 at 18:21

3 Answers 3

7

Updated

I've decided to update my answer by adding a counter to the foreach statement. This way it is much more automatized and the code is shorter.

The foreach adds the nodes at each corner of the polygon, which can be referred to using corner # (you can find this in the Tikz Manual, page 229), but it starts the subscript number from 0 at a certain corner and adds 1 to the previous value.

Anyway, here it is:

graph image

\documentclass[border=1cm]{standalone}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, calc}

\begin{document}
\begin{tikzpicture}[scale=3]
\draw [very thick,<->] (-1.5,0)--(1.5,0);
\draw [very thick,<->] (0,-1.5)--(0,1.5);
\draw[thick,red!90!black] (0,0) circle (1cm);

\node (pol) [draw, thick, blue!90!black,rotate=90,minimum size=6cm,regular polygon, regular polygon sides=11] at (0,0) {}; 

\foreach \n [count=\nu from 0, remember=\n as \lastn, evaluate={\nu+\lastn}] in {7,8,...,10,11,1,2,...,5,6} 
\node[anchor=\n*(360/11)]at(pol.corner \n){$\omega_{\nu}$};

\end{tikzpicture}
\end{document}
12
  • 2
    Use w_{10} and w_{11}. Commented Oct 31, 2013 at 18:23
  • @Marienplatz Thank you! Why was it behaving like that?
    – Alenanno
    Commented Oct 31, 2013 at 18:26
  • 1
    Because of the need of grouping. :-) Commented Oct 31, 2013 at 18:28
  • 1
    In this case, acceptable results can be obtained by using \foreach\n in{1,...,11}\node[anchor=\n*(360/11)]at(pol.corner \n){$\omega_{\n}$}; Commented Nov 1, 2013 at 10:33
  • 1
    @Tobal I've updated my answer with a slightly better solution (still using the foreach but with a counter) and I fixed the labels. :)
    – Alenanno
    Commented Nov 1, 2013 at 16:02
6

The correct solution (from mathematics point of view) with PSTricks. I used zero-based index here (because the OP wants it).

\documentclass[pstricks,border=12pt,12pt]{standalone}
\usepackage{pst-node,pst-plot}

\makeatletter

\def\Atom#1{%
\begin{pspicture}(-3,-3)(3,3)
    \psaxes[labels=none,ticks=none,linecolor=lightgray!50](0,0)(-3,-3)(3,3)
    \pscircle[dimen=m,linecolor=lightgray]{2}
    \degrees[#1]
    \curvepnodes[plotpoints=\numexpr#1+1]{0}{#1}{2 t .5 add \pst@angleunit PtoC}{P}  
    \psnline[linecolor=blue](0,\Pnodecount){P}
    \multido{\i@=0+1}{\Pnodecount}{\qdisk(P\i@){2pt}\uput{2.2}[(P\i@)](0,0){$\omega_{#1}^{\i@}$}}
\end{pspicture}}

\makeatother

\begin{document}
    \multido{\i=1+1}{12}{\Atom{\i}}
\end{document}

enter image description here

A bonus puzzle

Why did I add .5 to t in 2 t .5 add \pst@angleunit PtoC? :-)

Latest edit

Another method that seems to be more complicated but it is still fun!

\documentclass[pstricks,border=12pt,12pt]{standalone}
\usepackage{pst-eucl,pst-plot}

\psset{CurveType=polygon}

\makeatletter
\def\Atom#1{%
\begin{pspicture}[showgrid=false](-3,-3)(3,3)
  \psaxes[labels=none,ticks=none,linecolor=lightgray!50](0,0)(-3,-3)(3,3)
    \pscircle[linecolor=red]{2}
    \degrees[#1]
    \def\points{}\def\names{}\def\angles{}
    \multido{\i@=0+1,\n@=.5+1.0}{#1}
    {
        \xdef\points{\points(!2 \n@\space \pst@angleunit PtoC){A\i@}}
        \xdef\names{\names \omega_{\i@},}
        \xdef\angles{\angles \n@,}
    }
    \edef\args{[PointName={\names},PosAngle={\angles}]\points}
    \expandafter\pstGeonode\args
\end{pspicture}}
\makeatother

\begin{document}
\multido{\i=1+1}{12}{\Atom{\i}}
\end{document}
0

Only for more clearly I've rearrenged the order of vertices in the correct mathematical order:

\documentclass[border=1cm]{standalone}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, calc}


\begin{document}
\begin{tikzpicture}[scale=3]
\draw [very thick,<->] (-1.5,0)--(1.5,0);
\draw [very thick,<->] (0,-1.5)--(0,1.5);
\draw[thick,red!90!black] (0,0) circle (1cm);

\node (pol) [draw, thick, blue!90!black,rotate=90,minimum size=6cm,regular polygon, regular polygon sides=11] at (0,0) {}; 

\foreach \anchor/\label/\placement in
    {corner 1/$w_5$/above left, 
     corner 2/$w_6$/left, 
     corner 3/$w_7$/left, 
     corner 4/$w_8$/below,
     corner 5/$w_9$/below,   
     corner 6/$w_{10}$/right,
     corner 7/$w_0$/right,
     corner 8/$w_1$/above,
     corner 9/$w_2$/above,
     corner 10/$w_3$/above,
     corner 11/$w_4$/above}
\draw[shift=(pol.\anchor)] plot coordinates{(0,0)}
node[font=\scriptsize,\placement] {\label};

\end{tikzpicture}
\end{document}

regular polygon of 11-th unity-roots with math label order fixed

9
  • Do you want to use zero-based index? Commented Oct 31, 2013 at 19:09
  • Yep! In my own latex document (a pdf book) it has got the right meanning, because I'm using the Euler formula to explain how to calculate the unity's nth-roots
    – Tobal
    Commented Oct 31, 2013 at 19:15
  • 1
    @Tobal Want me to update the answer? I realize that the position of the labels is not correct. :D
    – Alenanno
    Commented Oct 31, 2013 at 19:29
  • I don't understand you very well, can you explain more, please? The order of the labels is the correct, the position? please type the code cuz it's very difficult to me understand you, i don't speak english ;-)
    – Tobal
    Commented Oct 31, 2013 at 20:15
  • 1
    See my answer, the position of the root in my answer is correct. Commented Oct 31, 2013 at 20:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .