有没有一种系统的方法来绘制正多边形的所有对称轴(带虚线)?这里有一份文件。我希望得到这样的输出:
(抱歉我画得不好)。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, calc}
\begin{document}
\begin{tikzpicture}[scale=3]
\node (a)
[draw, blue!0!black,rotate=90,minimum size=3cm,regular polygon, regular polygon sides=5] at (0, 0) {};
\foreach \x in {1,2,..., 5}
\fill (a.corner \x) circle[radius=.5pt];
\end{tikzpicture}
\begin{tikzpicture}[scale=3]
\node (a)
[draw, blue!0!black,rotate=90,minimum size=3cm,regular polygon, regular polygon sides=6] at (0, 0) {};
\foreach \x in {1,2,..., 6}
\fill (a.corner \x) circle[radius=.5pt];
\end{tikzpicture}
\end{document}
答案1
您可以使用center
和side
锚点 来corner
锚定多边形。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, calc}
\begin{document}
\begin{tikzpicture}[scale=3]
\def\rps{7} % regular polygon sides
\node (a)
[draw, blue!0!black,rotate=90,minimum size=3cm,regular polygon, regular polygon sides=\rps] at (0, 0) {};
\foreach \x in {1,2,...,\rps}
\fill (a.corner \x) circle[radius=.5pt];
\foreach \x in {1,2,...,\rps}{
\draw [red,dashed, shorten <=-0.5cm,shorten >=-0.5cm](a.center) -- (a.side \x);
\draw [red,dashed, shorten <=-0.5cm,shorten >=-0.5cm](a.center) -- (a.corner \x);}
\end{tikzpicture}
\end{document}
对于 n=3
对于 n=4
对于 n=7
答案2
\documentclass[pstricks,preview,border=5mm]{standalone}
\usepackage{pst-node,pst-plot}
\def\N{10}
\degrees[\N]
\begin{document}
\makeatletter
\begin{pspicture}(-4,-4)(4,4)
\pstVerb{/offset 30 def}%
\curvepnodes[plotpoints=\numexpr\N+1\relax]{0}{\N}{3 t \pst@angleunit offset add PtoC}{A}
\psnline[showpoints](0,\N){A}
\multido{\i=0+1}{\N}{\pcline[nodesepB=-10mm,linestyle=dashed,linecolor=red](0,0)(A\i)}
\end{pspicture}
\makeatother
\end{document}