[Tex/LaTex] How tontersect an arc with a line without calculating the angle

anglearccalculationsintersectionstikz-pgf

I'd like to draw an optics-related figure, for which I need to draw several beams with varying opening angles, which will need to be labeled.

What I've come up at the moment (boiled down to a minimal example) is below:

\documentclass{article}

\usepackage{tikz}
    \usetikzlibrary{intersections}
\usepackage[active,tightpage]{preview}

\begin{document}
\centering
\begin{preview}
\begin{tikzpicture}
    \coordinate (origin) at (0,0);
    \coordinate (screen-top) at (5,2);
    \coordinate (screen-bottom) at (5,-2);
    \draw [dashed,name path=beam] (origin) -- (screen-top) -- (screen-bottom) -- cycle;
    \draw [green,name path=circle] (0,0) circle (1);
    \path [name intersections={of=beam and circle,name=arc}];
    \draw [bend left] (arc-1) to node [midway,right] { \(\alpha\)} (arc-2) ;
\end{tikzpicture}
\end{preview}
\end{document}

Now I have a problem with this code. I can't seem to be able to automatically figure out the correct bending angle of the path between the intersections (the creen circle and the beam), so the bend is not 'nice', as seen in the figure below.

I know that I can manually set the bending angle with [bend left=19] instead of [bend left], but doing this manually for all drawings seems like not doing it the TikZ-way.

Problem

Does anyone have a tip for automatically calculating the bending angle for the path so it automatically matches a circle going through that point? Automatically means for different beam angles and 'screen' sizes and positions (which can be set in the code…)

Best Answer

Here are two solutions. The first clips a circle. The second actually computes the required angle, then draws the arc.

The code is

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{intersections}
\usetikzlibrary{calc}

\begin{document}

%option 1
\begin{tikzpicture}

\coordinate (origin) at (0,0);
\coordinate (screen-top) at (5,2);
\coordinate (screen-bottom) at (5,-2);

\draw [dashed,name path=beam] (origin) -- (screen-top) -- (screen-bottom) -- cycle;
\draw [green,name path=circle] (0,0) circle (1);

\clip (origin) -- (screen-top) -- (screen-bottom) -- cycle;
\draw (origin) circle[radius=1];
\node[right] at (1,0) {$\alpha$};

\end{tikzpicture}

%option 2
\begin{tikzpicture}
\pgfmathsetmacro{\radius}{1}

\coordinate (origin) at (0,0);
\coordinate (screen-top) at (5,2);
\coordinate (screen-bottom) at (5,-2);

\draw [dashed,name path=beam] (origin) -- (screen-top) -- (screen-bottom) -- cycle;
\draw [green,name path=circle] (0,0) circle (\radius);

\draw let
        \p{a} = ($(screen-top) - (origin)$),
        \p{b} = ($(screen-bottom) - (origin)$),
        \n{inner product} = {(\x{a}/1cm)*(\x{b}/1cm) + (\y{a}/1cm)*(\y{b}/1cm)},
        \n{la} = {veclen(\x{a}/1cm,\y{a}/1cm)},
        \n{lb} = {veclen(\x{b}/1cm,\y{b}/1cm)},
        \n{cosine} = {\n{inner product}/(\n{la}*\n{lb})},
        \n{half-angle} = {0.5*acos(\n{cosine})}
        in 
        (arc-2) arc[start angle=-\n{half-angle},end angle=\n{half-angle},radius = \radius] node[right] at ($(origin) + (\radius,0)$){$\alpha$};



\end{tikzpicture}


\end{document} 

Comment for Habi: You may replace the code defining the arc by the following line, in which the arc starts at arc-1:

(arc-1) arc[start angle=\n{half-angle},end angle=-\n{half-angle},radius = \radius] node[right] at ($(origin) + (\radius,0)$){$\alpha$};