1

I would like to place rectangles on a circular path, in a way that they are tangential to the circle.

If I use polar coordinates and connected lines, I end up with something like this: enter image description here

I want the rectangular sections to stay truly rectangular. If I use the rectangle command together with the rotate option, I have troubles placing the rectangles along a circular path.

Is it possible to use the rectangle command with polar coordinates?

Edit: My poor attempt was the following:

\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
  • 1
    Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
    – LaRiFaRi
    Commented Sep 7, 2015 at 9:56

3 Answers 3

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}

enter image description here

1
  • I did not know about minimum width/minimum height parameters, which apparently lets you create arbitrary rectangles. :D Commented Sep 7, 2015 at 10:13
3

I think this does it:

\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}

enter image description here

1

You can use a \foreach loop to draw rectangles around a circle.

\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}

I defined some variables to set the size of the rectangles (\w and \h), the number of rectangles (\N+1) and the radius of the circle (\R).

rectangles in a circle

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .