1

The code at the bottom produces the correct drawing, shown below. The issue is that I don't think I drew it in the best way possible; in particular, I really don't like having to construct (X) or (Y) (I would rather specify that the radius is 2 and that the ray should go in the direction of (p)).

Can someone show me a better way?

\begin{tikzpicture}
\node [fill=black, shape=circle, inner sep=1pt, label=below:$O$] (O) at (0,0) {};
\node [fill=black, shape=circle, inner sep=1pt, label=below:$p$] (p) at (0.6,1.2) {};
\node [fill=black, shape=circle, inner sep=1pt, label=below:$f(p)$] (fp) at 
(-1.2,0.7) {};
\coordinate (X) at (2,0);
\coordinate (Y) at (2.4, 1.7);
\node (C) [name path=C, draw, circle through=(X)] at (O) {};
\path [name path=fp--Y] (fp)--(Y);
\path [name intersections={of=fp--Y and C, by=F}];
\node [fill=black, shape=circle, inner sep=1pt, label=right:$r(p)$] (rp) at (F) {};
\draw [->] (fp)--(rp);
\end{tikzpicture}

Correct output

2
2

Here is a somewhat simpler proposal. Assuming that you like your code except for the fact that you need to place Y by hand, here is a simple way to fix it. At first sight this code appears bulkier than @Zarko's, but this is only because I add something that is missing in both your and @Zarko's code: the correct determination of the bounding box. This code also finds a suitable Y outside the circle such that one can compute the desired intersection, but here there is no hard-coded length 2, which will make @Zarko's code fail if p and fp were chosen differently. Moreover, there is really no acos computation needed, TikZ has this already built in the calc library, the relevant syntax is ($ (fp) ! 2*veclen(\x1,\y1) ! (p) $). Here, veclen(\x1,\y1) is the radius of the circle, and the distance between Y and (fp) is chosen to be 2 times this radius such that the auxiliary line will for sure intersect with the circle.

\documentclass[tikz,border=3.14pt,varwidth]{standalone}
\usetikzlibrary{through,calc,intersections}
\begin{document}
\begin{tikzpicture}
\node [fill=black, shape=circle, inner sep=1pt, label=below:$O$] (O) at (0,0) {};
\node [fill=black, shape=circle, inner sep=1pt, label=below:$p$] (p) at (0.6,1.2) {};
\node [fill=black, shape=circle, inner sep=1pt, label=below:$f(p)$] (fp) at 
(-1.2,0.7) {};
(0.4,0.7) {};
\coordinate (X) at (2,0);
\node (C) [name path=C, draw, circle through=(X)] at (O) {};
% store the original boundary box
\begin{pgfinterruptboundingbox}
% automatically find a suitable Y : draw a line of length twice the radius
% starting from (fp) to the (t) direction (no acos computation is required)
\path let \p1 = ($ (O) - (X) $) in coordinate (Y) at ($ (fp) ! 2*veclen(\x1,\y1) ! (p) $); 
\path [name path=fp--Y] (fp)--(Y);
\path [name intersections={of=fp--Y and C, by=F}];
% restore the original boundary box
\end{pgfinterruptboundingbox}
\node [fill=black, shape=circle, inner sep=1pt, label=right:$r(p)$] (rp) at (F) {};
\draw [->] (fp)--(rp);
\end{tikzpicture}
\end{document}

enter image description here

3
  • 1
    Actually, it's not that uncommon for people to post answers that share essential features of other answers. Sometimes this is because they had similar ideas and they were writing/editing their post when the other answer appeared. Sometimes they just copy... Anyway, I have tried to correct for the down vote +1. (I don't like down-votes so I'd also up-vote Zarko's answer but you can't vote on deleted posts.) Btw, I like the pgfinterruptboundingbox :)
    – user30471
    Apr 7 '18 at 6:18
  • @Andrew It is fine to improve an answer. After all, the aim is to provide users with the best possible answers. What is IMHO not fine is to adopt features of another later answer without mentioning this. I actually upvoted his answer when I posted mine, but all he did was to copy the new features from mine without mentioning my answer in the update. Do you think that is OK?
    – user121799
    Apr 7 '18 at 14:22
  • 2
    Yes, I agree. I think that the key point is that one should always acknowledge one’s sources.
    – user30471
    Apr 9 '18 at 14:36
2

You can basically skip the X and Y definition and elongate the line towards some direction that you think will hit the circle. For that either you get the angles or you know something is along that direction for sure (here I used O.east)

\documentclass[tikz]{standalone}
\usetikzlibrary{intersections,calc}
\begin{document}
\begin{tikzpicture}[mydot/.style={fill=black,circle,inner sep=1pt,label={below:#1}}]
\path node [circle,draw,name path=C,minimum height=4cm](O) at (0,0) {} node[mydot=$O$]
      at(O.center){} node[mydot=$p$](p) at(0.5,1) {} node [mydot=$f(p)$] (fp) at (-1,0) {};
\path [overlay,name path=fp--Y] (fp)--($(fp)!($2*(O.east)$)!(p)$);
\path [name intersections={of=fp--Y and C, by=F}];
\node [fill=black, shape=circle, inner sep=1pt, label=right:$r(p)$] (rp) at (F) {};
\draw [->] (fp)--(p)--(rp);
\end{tikzpicture}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.