Tikz:画一条垂直线到一条直线

Tikz:画一条垂直线到一条直线

我正在尝试从点/坐标绘制一条直线。到目前为止,我已经使用 Tikz 绘制了:

      \begin{tikzpicture}
      \coordinate [label=left:$A$] (A) at (-5,-5){};
      \coordinate [label=right:$B$] (B) at (5,-5) {};
      \coordinate [label=right:$C$] (C) at (5,1) {};
      \coordinate [label=left:$D$] (D) at (-5,1) {};

      \draw [thick] (A) -- node[midway] {$\parallel$} (B) -- node[sloped]{$\parallel$} (C) -- (D) -- cycle;

      \coordinate (S1) at ($(D)!0.66!(C)$);
      \coordinate (S2) at ($(A)!0.11!(B)$);
      \draw [very thick] (S1) -- node[above]{x} (S2);
      \draw [red!100, thick] (S1) -- node[above]{T} (A -| B );
      \end{tikzpicture}

红线应该放在这里

红线应该从坐标(S1)垂直延伸到直线(A-B)。我尝试这样画:

     \draw [red!100, thick] (S1) -- node[above]{T} (A -| B );

但这却画了一条线到坐标 A。

答案1

你要

\draw [red!100, thick] (S1) -- node[right]{T} (S1 |- S2);

即从S1到 x 坐标为S1、 y 坐标为 的点S2。(参见TikZ:箭头的 |- 符号到底起什么作用?-|有关/的更多解释|-。)

代码输出

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc} 
\begin{document}

      \begin{tikzpicture}
      \coordinate [label=left:$A$] (A) at (-5,-5){};
      \coordinate [label=right:$B$] (B) at (5,-5) {};
      \coordinate [label=right:$C$] (C) at (5,1) {};
      \coordinate [label=left:$D$] (D) at (-5,1) {};

      \draw [thick] (A) -- node[midway] {$\parallel$} (B) -- node[sloped]{$\parallel$} (C) -- (D) -- cycle;

      \coordinate (S1) at ($(D)!0.66!(C)$);
      \coordinate (S2) at ($(A)!0.11!(B)$);
      \draw [very thick] (S1) -- node[above]{x} (S2);
      \draw [red!100, thick] (S1) -- node[right]{T} (S1 |- S2);
      \end{tikzpicture}
\end{document}

\end{document}

相关内容