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
O bem que a violência faz, é - sempre - passageiro.
O mal que ela faz, é permanente.
Mahatma Gandhi
< Polygone | Polygones | Circle >

More Polygons

Reusing Code in file, Draw.tikz.tex, Drawing the Polygin:
TiKZ Listing: Draw.tikz.tex. PDF   PNG   SVG   ZIP*  
%Must be defined:
%   Center: (C)
%   Radius: \R
%   Starting Angle: \Angle
%   No of Points: \N


%Angles
\tikzmath{\dAngle=360/\N;};
  
\filldraw (C) circle(1pt);

\draw ($(C)+(0,-1.1*\R)$)  node [below] {$\N$};

\foreach \i in { 1,...,\N }
{
    \tikzmath{\AngleA=\Angle+(\i-1)*\dAngle;};
    \tikzmath{\AngleB=\Angle+\i*\dAngle;};

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

    \draw (C) -- (P1) -- (P2);
    \filldraw (P1) circle(1pt);
}
Include:
TiKZ Listing: Polygons.tikz.tex. PDF   PNG   SVG   ZIP*  
\begin{tikzpicture}[scale=1]
  %Center and Radius
  \coordinate (C) at (0,0);
  \tikzmath{\R=2;};
  \tikzmath{\F=2.5;};
  
  \tikzmath{\NStart=3;};
  \tikzmath{\NRows=3;};
  \tikzmath{\NCols=3;};
  
  %Rotations
  \tikzmath{\dAngle=10;};
  
  %Number of Polygones
  \tikzmath{\NIni=3;};
  \tikzmath{\NFin=8;};

  \foreach \nr in { 1,...,\NRows }
  {
     \foreach \nc in { 1,...,\NCols }
     {
         \tikzmath{\N=(\nr-1)*\NCols+\nc-1);};
         \tikzmath{\N=\N+\NStart;};

         %Move center
         \coordinate (C) at (\F*\nc*\R,-\F*\nr*\R);

         %Rotate
         \tikzmath{\Angle=\N*\dAngle;};
             
         \input{Draw.tikz}
     }
  }
\end{tikzpicture}


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