TransWikia.com

Tikz: Angle arc overrunning line

TeX - LaTeX Asked by Matt N. on December 26, 2020

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

2 Answers

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.

Correct answer by hpekristiansen on December 26, 2020

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

Answered by phil-elkabat on December 26, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP