如何使用 Tikz 绘制星形,如下图所示
答案1
一个选项;使用重心坐标系来定位节点“G”:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[dotted]
(0,0) coordinate (A) --
(4,1) coordinate (B) --
(4.5,2) coordinate (C) --
(3.8,3) coordinate (D) --
(1.6,4) coordinate (E) --
(-1,1.5) coordinate (F) --
cycle;
\draw[thick]
(B) -- (D) -- (F) -- cycle;
\draw[dashed]
(A) -- (C) -- (E) -- cycle;
\foreach \Coor/\Texto/\Pos in
{A/q/below,
B/b/below,
C/r/right,
D/c/right,
E/p/above,
F/a/left%
}
\node[circle,draw,inner sep=1.5pt,fill=white,label={\Pos:$\Texto$}]
at (\Coor) {};
\node[fill,circle,inner sep=1.5pt,label={right:$G$}]
at (barycentric cs:A=0.5,B=0.5,C=0.5,D=0.5,E=0.5,F=0.5) {};
\end{tikzpicture}
\end{document}
答案2
仅用于 PSTricks 的打字练习。该点G
是最外层多边形的质心。
\documentclass[pstricks,border=24pt,12pt]{standalone}
\usepackage{pst-eucl}
\begin{document}
\begin{pspicture}[showgrid=false](6,6)
\pstGeonode[PosAngle={180,90,45,0,-45,-135},CurveType=polygon,linestyle=dotted,dotsep=0.4pt]
(0,3){a}
(3,6){p}
(5,5){c}
(6,3){r}
(5.5,1){b}
(1,0){q}
\nodexn{(a)+(b)+(c)+(p)+(q)+(r)}{g}
\pstGeonode(!\psGetNodeCenter{g} g.x 6 div g.y 6 div){G}
\pspolygon(a)(b)(c)
\pspolygon[linestyle=dashed](p)(q)(r)
\foreach \pt in {a,b,c,p,q,r}{\psset{fillcolor=white,fillstyle=solid}\pscircle(\pt){2pt}}
\end{pspicture}
\end{document}