SmtC: Show me the Code
Ole Peter Smith
Instituto de Matemática e Estatística
Universidade Federal de Goiás
http://www.olesmith.com.br

TikZ Examples
Whom takes fun only as fun.
And serious only seriously.
Misunderstood both.
Piet Hein
< Lines | Polygone | Polygones >

Regular Polygon - Polar Coordinates:

In TiKZ
  • $(\Angle:\Dist)$
  • $(C)+(\Angle:\Dist)$
TiKZ Listing: Polygon.tikz.tex. PDF   PNG   SVG   ZIP*  
\begin{tikzpicture}[scale=1]
  %Center and Radius
  \coordinate (C) at (0,0);
  \tikzmath{\R=2;};
  
  %Number of Nodes
  \tikzmath{\N=8;};

  %Angles
  \tikzmath{\PIs=360;};
  \tikzmath{\dAngle=\PIs/\N;};
  
  \filldraw (C) circle(1pt);
  
  \foreach \i in { 1,...,\N }
  {
      \tikzmath{\AngleA=(\i-1)*\dAngle;};
      \tikzmath{\AngleB=\i*\dAngle;};

      \coordinate (P1) at ($(C)+(\AngleA:\R)$);
      \coordinate (P2) at ($(C)+(\AngleB:\R)$);

      \draw (P1) -- (P2);

      %Text centered in points
      %\filldraw ($(C)!1.15!(P1)$) circle(1pt) node {$P_\i$};
      \filldraw (P1) circle(1pt);
      \filldraw ($(C)!1.15!(P1)$) node {$P_\i$};
   }
\end{tikzpicture}


< Lines | Polygone | Polygones >
Messages:
0 secs.