我想知道它是如何\pgfmathanglebetweenpoints
工作的。为什么这里结果是 X = 243.57?谢谢。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\pgfmathanglebetweenpoints{\pgfpoint{0cm}{1cm}}{\pgfpoint{-1cm}{-1cm}}
\edef\angleX{\pgfmathresult}
\node at (3,0) {X=\angleX};
\end{tikzpicture}
\end{document}
答案1
pgfmanual v 3.1.5 在第 1045 页上说
所以
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[bullet/.style={circle,draw,fill,inner sep=1pt,label=#1}]
\pgfmathanglebetweenpoints{\pgfpoint{0cm}{1cm}}{\pgfpoint{-1cm}{-1cm}}
\edef\angleX{\pgfmathresult}
\draw (-1,-1) coordinate[bullet={below:$q$}] -- (0,1) coordinate[bullet={above:$p$}] -- ++ (1,0)
arc[start angle=0,end angle=\angleX,radius=1]
node[midway,above=1ex]{$\alpha=\pgfmathprintnumber{\angleX}$};
\end{tikzpicture}
\end{document}
顺便说一句,你正在加载calc
但并未使用它。你可以用它作为测量角度的替代方法。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[bullet/.style={circle,draw,fill,inner sep=1pt,label=#1}]
\draw (-1,-1) coordinate[bullet={below:$q$}] -- (0,1) coordinate[bullet={above:$p$}] -- ++ (1,0)
let \p1=($(0,1)-(-1,-1)$),\n1={180+atan2(\y1,\x1)} in
arc[start angle=0,end angle=\n1,radius=1]
node[midway,above=1ex]
{$\alpha=\pgfmathparse{\n1}\pgfmathprintnumber{\pgfmathresult}$};
\end{tikzpicture}
\end{document}