1

How could I draw, using tikz, a regular heptagon of area 7 sq.units?

1
  • 1
    What have you tried so far? Please show us that code ...
    – Mensch
    Sep 22 '21 at 15:54
5

A quick search points to shapes.geometric. I let you do the math to find the appropriate radius ;-)

enter image description here

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{shapes.geometric}

\begin{document}

{\def\PolyRadius{2cm}
  \begin{tikzpicture}
    % Remove next line to remove the red circle
    \draw[red] (0,0) circle [radius=\PolyRadius];
    \node[regular polygon,draw,regular polygon sides = 7,minimum size=2*\PolyRadius] at (0,0) {};
  \end{tikzpicture}
}

\end{document}
6

For regular polygon of n sides with area S, length from center to a vertex r, we have the formula

enter image description here

The TikZ code is using foreach inside one \draw command. The unit here is cm - the default unit of TikZ.

enter image description here

\documentclass[tikz,border=5mm]{standalone}
\usepackage{amsmath}
\begin{document}
% for maths
\begin{tikzpicture}
\node{$S=\dfrac{nr^2\sin\left(\frac{360}{n}\right)}{2}$ \quad implies\quad $r=\sqrt{\dfrac{2S}{n\sin\left(\frac{360}{n}\right)}}$};
\end{tikzpicture}

\begin{tikzpicture}
\def\n{7}    % number of sides of a heptagon
\def\S{7}    % the area of that heptagon
\pgfmathsetmacro{\k}{360/\n}
\pgfmathsetmacro{\r}{(sqrt(2*\S))/(\n*sin(\k))}
\draw[violet] (90:\r) 
foreach \i[parse=true] in {1,...,\n-1}  {--({90+\k*\i}:\r)}--cycle;
\end{tikzpicture}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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