我想将矩形放置在圆形路径上,使它们与圆相切。
我希望矩形部分保持真正的矩形。如果我将矩形命令与旋转选项一起使用,则很难将矩形沿圆形路径放置。
是否可以将矩形命令与极坐标一起使用?
编辑:我的糟糕尝试如下:
\documentclass[a4paper,10pt]{scrreprt}
\usepackage{tikz}
\begin{tikzpicture}[scale=1]
\foreach \a in {0, 45, 90, 135, 180}{
\path[draw] (\a:1) -- (\a:2) -- (\a + 10:2) -- (\a + 10:1) -- cycle;
}
\end{document}
答案1
\documentclass[tikz, border=2mm]{standalone}
\begin{document}
\begin{tikzpicture}
\draw circle (3cm);
\draw (30:3cm) node[draw, anchor=south, rotate=-60, minimum width=1cm] {A};
\draw (60:3cm) node[draw, anchor=south, rotate=-30, minimum width=1cm] {B};
\draw (215:3cm) node[draw, anchor=south, rotate=125, minimum width=1cm] {C};
\end{tikzpicture}
\end{document}
答案2
我认为这样做可以:
\documentclass[tikz,border=5]{standalone}
\usetikzlibrary{math}
\begin{document}
\begin{tikzpicture}
\tikzmath{%
\r = 1;
\a = 10; % angle of chord forming base of rectangle
\s = 15; % angle between rectangle centers
\R = \r * cos(\s / 2);
\n = int(360 / \s);
\x = \r / 2 * sin(\a);
}
\draw [help lines] circle [radius=\r];
\foreach \i in {1, ..., \n}
\draw [help lines]
(0,0) -- (\i*\s-\a/2:\r+1/2) (0,0) -- (\i*\s+\a/2:\r+1/2);
\foreach \i in {1, ..., \n}
\draw [shift=(\i*\s:\R),rotate=\i*\s+270]
(-\x, 0) rectangle (\x, 1/8);
\end{tikzpicture}
\end{document}
答案3
您可以使用\foreach
循环在圆圈周围绘制矩形。
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[
rectangle node/.style={
minimum width = \w,
minimum height = \h,
fill = gray,
inner sep = 0pt,
anchor = center,
},
]
% Variables
\def\N{36}% Number of rectangles - 1
\def\h{0.2cm}% height of rectangles
\def\w{0.4cm}% width of rectangles
\def\R{3}% Radius
% draw rectangles
\foreach \n in {0,...,\N} {
\node [rectangle node, rotate=\n*(360/(\N+1))+90] at ({\n*360/(\N+1)}:\R) {};
}
\end{tikzpicture}
\end{document}
我定义了一些变量来设置矩形的大小(\w
和\h
),矩形的数量(\N
+1)和圆的半径(\R
)。