使用 tikz 在 for 循环中连接点

使用 tikz 在 for 循环中连接点
\documentclass{article}
\usepackage{tikz}

\begin{document}
    \begin{center}
        \begin{tikzpicture}[line width=0.5pt]
        \filldraw [fill=white] (0,0) circle [radius=3cm]
        \foreach \i in {0,30,...,360} {--(\i:2.8) node{$\bullet$}};
        \foreach \angle [count=\xi] in {60,30,...,-270}
        {\draw[line width=1pt] (\angle:2.8cm) -- (\angle:3cm);
            \node[font=\large] at (\angle:2.2cm) {\xi};}
        \foreach \angle in {0,90,180,270};
        \foreach \angle in {60,30,...,-270}
        {\draw[fill=black] (\angle:2.8cm) circle (0.1pt);
        }
        \end{tikzpicture}
    \end{center}
\end{document}

此代码产生

1

按照答案中给出的代码,我成功制作并连接了时钟中的所有点。现在从数字 3(或者90:2.8我猜)到时钟中心有一条额外的线,这是我不想要的。您可以在图中清楚地看到它。为什么会出现它以及如何将其移除?

答案1

更新:时钟作为更新的问题。

在此处输入图片描述

\documentclass[tikz,border=3mm]{standalone}
\begin{document}
\begin{tikzpicture}[cyan]
\draw (0:2.8) \foreach \i in {0,30,...,360} {--(\i:2.8) node{$\bullet$}};
\foreach \i [count=\xi] in {60,30,...,-270}
\draw[thick] (\i:2.8)--(\i:3) (\i:2.2) node[scale=1.2,orange]{\xi};
\draw[line width=2pt] (0,0) circle(3);
\end{tikzpicture}
\end{document}

这里有一种方法:

在此处输入图片描述

\documentclass[tikz,border=0.5cm]{standalone}
\begin{document}
\begin{tikzpicture}
\draw (0,0) circle(3) (0:2.8) \foreach \i in {0,30,...,330} {--(\i:2.8) node{$\bullet$}}--cycle;   
\end{tikzpicture}
\end{document}

答案2

另一种方式tkz-euclide

时钟:

\documentclass{standalone} 
\usepackage{tkz-euclide}
\begin{document} 

\begin{tikzpicture}[scale=2,ms/.style={teal,line width=.8mm}]
\foreach \an [count=\i] in {60,30,...,-270}
{ \tkzDefPoint(\an:2.8){\i}
  \tkzDrawSegment[ms]({\an:2.8},{\an:3})} 
  \tkzDefPoint(0,0){O}
  \tkzDrawCircle[R,teal,line width=1.6mm](O,3 cm)
  \tkzDrawPolygon[ms](1,...,12) 
  \tkzDrawPoints[teal,size=6](1,...,12) 
  \tkzAutoLabelPoints[purple,font=\Large,center=O,dist=-0.1](1,...,12) 
\end{tikzpicture}
\end{document}

在此处输入图片描述

\documentclass{standalone} 
\usepackage{tkz-euclide}
\begin{document} 

\begin{tikzpicture}
\foreach \an [count=\i] in {0,30,...,360}
{ \tkzDefPoint(\an:2.8){A_\i}} 
\tkzDefPoint(0,0){O}
  \tkzDrawCircle[R](O,3 cm)
  \tkzDrawPolygon(A_1,A_...,A_12) 
  \tkzDrawPoints(A_1,A_...,A_12) 
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容