2

Is it possibile to evaluate an angle in Tikz? I googled a lot but I can't find anything exhausting. My problem is the following: I have an arc intersected by a bundle of parallel lines, like shawn in the picture below

enter image description here

Once drawn the arc (path name=mirror) I used this code

\foreach \y in {-1.6,-0.8,...,1.6}
                {
                    \path [name path=ray] (-1,\y) -- ($ (-1,\y) + (10,0) $);
                    \path [name intersections={of=ray and mirror, by={P}}];
                    \draw [thick, postaction={on each segment={mid arrow=black}}] (-1,\y) -- (P);
                    \draw [thick, dashed, name path=refracted] (P) -- (F);

                    \begin{scope}[shift={(P)}]

                    \end{scope}                     
                }

to generate the bundle of lines. I would like to draw some lines like these in red

enter image description here

To do this, I thought to evaluate the angle between P--F--V and, after a shift of the coordinate system in P (which changes for each line), then draw a simply line using

\draw [thick] (\myAngle:2cm);
5
  • Can you please post a complete code that starts with \documentclass and ends with \end{document}? BTW, the computation of the angle is already done in the lowest example of tex.stackexchange.com/a/520724/194703.
    – user194703
    Dec 18, 2019 at 21:41
  • I'm writing something like a book, it would be impossible I guess
    – frad
    Dec 18, 2019 at 21:42
  • Have a look at the calc library (you seem to already use it). There is a way to do exactly what you ask for. Dec 18, 2019 at 21:44
  • 1
    You also expect the answer to be self-contained, don't you? It is for all of us some effort to provide some minimal compilable codes, but this is the only reasonable way of communicating here, I think.
    – user194703
    Dec 18, 2019 at 21:51
  • Oh I got you... Excuse me for my last posts then, you are definetely right. I'll post the entire code on next time
    – frad
    Dec 18, 2019 at 22:15

1 Answer 1

5

The computation you are asking for is simpler than the one in the previous answer since the rays are all horizontal. You just need to get the angle, alpha, at which they hit the mirror, and outgoing ray will have an angle of 180-2*alpha. This angle can be computed with the calc syntax

\path let \p1=($(<point>)-(<center>)$),
    \n1={180-atan2(\y1,\x1)} in ... ;

where <point> is the point at which the ray hits the mirror, i.e. the intersection point P in your code, and <center> is the center of the circle used to draw the mirror. The following self-contained code illustrates this.

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{decorations.markings,calc,angles,quotes}
\pgfdeclareradialshading{halo}{\pgfpointorigin}{
  color(0pt)=(pgftransparent!100); color(22.5bp)=(pgftransparent!100);
  color(25bp)=(pgftransparent!00); color(50bp)=(pgftransparent!00)}%
\pgfdeclarefading{halo}{\pgfuseshading{halo}}%
\tikzset{->-/.style={decoration={% https://tex.stackexchange.com/a/39282/194703
  markings,
  mark=at position #1 with {\arrow{>}}},postaction={decorate}},
  ->-/.default=0.5}
\begin{document}
\begin{tikzpicture}[>=stealth,every label/.append style={black},
    bullet/.style={circle,fill=black,inner sep=0.1em}]
\begin{scope}[xshift=6cm]
    \clip (75:-3)
    -- (75:-2.5) arc (75:-75:-2.5)
    -- (-75:-3) arc (-75:75:-3);
    \fill[path fading=halo] (0,0) circle[radius=3cm];
\end{scope}
\draw (-2,0) coordinate (L) -- (7,0) coordinate (R) 
  (3,0)  node[bullet,label=below left:$V$](V){}
  (6,0)  node[bullet,label=below:$C$](C){}
  (-1,0)  node[bullet,label=below:$O$](O){}
  foreach \X [count=\Y] in {-40,-20,20,40}
  {($(C)+(180+\X:3)$) node[bullet](P\Y){}};
  \foreach \Y in {1,...,4}
  {\draw[orange,->-,thick] (O|-P\Y) -- (P\Y);
   \draw[red,->-,thick] let \p1=($(P\Y)-(C)$),
    \n1={180-atan2(\y1,\x1)} in
    (P\Y) -- ++({180-2*\n1}:2);
   \draw[dashed, shorten >=-2cm] (C) -- (P\Y);}
\end{tikzpicture}
\end{document}

enter image description here

You must log in to answer this question.

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