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

Latex / Tikz: draw a vertical line to a straight line

也许你能帮帮我,我试着从一条Point/Coordinate画一条直线到一条直线。我用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}

This where the red line should go

红线应该从坐标(S1)垂直到直线(A -- B)。 我试着把它画成这样:

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

然后他画了一条线来坐标A

谢谢,

您可以通过为 AB 上的点定义一个新坐标(比如 S3)来做到这一点:

\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)$);
\coordinate (S3) at ($(A)!0.66!(B)$);
\draw [very thick] (S1) -- node[above]{x} (S2);
\draw [red!100, thick] (S1) -- node[left]{T} (S3);
\end{tikzpicture}

您无需定义新坐标,但可以使用 calc 库中的投影标识符。

在最后一行你只需要

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

这意味着沿着A--B取S1投影到A--B上的点。

您的语法几乎是正确的,但是发球运算符 |--| 从一侧获取 x 坐标,从另一侧获取 y 坐标。当你写 A -| B 你得到了 A 的 y 坐标和 B 的 x 坐标,但在你的代码中,A 和 B 具有相同的 x 坐标,所以这再次给你点 A。相反,你想要 A -| S1,或者等价地 S1 |- A

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

\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[left]{T} (S1 |- A);
      \end{tikzpicture}
\end{document}