[Tex/LaTex] Tikz: draw a vertical line to a straight line

math-modetikz-pgftikz-styles

I am trying to draw a line from a Point/Coordinate to a straight line. So far, I have used Tikz to draw:

      \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 is where the red line should go

The red line should go from coordinate (S1) to the straight line (A — B) vertically.
I tried it to draw it like this:

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

But instead this drew a line to coordinate A.

Best Answer

You want

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

i.e. from S1 to the point that has the x-coordinate of S1, and y-coordinate of S2. (See TikZ: What EXACTLY does the the |- notation for arrows do? for some more explanation of -|/|-.)

output of code

\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}