In order to complete a handout I was preparing, I wrote the code below (MWE):
\documentclass[border=10pt,tikz]{standalone}
\usetikzlibrary{calc,angles,positioning,decorations.pathreplacing}
\begin{document}
\newcounter{angle}
\setcounter{angle}{135}
\begin{tikzpicture}
%--------------------------------------------------------------------------------------------
%Axis
\draw[thick,-stealth,black] (-3.7,0)--(3.7,0) node[below] {$x$}; % x axis
\draw[thick,-stealth,black] (0,-3.7)--(0,3.7) node[left] {$y$}; % y axis
%--------------------------------------------------------------------------------------------
% Unit Circle
\draw[black] (0,0) circle (2cm);
\node[black,below] at (2.2,0) {1};
%--------------------------------------------------------------------------------------------
% Circle of Radius R
\draw[black] (0,0) circle (3cm);
\node[black,below] at (3.2,0) {$r$};
%--------------------------------------------------------------------------------------------
%
\draw[-stealth] (1,0) arc (0:\theangle:1) node at ($(\theangle/2:0.7)$) {$\theta$};
%--------------------------------------------------------------------------------------------
\draw[dashed] (\theangle:2cm) -- (\theangle:2cm |- 0,0) coordinate (A) node [midway, left]{$y^\prime$}; % vertical line
\draw[thick,rotate=\theangle] (0,0) -- (2,0);%
\filldraw[black] (\theangle:2cm) circle(1pt);
\filldraw[black] (A) circle(1pt);
\draw (\theangle:2cm) node[above=2pt,xshift=2pt] {$P^\prime$};
\node[xshift=-0.75cm, below] (A) {$x^\prime$};
%--------------------------------------------------------------------------------------------
\draw[thick,rotate=\theangle] (0,0) -- (3,0);
\filldraw[black] (\theangle:3cm) circle(1pt);
\draw (\theangle:3cm) node[above=2pt] {$P$};
\draw[dashed] (\theangle:3cm) -- (\theangle:3cm |- 0,0) coordinate (B) node [midway, left]{$y$};
\filldraw[black] (B) circle(1pt);
\draw [decoration={brace,raise=17pt}, decorate,thick,rotate=\theangle] (0,0) -- (B)
node [midway, below=4.5ex]{$x$};%
\end{tikzpicture}
\end{document}
But I feel the code is a bit messy. Can you assist me in achieving the same result but with a more compact and robust code?
Here is an image of the result above:
Best Answer
This makes the code a bit shorter.
Let me mention that overall your code is fine. I feel that the things that you really should do is to avoid positioning the brace with
raise
and to use styles for repeating things like the bullet here. The\foreach
thingy does make the code shorter but for two repetitions it is not that big of a deal.Here is an annotated version: