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?

Ruben
  • 13,448
Tobal
  • 805
  • 8
  • 16
  • Time to call \foreach I guess. – Sigur Oct 31 '13 at 17:25
  • This answer was written to help you. – kiss my armpit Oct 31 '13 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 Oct 31 '13 at 17:54
  • @Tobal Where is the w_1 located and what direction do w_2, w_3, etc go? – Alenanno Oct 31 '13 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 Oct 31 '13 at 18:21

3 Answers3

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}
Alenanno
  • 37,338
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

Tobal
  • 805
  • 8
  • 16
  • Do you want to use zero-based index? – kiss my armpit Oct 31 '13 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 Oct 31 '13 at 19:15
  • 1
    @Tobal Want me to update the answer? I realize that the position of the labels is not correct. :D – Alenanno Oct 31 '13 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 Oct 31 '13 at 20:15
  • 1
    See my answer, the position of the root in my answer is correct. – kiss my armpit Oct 31 '13 at 20:27
  • Please, rewrite the code because i suspect you are talking about put the labels in the exactly, exactly place. I know the polygon is correct, or not? Well the polygon is correct – Tobal Oct 31 '13 at 20:39
  • ok, i understand now, tomorrow i'll calculate all the points with octave and i'll fix the problem with the labels, now it's very late in Spain to do that. Thanks!!! – Tobal Oct 31 '13 at 20:52
  • @Marienplatz , I've already fixed the label order in math way ordering. Your PSTRICKS code is very cool!!! Thanks everybody for your help !!!! – Tobal Nov 01 '13 at 10:13
  • You can shorten you loop quite a bit: try \foreach \x in {1,...,11} { \pgfmathtruncatemacro{\l}{mod(\x+4,11)} \pgfmathtruncatemacro{\d}{360/11*(\x-1)+170} \draw[shift=(pol.corner \x)] plot coordinates{(0,0)} node[font=\scriptsize,label=\d: $\omega_{\l}$] {}; } – Tom Bombadil Nov 01 '13 at 11:42