我想画一个八边形,其中没有三条对角线经过同一点。为此,我想画一个不规则的八边形。为什么编译不正确?
\usepackage[svgnames]{xcolor}
\usepackage{tkz-euclide}
\usetkzobj{all}
\begin{document}
\begin{tikzpicture}[scale=.6]
\tkzDefPoint(0,0){O}
\tkzDefPoint(5,0){A}
\tkzDrawCircle(O,A)
\tkzDefPoint({5*cos(75^{\circ})},{5*sin(75^{\circ)}) \tkzGetPoint{P1}
\tkzDefPoint({5*cos(110^{\circ})},{5\sin(110^{\circ)}) \tkzGetPoint{P2}
\tkzDefPoint({5*cos(140^{\circ)},{5*sin(140^{\circ)}) \tkzGetPoint{P3}
\tkzDefPoint({5*cos(190^{\circ)},{5*sin(190^{\circ)}) \tkzGetPoint{P4}
\tkzDefPoint({5*cos(200^{\circ)},{5*sin(200^{\circ)}) \tkzGetPoint{P5}
\tkzDefPoint({5*cos(240^{\circ)},{5*sin(240^{\circ)}) \tkzGetPoinP{P6}
\tkzDefPoint({5*cos(290^{\circ)},{5*sin(290^{\circ)}) \tkzGetPoint{P7}
\tkzDefPoint({5*cos(310^{\circ)},{5*sin(310^{\circ)}) \tkzGetPoint{P8}
\tkzDrawPolygon[color=red!50!Gold,ultra thick](P1,P2,P3,P4,P5,P6,P7,P8)
\tkzDrawPoints[color=red!50!Gold,size=15](P1,P2,P3,P4,P5,P6,P7,P8)
\end{tikzpicture}
\end{document}
答案1
您的代码的主要问题是您将排版语法 ( \circ
, \sin
) 与计算语法混淆了。正如 Sam Carter 在评论中指出的那样,您的括号/圆括号也有些不匹配。点的有效定义是
\tkzDefPoint({5*cos(75)},{5*sin(75)}){P1}
fp
下一个问题是,中的三角函数tkz-euclide
假设以弧度为单位,而您使用以度为单位。
下面是完整的示例。我使用循环来定义点。
\documentclass[border=5mm,svgnames]{standalone}
\usepackage{tkz-euclide}
\usetkzobj{all}
\begin{document}
\begin{tikzpicture}
\tkzDefPoint(0,0){O}
\tkzDefPoint(5,0){A}
\tkzDrawCircle(O,A)
\foreach[count=\i] \ANG in {75,110,140,190,200,240,290,310} {
\tkzDefPoint({5*cos(\ANG*pi/180)},{5*sin(\ANG*pi/180)}){P\i}
}
\tkzDrawPolygon[color=red!50!Gold,ultra thick](P1,P2,P3,P4,P5,P6,P7,P8)
\tkzDrawPoints[color=red!50!Gold,size=15](P1,P2,P3,P4,P5,P6,P7,P8)
\tkzLabelPoints(P1,P2,P3,P4,P5,P6,P7,P8)
\end{tikzpicture}
\end{document}