我想要画一个五角星,如下图所示。
我使用了以下命令:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{center}
\begin{tikzpicture}[scale=0.3]
\draw[ultra thick,shift={(0,0)},rotate=18] (3.86,11.90)--(-10.12,-7.35);
\draw [ultra thick,shift={(0,0)},rotate=18] (3.86,11.90)--(3.86,-11.90);
\draw [ultra thick,shift={(0,0)},rotate=18] (-10.12,7.35)--(3.86,-11.90);
\draw [ultra thick,shift={(0,0)},rotate=18] (-10.12,7.35)--(12.51,0);
\draw [ultra thick,shift={(0,0)},rotate=18] (-10.12,-7.35)--(12.51,0);
\end{tikzpicture}
\end{center}
\end{document}
如何完成这个图形?
答案1
我不知道如何完成它,但它非常简单,pstricks
无需与顶点坐标作斗争:
\documentclass[border=53pt, svgnames]{standalone}
\usepackage{pst-poly, pst-eucl}
\usepackage{auto-pst-pdf} %% to compile with pdflatex -shell-escape TeXLive, MacTeX)
%% or pdflatex --enable-write18 (MiKTeX)
\begin{document}
\psset{unit=2cm, dimen=inner, linejoin=1}
\begin{pspicture}
\PstStarFive[PolyName=A]
\uput[r](A1){A} \uput[u](A2){B}
\uput[l](A3){C}\uput[dl](A4){D} \uput[dr](A5){E}
\psset{PointSymbol=none}
\pstInterLL[ PosAngle=180]{A2}{A4}{A3}{A5}{I}
\pstInterLL{A1}{A4}{A2}{A5}{J}
\pstInterLL[PosAngle=40]{A1}{A3}{A2}{A5}{K}
\pspolygon[linestyle=none, fillstyle=solid, fillcolor=LimeGreen!60!YellowGreen!35!](A1)(A3)(I)(J)
\psline(J)(A1)(A3)(I)
\psline[linewidth=0.4pt](K)(I)(J)
\end{pspicture}
\end{document}
答案2
这是使用相对极坐标的 TikZ 解决方案。星形定义了每个尖端和角的坐标,可用于以后的绘图。
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{center}
\begin{tikzpicture}
\pgfmathsetmacro{\ct}{3} % distance center to tip
\pgfmathsetmacro{\cc}{\ct*sin(18)/sin(126)} % distance center to corner (sine rule)
% star
\draw[ultra thick] (0,0)
+(90-0*36:\ct) coordinate(T1)
foreach[evaluate=\x as \nc using int((\x+1)/2), % number for corner coordinates
evaluate=\x as \nt using int((\x+1)/2+1)] % number for tip coordinates
\x in {1,3,...,9}{
-- +(90-\x*36:\cc) coordinate(C\nc) -- +({90-(\x+1)*36}:\ct) coordinate(T\nt)}
-- cycle;
\node[above=1cm] at (T1) {star only};
% star
\draw[ultra thick] (7,0)
+(90-0*36:\ct) coordinate(T1)
foreach[evaluate=\x as \nc using int((\x+1)/2), % number for corner coordinates
evaluate=\x as \nt using int((\x+1)/2+1)] % number for tip coordinates
\x in {1,3,...,9}{
-- +(90-\x*36:\cc) coordinate(C\nc) -- +({90-(\x+1)*36}:\ct) coordinate(T\nt)}
-- cycle;
% the rest
\draw[ultra thick] (C2) -- (C3) -- (C4);
\draw[ultra thick,fill=green] (T5) -- (C1) -- (C4) -- cycle;
\draw[ultra thick,fill=green] (C4) -- (C1) -- (T2) -- (C2) -- (C4);
\node[above=1cm] at (T1) {complete};
\end{tikzpicture}
\end{center}
\end{document}