3

I have this diagram,

sample 1

And the part I am only concerned with is the lines joining the centers C2 (blue circle) and C3 (violet circle). No matter how much values I change in the following code, they don't coincide. I am not sure why. Note that the lines joining the points of tangency (from l line) and the centers as well as point of contact between the circles were obtained by trial and error with the help of intersections as you will see in the code. Also please suggest me if there is any other better way to get the same diagram.

sample 2

Here's the code:

%% Figure 13

\documentclass[border=3mm,tikz]{standalone} \usepackage{tkz-euclide} \usetikzlibrary{intersections,calc}

\begin{document}

\begin{tikzpicture}[scale=0.9] %frames \draw[thick,->] (0,0) coordinate (origin) -- (23,0) coordinate (a1) node[right]{$x$}; % x-axis \draw[thick,->] (origin) -- (0,20) coordinate (a2) node[above]{$y$}; % y-axis \draw[name path=lline,thick] (origin) -- (60:22.25) coordinate (a3) node[anchor=south west]{$l$}; % l-line

%circle 1 \coordinate (CC1) at (1.732,1){}; \coordinate[label={[red]below:$C_1$}] (C1) at (1.732,0){}; \tkzDrawPointred,scale=2pt \tkzDrawCirclename path=circle1,red; \drawthick,red--(CC1) node[right,pos=.5]{1}; \draw[name intersections={of=lline and circle1}] (intersection-1) coordinate (A1); \drawthick,red--(CC1) node[above,pos=.5]{1};

%circle 2 \coordinate (CC2) at (5.1983,3){}; \coordinate[label={[blue]below:$C_2$}] (C2) at (5.1983,0){}; \tkzDrawPointblue,scale=2pt \tkzDrawCirclename path=circle2,blue; \drawthick,blue--(CC2) node[right,pos=.5]{3}; \draw[name intersections={of=lline and circle2}] (intersection-1) coordinate (A2); \drawthick,blue--(CC2) node[above,pos=.5]{3};

%circle 3 \coordinate (CC3) at (15.59229,9){}; \coordinate[label={[violet]below:$C_3$}] (C3) at (15.59229,0){}; \tkzDrawPointviolet,scale=2pt \tkzDrawCirclename path=circle3,violet; \drawthick,violet--(CC3) node[right,pos=.5]{$r$}; \draw[name intersections={of=lline and circle3}] (intersection-1) coordinate (A4); \drawthick,violet--(CC3) node[above,pos=.5]{$r$};

% circle 1 and circle 2 point of contact \draw[name intersections={of=circle1 and circle2}] (intersection-1) coordinate (A3);

% circle 2 and circle 3 point of contact \draw[name intersections={of=circle2 and circle3}] (intersection-1) coordinate (A5);

%bisector %\tkzDrawBisector(a1,origin,a3) \draw[red,thick] (origin) -- (CC1); \drawred,thick -- (A3); \drawblue,thick -- (CC2); \drawblue,thick -- (A5); \drawviolet,thick -- (CC3);

%angle marks 1 \tkzMarkAnglesize=.6,mark=none \tkzLabelAnglefill=white,dist=.2{$2\alpha$}

%angle marks 2 \tkzMarkAnglesize=1,mark=none,red \tkzLabelAngledist=.8,red{$\alpha$} \tkzMarkRightAnglesize=.2,red

%angle marks 3 \tkzMarkRightAnglesize=.2,blue

%angle marks 4 \tkzMarkRightAnglesize=.2,violet

%markings \draw[orange,very thick] (CC2) --++ (0:10.4) coordinate (a5); \draw[orange,very thick] (CC3) -- (a5); \draw[orange,very thick] (CC2) -- (CC3);

\end{tikzpicture}

\end{document}

UPDATE For some reasons, no matter how accurate values you give in the coordinates, there will always be some discrete points, meaning that there isn't actually 'continuity' between each points, so after a certain increment of a value of coordinates, it will switch to another discrete point. It may be due to the way the computer or the system works.

SolidMark
  • 1,389

1 Answers1

3

I'd to this with a pic for the circles with the radii, the right angles and the labels. Also if the origin of the pic is at the origin of coordinates it will be easier to draw.

Something like this:

\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{calc}

\tikzset {% pics/my circle/.style n args={4}{% #1 = radius, #2 = tangent angle, code={% #3 = radius label, #4 = circle label \pgfmathsetmacro\aux{90+2*#2} % angle, top radius \coordinate (-C) at ({#1/tan(#2)},#1); % center \draw (-C) circle (#1); \fill (-C) circle (3pt); \node at ({#1/tan(#2)},0) [below] {$#4$}; \foreach\i in {-90,\aux} { \begin{scope}[shift={(-C)},rotate=\i] \draw (0,0) -- (#1,0) node[midway,yshift=1.5mm,xshift=1mm] {$#3$}; \draw ($(#1,0)+(0,-0.3)$) --++ (-0.3,0) --++ (0,0.3); \end{scope} }
}}, }

\begin{document} \begin{tikzpicture}[line cap=round,line join=round] % circles \pic[red] (C1) {my circle={1}{30}{1}{C_1}}; \pic[blue] (C2) {my circle={3}{30}{3}{C_2}}; \pic[magenta] (C3) {my circle={9}{30}{r}{C_3}}; % axes \draw[latex-latex] (0,18) node [above] {$y$} |- (25,0) node [right] {$x$}; % tangent, bisector \draw (0,0) --++ (60:20) node [above right] {$\ell$}; \draw (0,0) --++ (30:20); % triangle \draw[very thick,orange] (C2-C) -- (C3-C) |- cycle; % angles \draw (0.3,0) node[below] {\strut$2\alpha$} arc (0:60:0.3); \draw[red] (0.7,0) node[below] {\strut$\alpha$} arc (0:30:0.7); \end{tikzpicture} \end{document}

enter image description here

Juan Castaño
  • 28,426
  • matches up nicely. pic is a relatively new concept to me. Will take a look in doc. – SolidMark Sep 09 '21 at 07:17
  • @MarkA.Bromuela, it can be done too without a pic using a \foreach with three variables for the circles and putting the pic code inside. But I think it looks cleaner this way. – Juan Castaño Sep 09 '21 at 10:16
  • @JuanCastaño It is very nice answer. Can you help fill the area between two circle and x-axis with pic. I find a question in here https://tex.stackexchange.com/questions/614730/fill-the-area-between-two-arcs-and-x-axis-between-two-circles – Nam Tran Le Sep 09 '21 at 15:21
  • @NamTranLe, see my answer for that question. The filling can be done in the same way. The pics are only for drawing the circles and its elements. You can draw them with pics as here or with \foreach and them fill them as in my other answer (for the question you linked). – Juan Castaño Sep 09 '21 at 16:06
  • @JuanCastaño Thank you very! Now I understand. – Nam Tran Le Sep 09 '21 at 16:20