Graphics, Figures & Tables ⇒ Drawing Diagonals of regular polygon
Drawing Diagonals of regular polygon
This is my code. Any help would be appreciated! More specifically im trying to draw diagonals from A_1 to A_8 etc.
\begin{tikzpicture}
\node (p) [draw,rotate=90,minimum size=10cm,regular polygon, regular polygon sides=9] at (0,0) {};
\draw (0,0) circle (5 cm);
\foreach \n [count=\nu from 1, remember=\n as \lastn, evaluate={\nu+\lastn}] in {1,2,...,9}
\node[anchor=\n*(360/9)]at(p.corner \n){$A_{\nu}$};
\foreach \x in {1,2,...,9}
\fill (p.corner \x) circle[radius=1.5 pt];
\end{tikzpicture}
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
Drawing Diagonals of regular polygon

If the diagonals are allowed to look the same as the sides of the polygon, then a possible solution can be kept quite simple. My suggestion uses percusse's answer:
Code: Select all
\documentclass[tikz]{standalone}
\usetikzlibrary{shapes.geometric}
\begin{document}
\begin{tikzpicture}
\newcommand{\pSides}{9}
\draw
node (p) [
rotate=90,
minimum size=10cm,
regular polygon,
regular polygon sides=\pSides
] {}
circle [radius=5cm]
;
\foreach \n in {1,2,...,\pSides}{
\node[anchor=\n*(360/\pSides)] at (p.corner \n) {$A_{\n}$};
\fill (p.corner \n) circle [radius=1.5pt];
\ifnum\n<\pSides
\foreach\k in {\n,...,\pSides}
\draw (p.corner \n) -- (p.corner \k);
\fi
}
\end{tikzpicture}
\end{document}