我画了一个直角三角形,其直角位于C
。顶点C
通过直角三角形的高公式从三角形直角所在的顶点开始定位。由于P
是 的高的底边C
,并且|AP|=6
和|BP|=8
,高的长度为\sqrt{(6)(8)} = 4\sqrt{3}
。(该图缩小了 4 倍。)
我担心的是,我画的直角标记C
不是正方形。(用 替换 可以更明显地看出这一点3mm
。10mm
)要么TikZ
是定位不准确C
,要么是绘制直角标记的代码有错误。
\documentclass{amsart}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings,decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}
%The vertices A, B, and C for a right triangle are located.
\coordinate (A) at (0,0);
\coordinate (B) at (30:3.5);
\coordinate (P) at (30:1.5);
%P is the foot of the altitude of a right triangle from C to to $\overline{AB}$.
%Since the length of $\overline{AP}$ is 6 and the length of $\overline{BP}$ is 8,
%the length of the altitude is $\sqrt{(6)(8)} = 4\sqrt{3}$.
\coordinate (C) at ($(P) +(120:{sqrt(3)})$);
\draw[dashed] (P) -- (C);
\draw let \p1=($(A)-(B)$), \n1={atan(\y1/\x1)}, \p2=($(A)-(C)$), \n2={atan(\y2/\x2)} in node[anchor={0.5*(\n1+\n2)}, inner sep=0] at ($(A) + ({0.5*(\n1+\n2)+180}:0.15)$){$A$};
\coordinate (B) at (30:4);
\draw let \p1=($(B)-(A)$), \n1={atan(\y1/\x1)}, \p2=($(B)-(C)$), \n2={atan(\y2/\x2)} in node[anchor={0.5*(\n1+\n2)+180}, inner sep=0] at ($(B) + ({0.5*(\n1+\n2)}:0.15)$){$B$};
\draw let \p1=($(P)-(C)$), \n1={atan(\y1/\x1)} in node[anchor=\n1, inner sep=0] at ($(C)!-0.15cm!(P)$){$C$};
\draw let \p1=($(P)-(C)$), \n1={atan(\y1/\x1)} in node[anchor={\n1-180}, inner sep=0] at ($(P)!-0.15cm!(C)$){$P$};
%The right-angle mark at C is drawn.
\coordinate (U) at ($(C)!3mm!45:(A)$);
\draw (U) -- ($(C)!(U)!(A)$);
\draw (U) -- ($(C)!(U)!(B)$);
%The right-angle mark at P is drawn.
\coordinate (V) at ($(P)!3mm!-45:(A)$);
\draw (V) -- ($(P)!(V)!(A)$);
\draw (V) -- ($(P)!(V)!(C)$);
%$\triangle{ABC}$ is drawn.
\draw (C) -- (A) -- (B) -- (C);
%The angle mark for $\angle{ABC}$ is drawn. It is marked with "|".
\draw[draw=blue] let \p1=($(B)-(A)$), \n1={atan(\y1/\x1)}, \p2=($(B)-(C)$), \n2={atan(\y2/\x2)} in ($(B)!0.55cm!(A)$) arc ({\n1+180}:{\n2+180}:0.55);
\draw[draw=blue] let \p1=($(B)-(A)$), \n1={atan(\y1/\x1)}, \p2=($(B)-(C)$), \n2={atan(\y2/\x2)} in ($(B) +({0.5*(\n1+\n2)+180}:{0.55cm-3pt})$) -- ($(B) +({0.5*(\n1+\n2)+180}:{0.55cm+3pt})$);
%The angle mark for $\angle{ACP}$ is drawn. It is marked with "|".
\draw[draw=blue] let \p1=($(C)-(P)$), \n1={atan(\y1/\x1)}, \p2=($(C)-(A)$), \n2={atan(\y2/\x2)} in ($(C)!0.55cm!(P)$) arc (\n1:{\n2-180}:0.55);
\draw[draw=blue] let \p1=($(C)-(P)$), \n1={atan(\y1/\x1)}, \p2=($(C)-(A)$), \n2={atan(\y2/\x2)} in ($(C) +({0.5*(\n1+\n2-180)}:{0.55cm-3pt})$) -- ($(C) +({0.5*(\n1+\n2-180)}:{0.55cm+3pt})$);
\end{tikzpicture}
\end{document}
答案1
您的图片包含两个B
在不同位置命名的不同坐标。如果您注释掉第二个定义,据我所知,三角形看起来没问题:
\documentclass[border=10pt,tikz]{standalone}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
%The vertices A, B, and C for a right triangle are located.
\coordinate (A) at (0,0);
\coordinate (B) at (30:3.5);
\coordinate (P) at (30:1.5);
%P is the foot of the altitude of a right triangle from C to to $\overline{AB}$.
%Since the length of $\overline{AP}$ is 6 and the length of $\overline{BP}$ is 8,
%the length of the altitude is $\sqrt{(6)(8)} = 4\sqrt{3}$.
\coordinate (C) at ($(P) +(120:{sqrt(3)})$);
\draw[dashed] (P) -- (C);
\draw let \p1=($(A)-(B)$), \n1={atan(\y1/\x1)}, \p2=($(A)-(C)$), \n2={atan(\y2/\x2)} in node[anchor={0.5*(\n1+\n2)}, inner sep=0] at ($(A) + ({0.5*(\n1+\n2)+180}:0.15)$){$A$};
% \coordinate (B) at (30:4);
\draw let \p1=($(B)-(A)$), \n1={atan(\y1/\x1)}, \p2=($(B)-(C)$), \n2={atan(\y2/\x2)} in node[anchor={0.5*(\n1+\n2)+180}, inner sep=0] at ($(B) + ({0.5*(\n1+\n2)}:0.15)$){$B$};
\draw let \p1=($(P)-(C)$), \n1={atan(\y1/\x1)} in node[anchor=\n1, inner sep=0] at ($(C)!-0.15cm!(P)$){$C$};
\draw let \p1=($(P)-(C)$), \n1={atan(\y1/\x1)} in node[anchor={\n1-180}, inner sep=0] at ($(P)!-0.15cm!(C)$){$P$};
%The right-angle mark at C is drawn.
\coordinate (U) at ($(C)!3mm!45:(A)$);
\draw (U) -- ($(C)!(U)!(A)$);
\draw (U) -- ($(C)!(U)!(B)$);
%The right-angle mark at P is drawn.
\coordinate (V) at ($(P)!3mm!-45:(A)$);
\draw (V) -- ($(P)!(V)!(A)$);
\draw (V) -- ($(P)!(V)!(C)$);
%$\triangle{ABC}$ is drawn.
\draw (C) -- (A) -- (B) -- (C);
%The angle mark for $\angle{ABC}$ is drawn. It is marked with "|".
\draw[draw=blue] let \p1=($(B)-(A)$), \n1={atan(\y1/\x1)}, \p2=($(B)-(C)$), \n2={atan(\y2/\x2)} in ($(B)!0.55cm!(A)$) arc ({\n1+180}:{\n2+180}:0.55);
\draw[draw=blue] let \p1=($(B)-(A)$), \n1={atan(\y1/\x1)}, \p2=($(B)-(C)$), \n2={atan(\y2/\x2)} in ($(B) +({0.5*(\n1+\n2)+180}:{0.55cm-3pt})$) -- ($(B) +({0.5*(\n1+\n2)+180}:{0.55cm+3pt})$);
%The angle mark for $\angle{ACP}$ is drawn. It is marked with "|".
\draw[draw=blue] let \p1=($(C)-(P)$), \n1={atan(\y1/\x1)}, \p2=($(C)-(A)$), \n2={atan(\y2/\x2)} in ($(C)!0.55cm!(P)$) arc (\n1:{\n2-180}:0.55);
\draw[draw=blue] let \p1=($(C)-(P)$), \n1={atan(\y1/\x1)}, \p2=($(C)-(A)$), \n2={atan(\y2/\x2)} in ($(C) +({0.5*(\n1+\n2-180)}:{0.55cm-3pt})$) -- ($(C) +({0.5*(\n1+\n2-180)}:{0.55cm+3pt})$);
\end{tikzpicture}
\end{document}