使用多边形常规 tikz 在顶点绘制文本

使用多边形常规 tikz 在顶点绘制文本

我正在尝试绘制由方程引起的正多边形x^(11)+1=0。我用以下代码绘制了多边形和圆周:

\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}

现在,我想将文本添加w_i到第 i 个顶点。我该怎么做?

答案1

更新

我决定更新我的答案,在foreach语句中添加一个计数器。这样,它更加自动化,代码也更短。

在多边形的每个角上添加foreach节点,可以使用corner #(您可以在Tikz 手册,第 229 页),但它在某个角上从 0 开始记下标数字,并在前一个值上加 1。

无论如何,这里是:

圖形像

\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}

答案2

正确的解决方案(从数学角度来看)是使用 PSTricks。我在这里使用了从零开始的索引(因为 OP 想要它)。

\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}

在此处输入图片描述

额外谜题

我为什么要添加到.5? :-)t2 t .5 add \pst@angleunit PtoC

最新编辑

另一种方法看似更复杂,但仍然很有趣!

\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}

答案3

为了更清楚地说明,我按照正确的数学顺序重新排列了顶点的顺序:

\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}

数学标签顺序固定的 11 次单位根正多边形

相关内容