[Tex/LaTex] TikZ: Drawing an arc between two coordinates

tikz-pgf

I am up with the following:

Using the code given at the bottom.

Suffice to say, I don't really like the result: I wanted to draw this picture without explicitly calculating the circle and the lines going into and out of it. However, I just don't know how to draw that part-circle to the right (with $\theta$ in it), such that I…

  • get an arc which is shaped like a circle,
  • have it intersect the shown without actually crossing them, and
  • have $\theta$ placed between the middle of the actually drawn arc and its center.

How could I achieve this?

\begin{tikzpicture}

\coordinate (a) at (-3,0.5);
\coordinate (b) at (-1,0.5);

\draw[solid,-latex] (a) -- (b) coordinate[at start] (p);

\draw[thin,solid,latex-latex] (p) -- node[left] {$p$} ++(270:0.5);

\draw[thin,dashed] (-3,0) -- (3,0) coordinate[very near end] (angleStart);

\node (interaction) [circle through=(b)
                    , solid
                    , draw
                    , fill=lightgray
                    ]  at (0,0) {interaction};

\draw[solid,-latex] (interaction.north east)  -- ++(45:2) coordinate[near end] (angleEnd);

\draw (angleStart) to[out=50,in=-20] node[below left=2pt] {$\theta$} (angleEnd);
\end{tikzpicture}

Best Answer

I suggest that you base everything on the center of the circle in which case the calculations can easily be automated with the additional TikZ library: \usetikzlibrary{calc}

enter image description here

You can set the angle and radius you want via:

\newcommand*{\ArcAngle}{60}%
\newcommand*{\ArcRadius}{2.0}%

Everything else is computed based on these. You can adjust these to get the specific result you desire.

Two other tweaks that I have defined below are to adjust how far the dashed lines extend past the arc, and how far past the arc the label is placed (as percentages):

\newcommand*{\LineExtend}{1.25}%
\newcommand*{\LableExtend}{1.10}%

Code:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}

\newcommand*{\ArcAngle}{60}%
\newcommand*{\ArcRadius}{2.0}%
\newcommand*{\LineExtend}{1.25}%
\newcommand*{\LableExtend}{1.10}%

\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro{\XValueArc}{\ArcRadius*cos(\ArcAngle)}%
\pgfmathsetmacro{\YValueArc}{\ArcRadius*sin(\ArcAngle)}%

\pgfmathsetmacro{\XValueLabel}{\ArcRadius*cos(\ArcAngle/2)}%
\pgfmathsetmacro{\YValueLabel}{\ArcRadius*sin(\ArcAngle/2)}%

\coordinate (Origin) at (0,0);

\draw [thin, dashed] (Origin) -- ($(\LineExtend*\ArcRadius,0)$);% Horizontal

% Extend this past the (\XValue,\YValue)
\draw [thin, dashed] (Origin) -- ($\LineExtend*(\XValueArc,\YValueArc)$);

\node (interaction) [circle, solid, draw, fill=lightgray]  
    at (Origin) {interaction};

\draw [<->] ($(Origin)+(\ArcRadius,0)$) 
    arc (0:\ArcAngle:\ArcRadius);

\node at ($\LableExtend*(\XValueLabel,\YValueLabel)$) {$\theta$};
\end{tikzpicture}
\end{document}