绘制三角形内线段的代码错误

绘制三角形内线段的代码错误

我认为这篇帖子应该尽快被丢弃。我一直不愿意发布它。(这篇帖子的代码与我发布的关于节点标签与点的距离不相同的代码类似。)我画了一个三角形 ABC。我将点 S 放在 A 到 B 的中间。我想在 BC 上放置一个点 T,使得通过 S 和 T 的线位于通过 S 的水平线下方 30 度。在代码中,我发出命令\path[name path=ST] (S) --++ (-30:5);来执行此操作。我得到了一条通过 S 和 C 的线。如果我用 替换-30-90我会得到相同的图片!代码有什么问题?

\documentclass{amsart}
\usepackage{tikz}
\usetikzlibrary{calc,positioning,intersections}

\begin{document}

\begin{tikzpicture}

\coordinate[label=225:$A$] (A) at (0,0);
\coordinate[label=90:$B$] (B) at (60:6);

%These commands position vertex C, label it C, and positions the label southeast of the vertex.
\path[overlay,name path=horizontal] (A) -- ++(10,0);
\path[overlay,name path=BC] (B) -- ($(B)!2!75:(A)$);
\path[name intersections={of= horizontal and BC, by=C}];
\coordinate[label={[blue]-45:$C$}] (blah-blah) at (C);


%This command draws the triangle.
\draw (A) -- (B) -- (C) -- cycle;

%This command draws the line segment from the midpoint S on AB to a point T on BC.
\coordinate (S) at ($(A)!0.5!(B)$);
\path[name path=ST] (S) --++ (-30:5);
\path[name intersections={of= ST and BC, by=T}];
\draw[dashed] (S) -- (T);

\end{tikzpicture}

\end{document}

答案1

很容易看出,如果你\draw[blue, name path=ST] (S) --++ (-30:5);使用\path[name path=ST] (S) --++ (-30:5);

在此处输入图片描述

这条线太短,不相交BC。只需将其加长即可:

\documentclass{amsart}
\usepackage{tikz}
\usetikzlibrary{calc,positioning,intersections}

\begin{document}

\begin{tikzpicture}

\coordinate[label=225:$A$] (A) at (0,0);
\coordinate[label=90:$B$] (B) at (60:6);

%These commands position vertex C, label it C, and positions the label southeast of the vertex.
\draw[green,overlay,name path=horizontal] (A) -- ++(10,0);
\draw[red, overlay,name path=BC] (B) -- ($(B)!2!75:(A)$);
\path[name intersections={of= horizontal and BC, by=C}];
\coordinate[label={[blue]-45:$C$}] (blah-blah) at (C);


%This command draws the triangle.
\draw (A) -- (B) -- (C) -- cycle;

%This command draws the line segment from the midpoint S on AB to a point T on BC.
\coordinate[label=above left:S] (S) at ($(A)!0.5!(B)$);
\draw[blue, name path=ST] (S) --++ (-30:15);
\path[name intersections={of= ST and BC, by=T}];
\draw[dashed] (S)  -- (T) node [above right]{$T$};

\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容