如何绘制一个简单的角度,两条相交的线 Tikz

如何绘制一个简单的角度,两条相交的线 Tikz

我正在尝试获取负 $y$ 轴和通过原点的线之间的角度。如何实现?我看过其他论坛,代码似乎相当复杂;有没有简单的方法可以做到这一点?

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw [->,thick] (-3.5,0)--(3.5,0);
\node at (3.7,0) {\large{$x$}};
\draw [->,thick] (0,2)--(0,-3.5);
\draw[thick] (-3,-2)--(3,2);
\end{tikzpicture}
\end{document}

答案1

您可以加载库angles, quotes,然后使用该pic选项。我对您的代码进行了一些修改,例如,轴线现在等长,并且 X 轴的标签与命令一起添加\draw

输出

在此处输入图片描述

代码

\documentclass[margin=10pt]{standalone}
\usepackage{amsmath}
\usepackage{tikz}

\usetikzlibrary{quotes,angles}

\begin{document}
\begin{tikzpicture}

\coordinate (O) at (0,0);

\draw [->,thick] (-3.5,0)--(3.5,0) node[right, at end] {\large$x$};
\draw [->,thick] (0,3.5) coordinate (topy) --(0,-3.5) coordinate (bottomy);
\draw[thick] (-3,-2) coordinate (line2) -- (3,2);

\path 
    (line2)
    -- (O)
    -- (bottomy)
  pic["$\alpha$",draw=red,<->,angle eccentricity=1.2,angle radius=1cm] {angle=line2--O--bottomy};
\end{tikzpicture}
\end{document}

相关内容