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.
\documentclass[convert = false, tikz]{standalone}
\usetikzlibrary{intersections}
\usetikzlibrary{calc}

\begin{document}
\begin{tikzpicture}
  \coordinate (O) at (0, 0);
  \coordinate (M) at (4, 0);

  \def\angle{130}

  \draw (O) -- (M);
  \draw (M) -- ++(\angle:2cm) coordinate (SOI);

  \begin{pgfinterruptboundingbox}
    \path[name path global = circ] (O) circle[radius = 1.5cm];
    \path[name path global = xline] (O) -- +(-10, 0);
    \path[name path global = yline] (O) -- +(0, 2);
    \path[name path global = toE] (SOI) -- ++(-170:8cm);
    \path[name intersections = {of = yline and toE, by = E}];
    \path[name intersections = {of = xline and toE, by = I}];
    \path[name intersections = {of = circ and toE, by = P1}];
  \end{pgfinterruptboundingbox}

  \draw (SOI) -- (E);

  \draw[-latex] let
    \p0 = (I),
    \p1 = (M),
    \p2 = (P1),
    \n1 = {atan2(\x1 - \x0, \y1 - \y0)},
    \n2 = {atan2(\x2 - \x0, \y2 - \y0)},
    \n3 = {1.5cm}
  in (I) +(\n1:\n3) arc[radius = \n3, start angle = \n1, end angle = \n2];

  \draw[-latex] let
    \p0 = (O),
    \p1 = (M),
    \p2 = (P1),
    \n1 = {atan2(\x1 - \x0, \y1 - \y0)},
    \n2 = {atan2(\x2 - \x0, \y2 - \y0)},
    \n3 = {1.5cm}
  in (O) +(\n1:\n3) arc[radius = \n3, start angle = \n1, end angle = \n2];

  \draw[-latex] let
    \p0 = (I),
    \p1 = (M),
    \p2 = (SOI),
    \n1 = {atan2(\x1 - \x0, \y1 - \y0)},
    \n2 = {atan2(\x2 - \x0, \y2 - \y0)},
    \n3 = {1.5cm}
  in (I) +(\n1:\n3) arc[radius = \n3, start angle = \n1, end angle = \n2];

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

If we consider the code above, the arc that is long enough curves too much and the arc that has the right amount of curve is too short. How can I get the right amount of curve with the correct length in a case like this?

  1. Using (SOI)

Both curves are too short but neither appear to over arc.

What can I do here?

enter image description here


@Jake, your code that switches y and x rotates my vector to appear horizontal not vertical.

 \draw[-latex] let
    \p0 = (O),
    \p1 = (M),
    \p2 = (SOI),
    \n1 = {atan2(\y1 - \y0, \x1 - \x0)},
    \n2 = {atan2(\y2 - \y0, \x2 - \x0)},
    \n3 = {veclen(\x2 - \x0, \y2 - \y1)},
    \n4 = {(\n1 + \n2) / 2}
  in (O) +(\n1:\n3) arc[radius = \n3, start angle = \n1, end angle = \n2];

The code above you posted produces:

enter image description here

Going back to x and then y produces:

enter image description here


The problem was the (I) coordinate. It never actually existed but LaTeX wasn't returning any errors. The path toE never intersected the xline. Therefore, so when I was drawing from the (I), the circle path making up the intersection origin was above y = 0. Thus, causing the (I) arcs to be short. To correct this, set

\path[name path global = toE] (SOI) -- ++(-170:9cm);

which changes the radius of the ray to 9cm from 8cm.

share|improve this question
1  
@Jake I still get the picture. I had a \n4 that was unnecessary in MWE so I forgot to remove the ,. –  dustin Aug 3 '13 at 4:04
    
You should probably post that last bit as an answer and accept it –  Jake Aug 3 '13 at 4:52
    
@Jake do you know why there was no error message issued even though there was no intersection? –  dustin Aug 4 '13 at 20:57
1  
Interesting: That's an unexpected consequence of how the by mechanism for naming intersections is implemented. It turns out that all intersections are initially called intersection-1, and if you specify a custom name using by, that intersection is renamed to the chosen name. Now, once you've successfully found an intersection in a path, if later paths don't find their own intersection they'll just rename that initial intersection (which is what happened in your case). I'll file a bug report. –  Jake Aug 4 '13 at 21:37

1 Answer 1

up vote 2 down vote accepted

The problem was the (I) coordinate. It never actually existed but LaTeX wasn't returning any errors. The path toE never intersected the xline. Therefore, so when I was drawing from the (I), the circle path making up the intersection origin was above y = 0. Thus, causing the (I) arcs to be short. To correct this, set

\path[name path global = toE] (SOI) -- ++(-170:9cm);

which changes the radius of the ray to 9cm from 8cm.

At the current settings, an intersection never existed.

enter image description here

Unfortunately, LaTeX never spit out an error and let the line

\path[name intersections = {of = xline and toE, by = I}];

create the point (I) at the end of toE. Since I constructed paths, I couldn't actually see this until I decided to look more closely, and without an error message saying there is no intersection or something along those lines, I was lead to believe everything worked.

With the new change, we obtain

enter image description here

by setting

\path[name path global = circ] (I) circle[radius = 7cm];

and using Jake's deleted method of veclen and putting it in the pgfinterruptboundingbox or else you will have unnecessary white space.

  \draw[-latex] let
    \p0 = (I),
    \p1 = (M),
    \p2 = (P1),
    \n1 = {atan2(\x1 - \x0, \y1 - \y0)},
    \n2 = {atan2(\x2 - \x0, \y2 - \y0)},
    \n3 = {veclen(\x2 - \x0, \y2 - \y1)},
    \n4 = {(\n1 + \n2) / 2}
  in (I) +(\n1:\n3) arc[radius = \n3, start angle = \n1, end angle = \n2]
  node[font = \tiny, fill = white, inner sep = 0] at ([shift = (I)] \n4:\n3)
  {\(\phi_1\)};
share|improve this answer

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.