2

I drew two interecting lines and the angle of the arc between but the arc is overrunning the line. What am I doing wrong?

The code:

\begin{tikzpicture}
\coordinate (origin) at (0,0);
\draw [thick] (-2,2) coordinate (topy) -- (2,-2.5) coordinate (line1);
\draw[thick] (-3,-2) coordinate (line2) -- (3,2);
\pic [draw, -, "$\theta$", angle eccentricity=1.5] {angle = line2--origin--line1};
\end{tikzpicture}

The result:

enter image description here

1
  • 2
    Remember to supply compilable code, so that people who wants to help does not need to spend time on finding the needed packages. – hpekristiansen Aug 14 '20 at 13:33
6

Your lines does not cross at origin. I do not know what you want!? So I just show how to see the problem:

\documentclass[tikz, border = 0.5 cm]{standalone}
\usetikzlibrary {angles,quotes}
\begin{document}
\begin{tikzpicture}
\coordinate (origin) at (0,0);
\draw [thick] (-2,2) coordinate (topy) -- (2,-2.5) coordinate (line1);
\draw[thick] (-3,-2) coordinate (line2) -- (3,2);
\pic [draw, -, "$\theta$", angle eccentricity=1.5] {angle = line2--origin--line1};
\fill (line1) circle (0.05);
\fill (origin) circle (0.05);
\fill (line2) circle (0.05);
\end{tikzpicture}
 \end{document}

circles at named coordinates

With circles at the named coordinates, it can be seen that the angle correctly spans the arc line2--origin--line1.

1
  • Right, I just noticed the mistake with the origin and was going to delete the question. But since it's been answered perhaps it can help someone else! – Matt N. Aug 14 '20 at 13:48
5

To me it is always helpful to color everything, so I can see what is happening. Your example is missing an intersection:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{angles,quotes,intersections}

\begin{document}

\begin{tikzpicture}
\coordinate (origin) at (0,0);
\draw [thick] (-2,2) coordinate (topy) -- (2,-2.5) coordinate (line1);
\draw[thick] (-3,-2) coordinate (line2) -- (3,2);
\pic [draw, -, "$\theta$", angle eccentricity=1.5] {angle = line2--origin--line1};
\end{tikzpicture}

% Improved example
\begin{tikzpicture}
  \draw[thick,name path=A,red] (-2,2) coordinate (A) -- (2,-2.5) coordinate (B);
  \draw[thick,name path=B,green] (-3,-2) coordinate (C) -- (3,2) coordinate (D);
  \path[name intersections={of=A and B,name=inter}];
  \draw pic["$\theta$", draw=blue, angle eccentricity=1.5] {angle=C--inter-1--B};
\end{tikzpicture}

\end{document}

See your attempt at the top and mine below:

named paths with intersection

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.