在显示中,我有三个具有相同度量的角度。(这是仅有的三个标记的角度。它们以点 、 和 为中心O
。P
)Q
我正在使用此代码来熟悉arc
语法和 let-in
语法。要在 处绘制弧P
,我将起点声明为($(P)!0.5cm!(R)$)
。命令的这一部分是正确的。但我不确定 处未绘制弧的原因P
。
\documentclass{amsart}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{tikz}
\usetikzlibrary{calc,positioning,intersections,quotes}
\begin{document}
\vfill
\pagebreak
\noindent \hspace*{\fill}
\begin{tikzpicture}
\coordinate (O) at (0,0);
\draw[-latex,name path=ray_1] (O) -- (10:7);
\coordinate (label_for_ray_r_1) at ($(10:7) +(10:3mm)$);
\node at (label_for_ray_r_1){$r_{1}$};
\node at ($(O)!-3mm!(10:7)$){$O$};
\draw[-latex,name path=ray_2] (O) -- (135:3.5);
\coordinate (label_for_ray_r_2) at ($(135:3.5) +(135:0.3)$);
\node at (label_for_ray_r_2){$r_{2}$};
\draw[-latex,name path=ray_3] (O) -- (342.5:8);
\coordinate (label_for_ray_r_3) at ($(342.5:8) +(342.5:0.3)$);
\node at (label_for_ray_r_3){$r_{3}$};
%The ray opposite to $r_{2}$ is drawn.
\draw[-latex,dashed,name path=opposite_to_ray_2] (O) -- (-45:8);
\coordinate (Q) at (342.5:6.5);
\draw[fill] (Q) circle (1.5pt);
\coordinate (A) at ($(O)!(Q)!(10:7)$);
\node at ($(A)!-3mm!(Q)$){$A$};
\draw[fill,blue] (A) circle (1.5pt);
\draw[name path=path_AQ] (A) -- (Q);
%The projection of Q onto the ray opposite $r_{2}$ is called $P$.
\coordinate (P) at ($(O)!(Q)!(-45:7)$);
\node at ($(P)!3mm!90:(O)$){$P$};
\node at ($(Q)!-3mm!(P)$){$Q$};
\draw[dashed] (Q) -- (P);
%The projection of P onto $r_{1}$ is called $B$.
\coordinate (B) at ($(O)!(P)!(10:7)$);
\node at ($(B)!3mm!-90:(O)$){$B$};
\draw[dashed] (B) -- (P);
%The intersection of the line through P with the same slope as $r_{1}$ and the line through A and Q
%is labeled $R$.
\coordinate (a_point_R_1_in_the_plane_to_determine_R) at ($(P) +(10:3)$);
\path[name path=P_to_R_1] (P) -- (a_point_R_1_in_the_plane_to_determine_R);
\coordinate (a_point_R_2_in_the_plane_to_determine_R) at ($(Q)!-1!(A)$);
\path[name path=P_to_R_2] (Q) -- (a_point_R_2_in_the_plane_to_determine_R);
\coordinate[name intersections={of=P_to_R_1 and P_to_R_2, by={R}}];
\draw[fill] (R) circle (1.5pt);
\draw[dashed] (P) -- (R);
\draw[dashed] (Q) -- (R);
%The label for R is typeset.
\coordinate (label_R_below) at ($(R)!-7mm!(Q)$);
\coordinate (label_R_right) at ($(R)!-7mm!(P)$);
\coordinate (label_R) at ($(label_R_below)!0.5!(label_R_right)$);
\node[blue] at ($(R)!3mm!(label_R)$){$R$};
%An angle is drawn at O.
\draw[draw=blue] (O) ++(10:5mm) arc (10:-45:5mm);
%An angle at P with measure x is drawn.
\draw[draw=blue] let \p1=($(B)-(P)$), \n1={atan(\y1/\x1)}, \p2=($(Q)-(P)$), \n2={atan(\y2/\x2)} in ($(P)!0.5cm!(B)$) arc (\n1:\n2:0.5);
%An angle at Q with measure x is drawn.
\draw[draw=blue] let \p1=($(Q)-(P)$), \n1={atan(\y1/\x1)}, \p2=($(Q)-(R)$), \n2={atan(\y2/\x2)} in ($(Q)!0.5cm!(P)$) arc (\n1:\n2:0.5);
\end{tikzpicture}
\end{document}
答案1
我欣赏 Tarass 答案的优雅,但 OP 挑战我展示不使用 的解决方案atan
。在这个解决方案中,您需要知道 角度所在的象限,并相应地加或减 180 度。好的,我们开始吧:
\documentclass[border=1mm,
class=amsart,
preview]{standalone}
\usepackage{amsmath,amsfonts}
\usepackage{tikz}
\usetikzlibrary{calc,positioning,intersections,quotes}
\begin{document}
\begin{tikzpicture}
\coordinate (O) at (0,0);
\draw[-latex,name path=ray_1] (O) -- (10:7);
\coordinate (label_for_ray_r_1) at ($(10:7) +(10:3mm)$);
\node at (label_for_ray_r_1){$r_{1}$};
\node at ($(O)!-3mm!(10:7)$){$O$};
\draw[-latex,name path=ray_2] (O) -- (135:3.5);
\coordinate (label_for_ray_r_2) at ($(135:3.5) +(135:0.3)$);
\node at (label_for_ray_r_2){$r_{2}$};
\draw[-latex,name path=ray_3] (O) -- (342.5:8);
\coordinate (label_for_ray_r_3) at ($(342.5:8) +(342.5:0.3)$);
\node at (label_for_ray_r_3){$r_{3}$};
%The ray opposite to $r_{2}$ is drawn.
\draw[-latex,dashed,name path=opposite_to_ray_2] (O) -- (-45:8);
\coordinate (Q) at (342.5:6.5);
\draw[fill] (Q) circle (1.5pt);
\coordinate (A) at ($(O)!(Q)!(10:7)$);
\node at ($(A)!-3mm!(Q)$){$A$};
\draw[fill,blue] (A) circle (1.5pt);
\draw[name path=path_AQ] (A) -- (Q);
%The projection of Q onto the ray opposite $r_{2}$ is called $P$.
\coordinate (P) at ($(O)!(Q)!(-45:7)$);
\node at ($(P)!3mm!90:(O)$){$P$};
\node at ($(Q)!-3mm!(P)$){$Q$};
\draw[dashed] (Q) -- (P);
%The projection of P onto $r_{1}$ is called $B$.
\coordinate (B) at ($(O)!(P)!(10:7)$);
\node at ($(B)!3mm!-90:(O)$){$B$};
\draw[dashed] (B) -- (P);
%The intersection of the line through P with the same slope as $r_{1}$ and the line through A and Q is labeled $R$.
\coordinate (a_point_R_1_in_the_plane_to_determine_R) at ($(P) +(10:3)$);
\path[name path=P_to_R_1] (P) -- (a_point_R_1_in_the_plane_to_determine_R);
\coordinate (a_point_R_2_in_the_plane_to_determine_R) at ($(Q)!-1!(A)$);
\path[name path=P_to_R_2] (Q) -- (a_point_R_2_in_the_plane_to_determine_R);
\coordinate[name intersections={of=P_to_R_1 and P_to_R_2, by={R}}];
\draw[fill] (R) circle (1.5pt);
\draw[dashed] (P) -- (R);
\draw[dashed] (Q) -- (R);
%The label for R is typeset.
\coordinate (label_R_below) at ($(R)!-7mm!(Q)$);
\coordinate (label_R_right) at ($(R)!-7mm!(P)$);
\coordinate (label_R) at ($(label_R_below)!0.5!(label_R_right)$);
\node[blue] at ($(R)!3mm!(label_R)$){$R$};
%Angles at O, P and Q:
\path[draw=blue]
%An angle is drawn at O.
(O) ++(10:5mm) arc (10:-45:5mm)
%An angle at P with measure x is drawn.
let \p1=($(B)-(P)$),
\n1={atan(\y1/\x1)},
\p2=($(Q)-(P)$),
\n2={atan(\y2/\x2)} in
($(P)!0.5cm!(B)$) arc (\n1+180:\n2:0.5)% added 180 degree to \n1
%An angle at Q with measure x is drawn.
let \p1=($(Q)-(P)$),
\n1={atan(\y1/\x1)},
\p2=($(Q)-(R)$),
\n2={atan(\y2/\x2)} in
($(Q)!0.5cm!(P)$) arc (\n1-180:\n2:0.5);% substracted 180 degree from \n1
\end{tikzpicture}
\end{document}
答案2
问题出在atan
给出模 180° 的答案,因为它不考虑象限,atan2
所以使用。您可能认为重复代码时可以使用宏。一旦它起作用,就制作一个宏。
可以比较atan
红色和atan2
蓝色:第二个计算出正确的非定向角度,但两者都对三角定向不敏感。
绿色:解决了两个问题。
\documentclass{amsart}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{tikz}
\usetikzlibrary{calc,positioning,intersections,quotes}
\newcommand{\AngleBad}[4][red]{%
\draw[#1] let
\p1=($(#2)-(#3)$),
\n1={atan(\y1/\x1)},
\p2=($(#4)-(#3)$),
\n2={atan(\y2/\x2)} in
($(#3)!.4cm!(#2)$) arc (\n1:\n2:.4) ;
}
\newcommand{\AngleBetter}[4][blue]{%
\draw[#1] let
\p1=($(#2)-(#3)$),
\n1={atan2(\y1,\x1)},
\p2=($(#4)-(#3)$),
\n2={atan2(\y2,\x2)} in
($(#3)!.5cm!(#2)$) arc (\n1:\n2:.5) ;
}
\newcommand{\MarkAngle}[4][green]{%
\pgfmathanglebetweenpoints{\pgfpointanchor{#3}{center}}{\pgfpointanchor{#2}{center}}%
\let\AngleA\pgfmathresult
\pgfmathanglebetweenpoints{\pgfpointanchor{#3}{center}}{\pgfpointanchor{#4}{center}}%
\let\AngleB\pgfmathresult
\pgfmathparse{ifthenelse(\AngleA>\AngleB,\AngleA-360,\AngleA)}
\let\AngleA\pgfmathresult ;
\draw[#1] ($(#3)!.6cm!(#2)$) arc (\AngleA:\AngleB:.6) ; }
\begin{document}
\vfill
\pagebreak
\noindent \hspace*{\fill}
\begin{tikzpicture}
\coordinate (O) at (0,0);
\draw[-latex,name path=ray_1] (O) -- (10:7);
\coordinate (label_for_ray_r_1) at ($(10:7) +(10:3mm)$);
\node at (label_for_ray_r_1){$r_{1}$};
\node at ($(O)!-3mm!(10:7)$){$O$};
\draw[-latex,name path=ray_2] (O) -- (135:3.5);
\coordinate (label_for_ray_r_2) at ($(135:3.5) +(135:0.3)$);
\node at (label_for_ray_r_2){$r_{2}$};
\draw[-latex,name path=ray_3] (O) -- (342.5:8);
\coordinate (label_for_ray_r_3) at ($(342.5:8) +(342.5:0.3)$);
\node at (label_for_ray_r_3){$r_{3}$};
%The ray opposite to $r_{2}$ is drawn.
\draw[-latex,dashed,name path=opposite_to_ray_2] (O) -- (-45:8);
\coordinate (Q) at (342.5:6.5);
\draw[fill] (Q) circle (1.5pt);
\coordinate (A) at ($(O)!(Q)!(10:7)$);
\node at ($(A)!-3mm!(Q)$){$A$};
\draw[fill,blue] (A) circle (1.5pt);
\draw[name path=path_AQ] (A) -- (Q);
%The projection of Q onto the ray opposite $r_{2}$ is called $P$.
\coordinate (P) at ($(O)!(Q)!(-45:7)$);
\node at ($(P)!3mm!90:(O)$){$P$};
\node at ($(Q)!-3mm!(P)$){$Q$};
\draw[dashed] (Q) -- (P);
%The projection of P onto $r_{1}$ is called $B$.
\coordinate (B) at ($(O)!(P)!(10:7)$);
\node at ($(B)!3mm!-90:(O)$){$B$};
\draw[dashed] (B) -- (P);
%The intersection of the line through P with the same slope as $r_{1}$ and the line through A and Q
%is labeled $R$.
\coordinate (a_point_R_1_in_the_plane_to_determine_R) at ($(P) +(10:3)$);
\path[name path=P_to_R_1] (P) -- (a_point_R_1_in_the_plane_to_determine_R);
\coordinate (a_point_R_2_in_the_plane_to_determine_R) at ($(Q)!-1!(A)$);
\path[name path=P_to_R_2] (Q) -- (a_point_R_2_in_the_plane_to_determine_R);
\coordinate[name intersections={of=P_to_R_1 and P_to_R_2, by={R}}];
\draw[fill] (R) circle (1.5pt);
\draw[dashed] (P) -- (R);
\draw[dashed] (Q) -- (R);
%The label for R is typeset.
\coordinate (label_R_below) at ($(R)!-7mm!(Q)$);
\coordinate (label_R_right) at ($(R)!-7mm!(P)$);
\coordinate (label_R) at ($(label_R_below)!0.5!(label_R_right)$);
\node[blue] at ($(R)!3mm!(label_R)$){$R$};
\AngleBad{P}{O}{B}
\AngleBad{B}{O}{P} % not sensitive to trigonometric orientation
\AngleBad{P}{Q}{R}
\AngleBad{Q}{P}{B}
\AngleBetter{P}{O}{B}
\AngleBetter{B}{O}{P} % not sensitive to trigonometric orientation
\AngleBetter{P}{Q}{R}
\AngleBetter{Q}{P}{B}
\MarkAngle{P}{O}{B} % sensitive to trigonometric orientation
\MarkAngle[dashed,green]{B}{O}{P}
\MarkAngle{P}{Q}{R}
\MarkAngle{Q}{P}{B}
\end{tikzpicture}
\end{document}
答案3
以下是元帖子进行比较。特别是,我认为使用rotated
和可以简化绘图angle
,这两个函数的设计目的是为了让您无需明确考虑正弦、余弦和反正切。(参见 Metafont 书,第 67 页)。
prologues := 3;
outputtemplate := "%j%c.eps";
beginfig(1);
% define the end points of the three rays
z1 = right scaled 200 rotated 10;
z2 = right scaled 100 rotated 135;
z3 = right scaled 225 rotated -17.5;
% define the other points, relative to Q
pair A, B, P, Q, R;
Q = 0.8125 z3;
A = whatever[origin, z1]; A-Q = whatever * z1 rotated 90;
P = whatever[origin, z2]; P-Q = whatever * z2 rotated 90;
B = whatever[origin, z1]; B-P = whatever * z1 rotated 90;
R = whatever[A,Q]; R-P = whatever * (B-P) rotated 90;
% mark the angles
drawoptions(withcolor .67 blue);
draw fullcircle scaled 30 rotated angle (Q-P) shifted P cutafter (P--B);
draw fullcircle scaled 30 rotated angle (P-Q) shifted Q cutafter (Q--R);
draw fullcircle scaled 30 rotated angle P cutafter (origin--z1);
drawoptions();
% draw the rays and A--Q
drawarrow origin -- z1; label(btex $r_1$ etex, z1 scaled 1.05);
drawarrow origin -- z2; label(btex $r_2$ etex, z2 scaled 1.08);
drawarrow origin -- z3; label(btex $r_3$ etex, z3 scaled 1.05);
draw A--Q;
% draw the dashed lines
drawoptions(dashed evenly);
draw B--P--R--Q--P;
drawarrow origin -- P scaled 4/3;
drawoptions();
% label the points
dotlabel.urt(btex $Q$ etex, Q);
dotlabel.top(btex $A$ etex, A);
dotlabel.lrt(btex $R$ etex, R) withcolor .67 blue;
label.top (btex $B$ etex, B);
label.llft(btex $P$ etex, P);
label.llft(btex $O$ etex, origin);
endfig;
end.
笔记:该构造P = whatever[a,b]
将 P 定义为位于通过 a 和 b 的直线上某处的点。While表示“从 Q 到 P 的方向应该是从 b 到 a 的方向的某个倍数”。当然,当它是原点时P-Q = whatever * (a-b)
,您可以省略。b
普通 MPorigin=(0,0)
为您定义。