7

the figure I try to create is below: (I try to make the same with the upper figure, the lower is mine but it seem to be not the same) enter image description here

My code:

\begin{center}
\begin{tikzpicture} [scale=0.5]
\draw [magenta, thick] circle [radius=2] (0,0) node[above]{$R$}--(150:4.5cm);
\draw [magenta, thick] (0,0)--(6,0);

\node [circle,fill=black] at (4.05,2) {};
\node [circle,fill=black] at (4.05,-2) {};
\draw [blue, thick] circle [radius=4.5];
\draw [blue, thick] (0,2)--(6,2) node[above]{$B$} ;
\draw [blue, thick] (0,-2)--(6,-2) node[above]{$A$} ;
\draw [black, thick] (5,0)--(5,2) node[below right]{$R$};
\draw [black, thick] (5,0)--(5,-2) node[above right]{$R$};
\end{tikzpicture}
\end{center}

Then, how should i improve to draw the same with the upper? Thanks!

2 Answers 2

8

You can add labels to nodes, which I would suggest to do in the case of $A$, $B$ and Planet, and you can add nodes as labels to paths, which is probably more suitable for the other labels.

\documentclass[border=1mm, tikz]{standalone}

\begin{document}
\begin{tikzpicture}[scale=0.5]

% two nodes as labels to the same path
\draw[magenta, thick] circle[radius=2] (0,0) node[below]{Star} -- (150:4.5cm) node[pos=.6, above] {$a$};

\draw[magenta, thick] (0,0)--(8,0);

% labels to nodes (multiple labels per node possible)
\node[circle, fill=black, label={45:$A$}] at (4.05,2) {};
\node[circle, fill=black, label={45:$B$}, label={-45:Planet}] at (4.05,-2) {};

\draw[blue, thick] circle[radius=4.5];
\draw[blue, thick] (0,2) -- (8,2);
\draw[blue, thick] (0,-2) -- (8,-2);

% nodes as labels to paths
\draw[black, thick, <->] (7,0) -- (7,2) node[below right]{$R$};
\draw[black, thick, <->] (7,0) -- (7,-2) node[above right]{$R$};
\end{tikzpicture}
\end{document}

enter image description here

3
  • 1
    oh, I am a newbie to Tikz, many thanks!
    – user
    Dec 13, 2021 at 15:39
  • 3
    What you had was already a very good start! Dec 13, 2021 at 15:40
  • 1
    Thanks for yr good words! I have to try alot
    – user
    Dec 13, 2021 at 15:46
5

A bit more complex code, but intersections, where are positioned black dots, are calculated by intersections library. Determined are styles for paths, nodes and labels too. So they can be easy consistent adopted to desired style of image elements:

\documentclass[border=1mm, tikz]{standalone}
\usetikzlibrary{backgrounds,
                intersections,
                positioning,
                quotes}

\begin{document}
    \begin{tikzpicture}[
    scale=0.5, 
    node distance = 1em,
dot/.style = {circle, fill=black, inner sep=3pt, 
              label=#1, node contents={}},
 np/.style args = {#1/#2}{draw=#1, name path=#2},
%
every label/.style = {inner sep=1pt},
every  path/.style = {draw, thick, line cap=round},
every edge quotes/.style = {auto, inner sep=1pt}
                        ]

% small circle and two labels
\draw[np=magenta/{}, fill=magenta!15]  
    (225:44mm) to [pos=0.3, "$a$" sloped] (0:0) 
                    circle[radius=2] node[above] {Star}
               -- ++ (7,0) coordinate (aux1);
% big circle, labels at intersections
\draw[np=blue/C] circle[radius=44mm];
\draw[np=blue/A] (0,+2) -- ++ (aux1);
\draw[np=blue/B] (0,-2) -- ++ (aux1);
% intersections
\scoped[on background layer]
{
\draw[name intersections={of=C and A, by=a}]    
    (a) node[dot=45:$A$];
\draw[name intersections={of=C and B, by=b}]
    (b) node[dot=45:$B$, label=-45:Planet];
}
% distances with labels 
\coordinate[left=of aux1] (aux2);
\draw[<->]  (a -| aux2) edge ["$R$"] (aux2)
            (aux2)      edge ["$R$"] (b-| aux2);
\end{tikzpicture}
\end{tikzpicture}
\end{document}

enter image description here

2
  • Many thanks! That's beautiful!
    – user
    Dec 15, 2021 at 2:05
  • 1
    @user, you are welcome!
    – Zarko
    Dec 15, 2021 at 2:34

You must log in to answer this question.

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