Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
    
Time to call \foreach I guess. –  Sigur Oct 31 '13 at 17:25
    
This answer was written to help you. –  Please don't touch 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 Answers 3

up vote 5 down vote accepted

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}
share|improve this answer
2  
Use w_{10} and w_{11}. –  Please don't touch Oct 31 '13 at 18:23
    
@Marienplatz Thank you! Why was it behaving like that? –  Alenanno Oct 31 '13 at 18:26
1  
Because of the need of grouping. :-) –  Please don't touch Oct 31 '13 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}$}; –  Mark Wibrow Nov 1 '13 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 Nov 1 '13 at 16:02

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}
share|improve this answer

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

share|improve this answer
    
Do you want to use zero-based index? –  Please don't touch 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. –  Please don't touch Oct 31 '13 at 20:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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