Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I tried both (O.center) and (F.center) but the arc doesn't end at the line FS. How can I construct this arc?

\documentclass[tikz,convert=false]{standalone}
\usetikzlibrary{intersections, arrows, backgrounds, calc}
\begin{document}
\begin{tikzpicture}[
    every label/.append style = {font = \small},
    dot/.style = {inner sep = +0pt, shape = circle,
      draw = black, label = {#1}},
    small dot/.style = {minimum size = .05cm, dot = {#1}},
    big dot/.style = {minimum size = .1cm, dot = {#1}},
    extended line/.style = {shorten >=-#1, shorten <=-#1},
    extended line/.default = 1cm,
    one end extended/.style = {shorten >=-#1},
    one end extended/.default = 1.25cm, line cap = round, line join = round,
    >=triangle 45]
    \pgfmathsetmacro{\a}{3}
    \pgfmathsetmacro{\b}{2.5}
    \pgfmathsetmacro{\c}{sqrt(\a^2 - \b^2)}

    \node[fill = black, big dot = {below left: \(A\)}] (A) at (-3, 0) {};
    \node[fill = black, big dot = {below right: \(P\)}] (P) at (3, 0) {};
    \node[fill = black, big dot = {below left: \(D\)}] (D) at (0, -2.5) {};
    \node[fill = black, big dot = {above left: \(B\)}] (B) at (0, 2.5) {};
    \node[fill = black, big dot = {below left: \(F\)}] (F) at (\c, 0) {};
    \node[fill = black, big dot = {below left: \(O\)}] (O) at (0,0) {};

    \draw (0, -3.25) -- (0, 3.25) node[scale = .75, fill = white,
    inner sep = 0cm, pos = .7] {\(b\)};
    \draw[name path = xline] (-3.25, 0) -- (5, 0) node[scale = .8, fill = white,
    inner sep = 0cm, pos = .2] {\(a\)};
    \draw[red, name path = circle] (O) circle (3cm);
    \draw[blue, name path = ellipse] (O) ellipse (3cm and 2.5cm);
    \path[name path = line] (2.25, 3) -- (2.25, -1);

    \path[name intersections = {of = circle and line, by = P1}];
    \node[fill = black, big dot = {above: \(Q\)}] (Q) at (P1) {};
    \path[name intersections = {of = line and xline, by = P2}];

    \draw[black] (Q) -- (P2) node[fill = black, big dot = {below right: \(V\)}]
    (V) at (P2) {};
    \path[name intersections = {of = line and ellipse, by = P3}];
    \node[fill = black, big dot = {right: \(S\)}] (S) at (P3) {};

    \draw (O) -- (Q) node[scale = .75, pos = .5, fill = white, inner sep = 0cm]
    {\(a\)};
    \draw[one end extended] (F) -- (S) node[scale = .8, pos = .5,
    fill = white, inner sep = 0.03cm] {\(r\)} coordinate (P4);

    \begin{scope}[on background layer]
      \begin{scope}
        \clip (S) rectangle (P);
        \shadedraw[blue, outer color = blue!30!black, inner color = red!30] (O) ellipse (3cm and 2.5cm);
      \end{scope}
      \filldraw[bottom color = cyan!50!blue, top color = green!20] (S.center) -- (F.center) -- (V.center) -- cycle;
    \end{scope}

     \draw[latex-latex] let
      \p0 = (O),
      \p1 = (P),
      \p2 = (P4),
      \n1 = {atan2(\x1 - \x0, \y1 - \y0)},
      \n2 = {atan2(\x2 - \x0, \y2 - \y0)},
      \n3 = {3.5cm}
    in (O.center) +(\n1:\n3) arc[radius = \n3, start angle = \n1,
    end angle = \n2];
\end{tikzpicture}
\end{document}

enter image description here

The offending code excerpt is:

    \draw[latex-latex] let
      \p0 = (O),
      \p1 = (P),
      \p2 = (P4),
      \n1 = {atan2(\x1 - \x0, \y1 - \y0)},
      \n2 = {atan2(\x2 - \x0, \y2 - \y0)},
      \n3 = {3.5cm}
    in (O.center) +(\n1:\n3) arc[radius = \n3, start angle = \n1,
    end angle = \n2];
share|improve this question
    
I’m sure this is just a typo: end angle = \n2 instead of \n3. –  Qrrbrbirlbel Jun 29 '13 at 0:13
    
@Qrrbrbirlbel indeed but even with the correction the line inst' long enough. I will update the post. –  dustin Jun 29 '13 at 0:14
    
That’s not surprising, considering that the end angle is both in calculation and construction of the arc the angle of the line OS. The coordinate P4 is located at S, not where the line actually ends (the shorten part is done on a lower level). You could define P4 as coordinate[pos=1.52] (P4) (the position number is just guessed and adjusted so that it looks good). That is of course not a waterproof solution. (Don’t forget the calc library.) –  Qrrbrbirlbel Jun 29 '13 at 0:18
    
@Qrrbrbirlbel I don't understand. –  dustin Jun 29 '13 at 0:20
add comment

1 Answer 1

up vote 1 down vote accepted

I’d find that coordinate where the arrow should end with an intersection of two paths:

Code

\documentclass[tikz,convert=false]{standalone}
\usetikzlibrary{intersections, arrows, calc, backgrounds}
\begin{document}
\begin{tikzpicture}[
    every label/.append style = {font = \small},
    dot/.style = {inner sep = +0pt, shape = circle,
      draw = black, label = {#1}},
    big dot/.style = {minimum size = .1cm, dot = {#1}},
    extended line/.style = {shorten >=-#1, shorten <=-#1},
    extended line/.default = 1cm,
    one end extended/.style = {shorten >=-#1},
    one end extended/.default = 1.25cm, line cap = round, line join = round,
    >=triangle 45]
    \pgfmathsetmacro{\a}{3}
    \pgfmathsetmacro{\b}{2.5}
    \pgfmathsetmacro{\c}{sqrt(\a^2 - \b^2)}

    \node[fill = black, big dot = {below right: \(P\)}] (P) at (3, 0) {};
    \node[fill = black, big dot = {below left: \(F\)}] (F) at (\c, 0) {};
    \node[fill = black, big dot = {below left: \(O\)}] (O) at (0,0) {};

    \draw[blue, name path = ellipse] (O) ellipse (3cm and 2.5cm);
    \path[name path = line] (2.25, 3) -- (2.25, -1);

    \path[name intersections = {of = line and ellipse, by = P3}];
    \node[fill = black, big dot = {right: \(S\)}] (S) at (P3) {};


    \draw[one end extended] (F) -- (S) node[scale = .8, pos = .5,
    fill = white, inner sep = 0.03cm] {\(r\)} coordinate[pos=2] (P4);

    \path[name path=bigCircle] (O) circle [radius=3.5cm];
    \path[name path=longFS] (F) -- (P4);
    \tikzset{name intersections={of=bigCircle and longFS,by=P4}}
     \draw[latex-latex] let
      \p0 = (O),
      \p1 = (P),
      \p2 = (P4),
      \n1 = {atan2(\x1 - \x0, \y1 - \y0)},
      \n2 = {atan2(\x2 - \x0, \y2 - \y0)},
      \n3 = {3.5cm}
    in (O.center) +(\n1:\n3) arc[radius = \n3, start angle = \n1, end angle = \n2];
\end{tikzpicture}
\end{document}

Output

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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